Skip to content

πŸ›‘οΈ Sentinel: Structural validation for save data#76

Open
b0x1 wants to merge 1 commit intomainfrom
sentinel/save-data-validation-5394744797254544891
Open

πŸ›‘οΈ Sentinel: Structural validation for save data#76
b0x1 wants to merge 1 commit intomainfrom
sentinel/save-data-validation-5394744797254544891

Conversation

@b0x1
Copy link
Copy Markdown
Owner

@b0x1 b0x1 commented Apr 22, 2026

This PR enhances the security of the save system by implementing structural validation for deserialized game state.

🚨 Severity: MEDIUM
πŸ’‘ Vulnerability: Insecure deserialization of save game data from localStorage using blind type casting.
🎯 Impact: Malformed or maliciously modified save data could cause the application to crash or enter an inconsistent state when loaded.
πŸ”§ Fix: Added a isValidSaveData type guard that verifies the presence and types of essential SaveData properties (players, map, turn, phase, etc.) after JSON parsing but before the data is used.
βœ… Verification:

  • Manual verification of src/game/systems/SaveSystem.ts structure.
  • Ran all project tests via pnpm test, confirming SaveManager.test.ts and SaveSystem.test.ts pass.
  • Verified that invalid/partial JSON objects now return null instead of being cast to SaveData.

PR created automatically by Jules for task 5394744797254544891 started by @b0x1

… data

Implemented structural validation in `SaveSystem.deserialize` to ensure
that game state loaded from `localStorage` contains all required fields
with correct types. This prevents potential runtime crashes or logic errors
caused by malformed or maliciously modified save data.

- Added `isValidSaveData` private method to `SaveSystem`.
- Updated `deserialize` to use `isValidSaveData` before returning.
- Updated security journal in `.jules/sentinel.md`.

Co-authored-by: b0x1 <21123655+b0x1@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant