Skip to content

πŸ›‘οΈ Sentinel: Fix JavaScript Injection in CanvasController - #2

Draft
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
sentinel-fix-js-injection-8759586791768783797
Draft

πŸ›‘οΈ Sentinel: Fix JavaScript Injection in CanvasController#2
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
sentinel-fix-js-injection-8759586791768783797

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This PR fixes a critical JavaScript injection vulnerability in CanvasController.swift.

Previously, user input was directly interpolated into a JavaScript function call:

webView.evaluateJavaScript("changeCharacter('\(searchBar.text)')")

This allowed an attacker to break out of the string literal using single quotes.

The fix utilizes JSONSerialization to properly escape the input string and passes it as a variable to the JavaScript context, eliminating the injection risk:

let jsonString = ... // safely encoded ["input"]
webView.evaluateJavaScript("var args = \(jsonString); changeCharacter(args[0]);")

This PR also adds the Sentinel Journal entry describing the vulnerability.


PR created automatically by Jules for task 8759586791768783797 started by @tsainez

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: JavaScript Injection (XSS equivalent in WebView)
   User input from the search bar was directly interpolated into a JavaScript string executed by the WebView. This allowed arbitrary JavaScript execution if the input contained special characters (e.g., single quotes).
🎯 Impact: Attackers could execute malicious JavaScript within the app's context.
πŸ”§ Fix:
   - Used `JSONSerialization` to safely encode the user input as a JSON string.
   - Refactored the `evaluateJavaScript` call to pass the encoded data as a variable (`args`), ensuring it is treated as data, not code.
βœ… Verification:
   - Verified that the new code constructs a valid JSON string and passes it safely to the JavaScript function `changeCharacter`.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

πŸ‘‹ 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!


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

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

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.

0 participants