π‘οΈ Sentinel: [CRITICAL] Fix XSS vulnerability in markdown rendering#1251
π‘οΈ Sentinel: [CRITICAL] Fix XSS vulnerability in markdown rendering#1251khangnghiem wants to merge 1 commit into
Conversation
In `site/app.js`, markdown is parsed with `marked.parse` and rendered directly to `innerHTML`. `marked` does not sanitize HTML tags by default. This commit adds defensive conditional sanitization using `DOMPurify` (with a secure fallback) before assigning to `innerHTML`. 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
π¨ Severity: CRITICAL
π‘ Vulnerability:
site/app.jsrenders markdown notes usingmarked.parse(), which allows raw HTML by default. The resulting output was being directly assigned toinnerHTMLwithout any sanitization, creating a Cross-Site Scripting (XSS) vulnerability if the markdown source contained malicious payload.π― Impact: An attacker could embed malicious HTML/JS within a note's markdown. When a user opens the specs panel and the note is rendered, the payload would execute in their browser session, potentially stealing data or hijacking the session.
π§ Fix: Implemented conditional sanitization using
window.DOMPurify.sanitize()aftermarked.parse(). IfDOMPurifyis unavailable, it securely degrades to the pre-existing, safe inline regex replacement (<and>). Included{ ADD_ATTR: ['data-note-node', 'data-node'] }configuration to ensure required custom UI attributes are preserved by the sanitizer.β Verification: Ran
node --check site/app.jsto confirm valid syntax. Verified the source code visually to ensure the fix was properly applied to theinnerHTMLassignment and that the safe fallback string was preserved exactly as it existed before. Updated the.jules/sentinel.mdjournal with this learning.PR created automatically by Jules for task 9044137575033458410 started by @khangnghiem