Skip to content

🛡️ Sentinel: [HIGH] Fix XSS vulnerability in DescriptionPreview#27

Open
bobdivx wants to merge 1 commit intodevfrom
sentinel/xss-mitigation-description-preview-15717903538753576247
Open

🛡️ Sentinel: [HIGH] Fix XSS vulnerability in DescriptionPreview#27
bobdivx wants to merge 1 commit intodevfrom
sentinel/xss-mitigation-description-preview-15717903538753576247

Conversation

@bobdivx
Copy link
Copy Markdown
Owner

@bobdivx bobdivx commented Mar 25, 2026

🚨 Severity: HIGH
💡 Vulnerability: The DescriptionPreview component used dangerouslySetInnerHTML to render user-provided HTML and converted BBCode descriptions without any sanitization, leading to a potential Cross-Site Scripting (XSS) vulnerability.
🎯 Impact: An attacker could craft a malicious description containing executable JavaScript (e.g., via <script> tags or onerror handlers). When another user views this description, the malicious script would execute in their context, potentially leading to session hijacking, unauthorized actions, or data theft.
🔧 Fix: Introduced isomorphic-dompurify and wrapped all HTML output injected via dangerouslySetInnerHTML in DOMPurify.sanitize(). isomorphic-dompurify was chosen over standard dompurify to prevent window is not defined errors during Astro/Preact Server-Side Rendering (SSR). Also added a unit test to verify that onerror handlers and other XSS vectors are successfully stripped.
✅ Verification: npm run test src/components/upload/DescriptionPreview.test.ts passes. npm run build succeeds without SSR errors.


PR created automatically by Jules for task 15717903538753576247 started by @bobdivx

🚨 Severity: HIGH
💡 Vulnerability: The `DescriptionPreview` component used `dangerouslySetInnerHTML` to render user-provided HTML and converted BBCode descriptions without any sanitization, leading to a potential Cross-Site Scripting (XSS) vulnerability.
🎯 Impact: An attacker could craft a malicious description containing executable JavaScript (e.g., via `<script>` tags or `onerror` handlers). When another user views this description, the malicious script would execute in their context, potentially leading to session hijacking, unauthorized actions, or data theft.
🔧 Fix: Introduced `isomorphic-dompurify` and wrapped all HTML output injected via `dangerouslySetInnerHTML` in `DOMPurify.sanitize()`. `isomorphic-dompurify` was chosen over standard `dompurify` to prevent `window is not defined` errors during Astro/Preact Server-Side Rendering (SSR). Also added a unit test to verify that `onerror` handlers and other XSS vectors are successfully stripped.
✅ Verification: `npm run test src/components/upload/DescriptionPreview.test.ts` passes. `npm run build` succeeds without SSR errors.

Co-authored-by: bobdivx <6737167+bobdivx@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.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

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

Project Deployment Actions Updated (UTC)
popcorn-client Ready Ready Preview, Comment Mar 25, 2026 7:47am

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the application's security by resolving a high-severity XSS vulnerability within the DescriptionPreview component. The fix involves implementing robust HTML sanitization using isomorphic-dompurify to prevent the execution of malicious scripts from user-generated content, thereby protecting users from potential session hijacking or data theft.

Highlights

  • XSS Vulnerability Addressed: A high-severity Cross-Site Scripting (XSS) vulnerability in the DescriptionPreview component was fixed, which previously allowed unsanitized user-provided HTML and BBCode to be rendered.
  • Sanitization with isomorphic-dompurify: The isomorphic-dompurify library was integrated to sanitize all HTML output before it is rendered using dangerouslySetInnerHTML, ensuring compatibility with Server-Side Rendering (SSR) environments like Astro/Preact.
  • Enhanced Test Coverage: A new unit test was added specifically to DescriptionPreview.test.ts to validate that common XSS vectors, such as onerror handlers, are effectively stripped by the sanitization process.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on implementing XSS mitigation in the DescriptionPreview component by integrating isomorphic-dompurify. It includes adding isomorphic-dompurify, @playwright/test, and preact-render-to-string as dependencies, updating various other dependencies, and introducing new tests to verify the XSS prevention. The core change involves sanitizing HTML content using DOMPurify.sanitize() before rendering it with dangerouslySetInnerHTML in DescriptionPreview.tsx.

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