Repository navigation
fix(web): enforce the content security policy - #124
Merged
Merged
Conversation
A week report-only showed one violation: Astro's ClientRouter appends an empty data: module script on client-side navigation, so script-src allows data:. Every other page, tab and client fetch on the live site was clean.
Catches a new third-party origin before it ships. astro dev serves scripts as files, so the ClientRouter data: case is covered by the unit test.
Deploying f1-prediction-platform-web with
|
| Latest commit: |
6647b6e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://56099fd8.f1-prediction-platform-web.pages.dev |
| Branch Preview URL: | https://fix-csp-enforce.f1-prediction-platform-web.pages.dev |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
f1-prediction-platform-api | 6647b6e | Nov 17 2026, 02:53 PM |
10 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the last slice of #94: the report-only CSP becomes the enforced one.
The one addition is
data:inscript-src: Astro's ClientRouter appends<script type="module" src="data:application/javascript,">on client-side navigation (astro/dist/transitions/router.js:88) whenever the page has an inline module script.'unsafe-inline'was already allowed, so this adds no real exposure.A new smoke test fails the e2e run on any CSP console error, so a new font/analytics/API origin can't ship unnoticed.
astro devserves scripts as files, so it can't reproduce thedata:case; the unit test pins that.Evidence
Headless Chromium against the live site, with its CSP header rewritten to the enforced policy: 17 list pages and tabs, race / race-story / telemetry / sprint / driver / team / circuit / prediction detail pages, the search palette and sidebar client navigation.
client-nav Loading the script 'data:application/javascript,' violates … "script-src 'self' 'unsafe-inline' https://static.cloudflareinsights.com"After (this PR's policy):
CLEAN, and the client fetches still go through:200 /api/search,200 /api/drivers/222?year=2026,200 /api/drivers/221?year=2026.securityHeaders.test.ts6/6 (enforced, no report-only header,script-srchasdata:,connect-srchas the API).security.spec.ts3/3 against the fixture server.Merge Danger
Door: two-way
Revert the commit to go back to report-only.
Blast Radius: site-wide
A source the policy misses gets blocked in the browser on every page. The live sweep found none, but anything loaded only on a page or interaction the sweep didn't reach would break until it's added to
securityHeaders.ts. Prerendered/docsand static assets don't get these headers.