Skip to content

🛡️ Sentinel: [CRITICAL] Fix DOMPurify bypass in Mermaid foreignObject attributes#270

Merged
ImChong merged 1 commit into
mainfrom
sentinel-fix-mermaid-xss-3219942391315052121
Jun 12, 2026
Merged

🛡️ Sentinel: [CRITICAL] Fix DOMPurify bypass in Mermaid foreignObject attributes#270
ImChong merged 1 commit into
mainfrom
sentinel-fix-mermaid-xss-3219942391315052121

Conversation

@ImChong

@ImChong ImChong commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Vulnerability: Found a critical DOM-based XSS vulnerability in assets/js/mermaid-config.js (sanitizeMermaidSvg) where an attacker could bypass DOMPurify by embedding malicious attributes (e.g., onload="alert(1)") in SVG foreignObject tags. The code extracted foreignObject tags using a regex, stored their unsanitized attributes, sanitized the rest of the SVG structure via DOMPurify, and then blindly re-injected the raw attributes when restoring the foreignObject content.
Impact: A malicious actor could provide specially crafted Markdown that compiles into a Mermaid graph with malicious JavaScript, bypassing the site's default DOMPurify sanitization.
Fix: Let DOMPurify natively sanitize the placeholder attributes. The regex swap was updated to attach the extracted attributes directly onto the data-fo-placeholder element before DOMPurify processes the entire SVG, effectively enforcing the sanitizer on those attributes.
Verification: Manual verification via unit test scripts that DOMPurify properly scrubs onload attributes. All pytest Python test suites complete with success.


PR created automatically by Jules for task 3219942391315052121 started by @ImChong

Co-authored-by: ImChong <74563097+ImChong@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.

@ImChong ImChong merged commit 3ee4aeb into main Jun 12, 2026
1 check passed
@ImChong ImChong deleted the sentinel-fix-mermaid-xss-3219942391315052121 branch June 12, 2026 15:09
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