🛡️ Sentinel: [CRITICAL] Fix XSS vulnerability in DescriptionPreview#9
🛡️ Sentinel: [CRITICAL] Fix XSS vulnerability in DescriptionPreview#9
Conversation
…rify - Add `isomorphic-dompurify` to prevent XSS during SSR and client-side rendering. - Update `DescriptionPreview.tsx` to sanitize raw HTML before passing to `dangerouslySetInnerHTML`. - Add sentinel security learning to `.jules/sentinel.md` journal. Co-authored-by: bobdivx <6737167+bobdivx@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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello, 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 delivers a crucial security enhancement by resolving a critical XSS vulnerability within the Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a critical XSS vulnerability in the DescriptionPreview component by introducing isomorphic-dompurify to sanitize HTML before rendering. The fix is well-implemented. My review includes a high-severity suggestion to further enhance security by preventing tabnabbing attacks, and a medium-severity suggestion to clean up project dependencies.
| 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'blockquote', | ||
| 'code', 'pre', 'img', 'span', 'div', 'center' | ||
| ], | ||
| ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'width', 'height', 'style', 'target', 'rel'] |
There was a problem hiding this comment.
Allowing the target attribute can introduce a "tabnabbing" security vulnerability. When a link with target="_blank" is opened, the new page gains partial access to the original page, which can be exploited. While rel is in the allow-list, its presence isn't enforced for links with target="_blank". To mitigate this risk, I recommend removing target from the list of allowed attributes. This will cause all links to open in the same tab, which is safer for a preview component.
| ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'width', 'height', 'style', 'target', 'rel'] | |
| ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'width', 'height', 'style', 'rel'] |
| "@types/dompurify": "^3.2.0", | ||
| "@types/qrcode": "^1.5.6", | ||
| "astro": "^5.17.2", | ||
| "bcryptjs": "^2.4.3", | ||
| "daisyui": "^4.12.10", | ||
| "dompurify": "^3.3.2", | ||
| "hls.js": "^1.6.15", | ||
| "html5-qrcode": "^2.3.8", | ||
| "isomorphic-dompurify": "^3.0.0", |
There was a problem hiding this comment.
There are a couple of opportunities to clean up the dependencies:
- The
@types/dompurifypackage is deprecated and can be removed, asdompurifynow ships its own types. - The
dompurifypackage is a transitive dependency ofisomorphic-dompurify, so it can be removed as a direct dependency to avoid redundancy.
Removing these will clean up the project's dependencies.
| "@types/dompurify": "^3.2.0", | |
| "@types/qrcode": "^1.5.6", | |
| "astro": "^5.17.2", | |
| "bcryptjs": "^2.4.3", | |
| "daisyui": "^4.12.10", | |
| "dompurify": "^3.3.2", | |
| "hls.js": "^1.6.15", | |
| "html5-qrcode": "^2.3.8", | |
| "isomorphic-dompurify": "^3.0.0", | |
| "@types/qrcode": "^1.5.6", | |
| "astro": "^5.17.2", | |
| "bcryptjs": "^2.4.3", | |
| "daisyui": "^4.12.10", | |
| "hls.js": "^1.6.15", | |
| "html5-qrcode": "^2.3.8", | |
| "isomorphic-dompurify": "^3.0.0", |
🛡️ Sentinel: [CRITICAL] Fix XSS vulnerability in DescriptionPreview
🚨 Severity: CRITICAL
💡 Vulnerability: The
DescriptionPreviewcomponent was directly rendering raw HTML or converted BBCode usingdangerouslySetInnerHTMLwithout proper sanitization. This could allow malicious users to inject script tags or other XSS vectors if they have control over the description input.🎯 Impact: Attackers could execute arbitrary JavaScript within a user's browser context, potentially leading to session hijacking, stealing sensitive data, or taking actions on behalf of the user. Because this is an Astro SSR application, the lack of sanitization on the server could also lead to XSS payloads being injected into the initial HTML response.
🔧 Fix: Integrated
isomorphic-dompurifyto thoroughly sanitize the HTML string before injecting it into the DOM. The configuration explicitly allows only a safe subset of tags (like headings, bold, italic, code, img, links, etc.) and attributes. Usingisomorphic-dompurifyinstead of standarddompurifyguarantees protection runs consistently during both Server-Side Rendering (SSR) and Client-Side rendering, preventing hydration mismatches and early execution.✅ Verification: The fix was manually verified, build and test commands were executed successfully (
npm run buildandnpm run test).A journal entry has been added to
.jules/sentinel.mdoutlining the findings and mitigation.PR created automatically by Jules for task 251337543513320501 started by @bobdivx