Skip to content

🔒 Fix XSS vulnerability by replacing @html with a secure dompurify fragment action - #72

Merged
Sparkier merged 1 commit into
mainfrom
fix/security-xss-blog-render-8729800088616993268
Aug 1, 2026
Merged

🔒 Fix XSS vulnerability by replacing @html with a secure dompurify fragment action#72
Sparkier merged 1 commit into
mainfrom
fix/security-xss-blog-render-8729800088616993268

Conversation

@Sparkier

@Sparkier Sparkier commented Aug 1, 2026

Copy link
Copy Markdown
Owner

🎯 What: The vulnerability fixed
The raw @html content tag was being used to render blog content, which poses a Cross-Site Scripting (XSS) vulnerability, even when the HTML is pre-sanitized due to DOM mutation-based bypasses.

⚠️ Risk: The potential impact if left unfixed
If an attacker can inject malicious payloads into the rendered Markdown (e.g. through a dompurify bypass or stored payload), the code will be executed in the user's browser, allowing unauthorized access, session hijacking, or defacement.

🛡️ Solution: How the fix addresses the vulnerability
Replaced the {@html} rendering with a custom Svelte action, renderSanitizedHtml. This action parses the HTML safely utilizing isomorphic-dompurify configured to return a direct DocumentFragment ({ RETURN_DOM_FRAGMENT: true }), preventing the string-to-DOM conversion typically exploited in mutation XSS. The fragment is then securely injected into the container via replaceChildren(). Tests were added to ensure this action accurately purifies inputs while maintaining content updating dynamically.


PR created automatically by Jules for task 8729800088616993268 started by @Sparkier

Co-authored-by: Sparkier <5690524+Sparkier@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.

@Sparkier
Sparkier merged commit 0e96bdb into main Aug 1, 2026
1 check passed
@Sparkier
Sparkier deleted the fix/security-xss-blog-render-8729800088616993268 branch August 1, 2026 11:10
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