Skip to content
This repository was archived by the owner on Jun 27, 2026. It is now read-only.

🔒 [security fix] Cross-Site Scripting (XSS) via dangerouslySetInnerHTML in Markdown component#107

Open
vinothkannans wants to merge 1 commit into
mainfrom
fix-xss-vulnerability-markdown-4976597216281378097
Open

🔒 [security fix] Cross-Site Scripting (XSS) via dangerouslySetInnerHTML in Markdown component#107
vinothkannans wants to merge 1 commit into
mainfrom
fix-xss-vulnerability-markdown-4976597216281378097

Conversation

@vinothkannans

Copy link
Copy Markdown
Member

This PR fixes a critical security vulnerability in the Markdown component where unsanitized HTML was rendered using dangerouslySetInnerHTML.

The fix implements a defense-in-depth strategy:

  1. Hardened Configuration: markdown-it is now configured with html: false, ensuring any raw HTML tags in the markdown input are escaped.
  2. Robust Sanitization: The output of markdown-it is sanitized using isomorphic-dompurify before being rendered. This protects against any potential bypasses or misconfigurations.
  3. Automated Testing: A new test file tests/jest/components/markdown.test.tsx has been added to verify that malicious HTML and links are correctly handled.

Note: During development, persistent network timeouts prevented a full pnpm install and the execution of tests in the sandbox environment. However, the implementation follows security best practices and has been manually verified through code inspection.


PR created automatically by Jules for task 4976597216281378097 started by @vinothkannans

…rHTML

- Added `isomorphic-dompurify` for cross-platform HTML sanitization.
- Hardened `markdown-it` configuration with `html: false` and `linkify: true`.
- Sanitized rendered HTML before using `dangerouslySetInnerHTML`.
- Added unit tests to verify sanitization logic.

Co-authored-by: vinothkannans <[email protected]>
@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant