Skip to content

🛡️ Sentinel: [MEDIUM] Fix JavaScript injection in DomMixin#40

Open
ToufiqQureshi wants to merge 1 commit intomainfrom
sentinel-fix-js-injection-dom-mixin-15747334358977430641
Open

🛡️ Sentinel: [MEDIUM] Fix JavaScript injection in DomMixin#40
ToufiqQureshi wants to merge 1 commit intomainfrom
sentinel-fix-js-injection-dom-mixin-15747334358977430641

Conversation

@ToufiqQureshi
Copy link
Owner

I have addressed a security vulnerability in chuscraper/core/tabs/dom.py where CSS selectors were being injected into JavaScript templates using unsanitized string interpolation within backticks (`). This could have allowed a malicious user-provided selector to execute arbitrary JavaScript in the browser context.

The fix involves using json.dumps(selector) to safely escape the selector as a standard JavaScript string literal and removing the problematic backticks. Additionally, I've hardened the query_selector_all method by explicitly casting the idx variable to an integer.

Verification was performed using a reproduction script that demonstrated the breakout before the fix and confirmed successful escaping after the fix. Existing core tests were verified for compilation.

Details:

  • Severity: MEDIUM
  • Vulnerability: JavaScript Injection (XSS in browser context)
  • Impact: Potential for arbitrary code execution in the automated browser instance if selectors are sourced from untrusted input.
  • Fix: Sanitization via json.dumps() and removal of template literal backticks.
  • Verification: Custom reproduction script final_verify.py confirmed the fix.

PR created automatically by Jules for task 15747334358977430641 started by @ToufiqQureshi

- Identified and fixed a JavaScript injection vulnerability in `chuscraper/core/tabs/dom.py`.
- Replaced unsanitized f-string interpolation of `selector` with `json.dumps(selector)` in JavaScript templates.
- Explicitly cast `idx` to `int` in `query_selector_all` for improved robustness.
- Verified fix with reproduction and verification scripts.
- Updated Sentinel journal with findings and prevention strategies.

Co-authored-by: ToufiqQureshi <139612256+ToufiqQureshi@users.noreply.github.com>
@google-labs-jules
Copy link
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.

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chuscraper Ready Ready Preview, Comment Mar 6, 2026 3:23am

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