Skip to content

🔒 Add Content Security Policy (CSP) header#88

Merged
mbayue merged 4 commits into
masterfrom
jules-175275987009194359-fd6a3dc5
Jul 5, 2026
Merged

🔒 Add Content Security Policy (CSP) header#88
mbayue merged 4 commits into
masterfrom
jules-175275987009194359-fd6a3dc5

Conversation

@mbayue

@mbayue mbayue commented Jul 4, 2026

Copy link
Copy Markdown
Owner

🎯 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-Policy header in server/utils/http.ts that 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.

Review in cubic

Co-authored-by: mbayue <70324722+mbayue@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.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 3 files

Confidence score: 2/5

  • In server/utils/http.ts, the CSP allows 'unsafe-inline' and 'unsafe-eval' in script-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 omits base-uri 'self', so an injected <base> tag could rewrite relative resource URLs and bypass other policy intent, leading to script/style/fetch hijacking — add base-uri 'self' to the policy before merging.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/utils/http.ts Outdated
Comment thread server/utils/http.ts Outdated
google-labs-jules Bot and others added 3 commits July 4, 2026 17:02
🎯 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>
@mbayue mbayue merged commit 5f643d0 into master Jul 5, 2026
9 checks passed
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