🛡️ Sentinel: [HIGH] Fix Stored XSS vulnerability in deck links#94
🛡️ Sentinel: [HIGH] Fix Stored XSS vulnerability in deck links#94google-labs-jules[bot] wants to merge 1 commit intomainfrom
Conversation
Added a validation check in the `api/app/api/decks/route.ts` file to ensure that all deck links use either the `http://` or `https://` schemes before being stored. This prevents Stored Cross-Site Scripting (XSS) where an attacker could provide a malicious `javascript:` URL during manual deck text import, which would then be rendered as a clickable link in the frontend `DeckShowcase` component.
|
👋 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. |
There was a problem hiding this comment.
Code Review - Approved
No issues found. Checked for bugs, security issues, and CLAUDE.md compliance.
The added URL scheme validation (/^https?:\/\//i) correctly guards the text-based deck import path against non-HTTP(S) values being stored as the link field (e.g., javascript:, file://, data:). The check is a no-op for the URL-based path since Moxfield/Archidekt/ManaBox URLs are already pattern-validated before link is assigned. Regex and control flow are correct.
🚨 Severity: HIGH
💡 Vulnerability: Stored Cross-Site Scripting (XSS)
When creating a deck using the manual
deckTextanddeckLinkflow, thedeckLinkwas not validated to ensure it contained a safe URI scheme. The provided string was directly stored in the database.In the frontend, this stored link was rendered directly into an
<a>tag'shrefattribute infrontend/src/pages/Home.tsxandfrontend/src/components/DeckShowcase.tsx. An attacker could provide a maliciousdeckLinksuch asjavascript:alert(document.cookie)which would execute JavaScript in the victim's browser when they clicked "View source" or the deck link icon.🎯 Impact
If exploited, this vulnerability could allow an attacker to execute arbitrary JavaScript in the context of another user's session, potentially leading to session hijacking, unauthorized actions on behalf of the user, or data exfiltration.
🔧 Fix
Added a validation check in
api/app/api/decks/route.tsusing a regex testlink.match(/^https?:\/\//i)right before deck creation. If a user provides adeckLinkthat does not start withhttp://orhttps://, the API will now reject the request with a400 Bad Requestresponse, preventing the malicious payload from being stored.✅ Verification
npm test:unitin theapiworkspace to ensure no regressions were introduced.PR created automatically by Jules for task 10403101528358354258 started by @TytaniumDev