Skip to content

Fix: CSP violations - inline script + SW network error - #20

Merged
suradet-ps merged 1 commit into
mainfrom
feat/phase-7-security-hardening
Aug 5, 2026
Merged

Fix: CSP violations - inline script + SW network error#20
suradet-ps merged 1 commit into
mainfrom
feat/phase-7-security-hardening

Conversation

@suradet-ps

Copy link
Copy Markdown
Owner

Summary

Fixes CSP violations reported after Phase 7 deployment.

Changes

1. vercel.jsonscript-src 'unsafe-inline' added
Trunk 0.21 generates an inline <script type="module"> to bootstrap WASM. The script content includes content-hashed filenames that change every build, making a static SHA-256 hash non-viable. unsafe-inline is now accepted with a documented rationale.

2. static/pwa/sw.js — network error handling
The stale-while-revalidate handler now catches network failures and returns a 503 Service Unavailable response instead of letting the promise reject with an unhandled TypeError: Failed to fetch.

3. .github/workflows/ci.yml — CI updated
The csp-verify job now allows unsafe-inline in script-src with an explanatory comment (was: hard-fail).

4. SECURITY.md — known limitation documented
CSP section updated to reflect the unsafe-inline tradeoff and why a static hash doesn't work with Trunk's build output.

Three CSP-related fixes:

1. script-src 'unsafe-inline' added to CSP (vercel.json)
   Trunk 0.21 generates an inline script for WASM bootstrap whose
   content changes per build (content-hashed filenames). A static
   SHA-256 hash is non-viable. Documented in SECURITY.md.

2. Service worker network error handling (sw.js)
   The stale-while-revalidate handler now catches network failures
   and returns a 503 response instead of an unhandled TypeError.

3. CI csp-verify job updated to allow 'unsafe-inline' in script-src
   with an explanatory comment.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codeshot Ready Ready Preview Aug 5, 2026 2:13am

@suradet-ps
suradet-ps merged commit 73d3488 into main Aug 5, 2026
12 of 13 checks passed
@suradet-ps
suradet-ps deleted the feat/phase-7-security-hardening branch August 5, 2026 02:21
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