🔒 fix: Unsafe JSON Parsing in Restore Command#77
🔒 fix: Unsafe JSON Parsing in Restore Command#77TrueAlpha-spiral wants to merge 1 commit intomainfrom
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: The
restoreCommandpreviously parsed checkpoint files from disk directly usingJSON.parseand assumed the shape of the data without runtime validation, which could be a localized security risk if a checkpoint file is maliciously crafted or corrupted..gemini/checkpointsenvironment, parsing unsanitized JSON and directly reading arbitrary object properties (likehistoryandtoolCall.name) could lead to unexpected behavior, prototype pollution vectors, or unhandled exceptions crashing the application.🛡️ Solution: Implemented robust schema validation using
zodinpackages/cli/src/ui/commands/restoreCommand.ts. The parsed data is now passed throughtoolCallDataSchema.parse()to ensure it strictly conforms to the expected structure before any data properties are accessed. Missing required properties (liketoolCall) are caught gracefully and return an explicit error instead of causing unhandled runtime crashes. Tests inrestoreCommand.test.tshave been updated to expect the safer, more explicit error handling.PR created automatically by Jules for task 2251652087094023051 started by @TrueAlpha-spiral