Skip to content

🛡️ Sentinel: [HIGH] Fix XSS Vulnerability in Default CSP#515

Draft
EffortlessSteven wants to merge 1 commit into
mainfrom
jules-13254973477489825114-ef771284
Draft

🛡️ Sentinel: [HIGH] Fix XSS Vulnerability in Default CSP#515
EffortlessSteven wants to merge 1 commit into
mainfrom
jules-13254973477489825114-ef771284

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Jun 18, 2026

Copy link
Copy Markdown
Member

🚨 Severity: HIGH
💡 Vulnerability: The default Content Security Policy (CSP) implementation in SecurityHeadersConfig included 'unsafe-inline' and 'unsafe-eval', which are highly insecure and can lead to Cross-Site Scripting (XSS) vulnerabilities.
🎯 Impact: If exploited, an attacker could execute arbitrary JavaScript in the context of the user's browser, potentially leading to unauthorized actions, data theft, or complete account compromise.
🔧 Fix: Hardened the Default implementation for SecurityHeadersConfig in crates/http-middleware/src/security_headers.rs and crates/app-http/src/middleware/security_headers.rs to provide strict, production-ready CSP settings by removing 'unsafe-inline' and 'unsafe-eval'. The development configuration still uses the more permissive settings for local environment needs.
✅ Verification: Ran cargo test -p http-middleware and cargo test -p app-http to ensure the configurations and tests pass with the stricter settings.


PR created automatically by Jules for task 13254973477489825114 started by @EffortlessSteven


Note

Medium Risk
Default CSP is stricter for any code path that uses SecurityHeadersConfig::default() instead of from_sources()/development(), which may block inline scripts or eval until config is adjusted.

Overview
Tightens the default Content-Security-Policy on SecurityHeadersConfig::default() in both app-http and http-middleware by dropping 'unsafe-inline' and 'unsafe-eval' from script-src and style-src, aligning the default with the existing strict production CSP string.

Comments on the default impl now direct callers to from_sources() (app-http) or development() (http-middleware) for permissive dev CSP. Env-based production vs development behavior in from_sources() is unchanged.

Reviewed by Cursor Bugbot for commit 54ee0d0. Bugbot is set up for automated code reviews on this repo. Configure here.

@google-labs-jules

Copy link
Copy Markdown

👋 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.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@EffortlessSteven, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 187bd693-66cb-4d9b-a4ca-4dcac1faafe8

📥 Commits

Reviewing files that changed from the base of the PR and between 3debe49 and 54ee0d0.

📒 Files selected for processing (2)
  • crates/app-http/src/middleware/security_headers.rs
  • crates/http-middleware/src/security_headers.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jules-13254973477489825114-ef771284

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Copy link
Copy Markdown

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 hardens the default Content Security Policy (CSP) in both crates/app-http and crates/http-middleware by removing 'unsafe-inline' and 'unsafe-eval' directives. The reviewer recommends further strengthening the CSP by adding object-src 'none' and base-uri 'none' directives to prevent common bypasses.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 48 to 50
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

While removing 'unsafe-inline' and 'unsafe-eval' significantly hardens the Content Security Policy (CSP), the policy is still missing some critical directives to prevent common CSP bypasses:

  1. object-src 'none': Prevents the injection of plugins (like Flash or Java) which can be used to execute arbitrary scripts.
  2. base-uri 'none' (or 'self'): Prevents attackers from injecting a tag to hijack relative URLs (e.g., redirecting scripts or styles to an attacker-controlled domain).

Consider adding these directives to make the default CSP truly robust and production-ready.

Suggested change
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),
content_security_policy: Some(
"default-src 'self'; object-src 'none'; base-uri 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),

Comment on lines 48 to 50
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

While removing 'unsafe-inline' and 'unsafe-eval' significantly hardens the Content Security Policy (CSP), the policy is still missing some critical directives to prevent common CSP bypasses:

  1. object-src 'none': Prevents the injection of plugins (like Flash or Java) which can be used to execute arbitrary scripts.
  2. base-uri 'none' (or 'self'): Prevents attackers from injecting a tag to hijack relative URLs (e.g., redirecting scripts or styles to an attacker-controlled domain).

Consider adding these directives to make the default CSP truly robust and production-ready.

Suggested change
content_security_policy: Some(
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
"default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),
content_security_policy: Some(
"default-src 'self'; object-src 'none'; base-uri 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'none';".to_string(),
),

@github-actions

Copy link
Copy Markdown

Test Results

283 tests   245 ✅  10m 56s ⏱️
 25 suites   38 💤
  1 files      0 ❌

Results for commit 54ee0d0.

@cursor

cursor Bot commented Jun 18, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_18c82612-04e3-42e9-8d2b-b5560f018c9c)

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