🔒 Add Content Security Policy (CSP) header#88
Conversation
Co-authored-by: mbayue <70324722+mbayue@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. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
2 issues found across 3 files
Confidence score: 2/5
- In
server/utils/http.ts, the CSP allows'unsafe-inline'and'unsafe-eval'inscript-src, which significantly weakens XSS protection and could let injected script execute in users’ browsers if any injection point exists — remove these directives (or replace with nonces/hashes) before merging. - In
server/utils/http.ts, the CSP omitsbase-uri 'self', so an injected<base>tag could rewrite relative resource URLs and bypass other policy intent, leading to script/style/fetch hijacking — addbase-uri 'self'to the policy before merging.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
🎯 What: Missing `base-uri` in CSP and overly permissive `script-src`.⚠️ Risk: Without `base-uri`, attackers can inject a `<base>` tag to hijack relative URLs. 🛡️ Solution: Added `base-uri 'self'` to the `Content-Security-Policy`. `unsafe-eval` is still needed by `d3-dsv` which is used for data parsing and diagram rendering. Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
🎯 What: Missing `base-uri` in CSP and overly permissive `script-src`.⚠️ Risk: Without `base-uri`, attackers can inject a `<base>` tag to hijack relative URLs. 🛡️ Solution: Added `base-uri 'self'` to the `Content-Security-Policy`. `unsafe-eval` is still needed by `d3-dsv` which is used for data parsing and diagram rendering. Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
🎯 What: Missing Content-Security-Policy header in server responses.
⚠️ Risk: Without a CSP, the application is more susceptible to Cross-Site Scripting (XSS) attacks, as browsers will execute inline scripts or load resources from untrusted domains.
🛡️ Solution: Added a baseline
Content-Security-Policyheader inserver/utils/http.tsthat restricts sources while allowing necessary functionality (inline scripts/eval for Vite/React, external fonts, etc.). Also added a unit test to verify.PR created automatically by Jules for task 175275987009194359 started by @mbayue
Summary by cubic
Add a strict Content-Security-Policy header to all responses to reduce XSS. Locks down script execution to 'self' and a hash allowlist, adds
base-uri 'self', and permits Google Fonts, data: images, and HTTPS/WSS connections; verified by a unit test.Written for commit 7cd0b64. Summary will update on new commits.