CSP Hash-Pinned script-src for Static Sites
This kit is the hasher, the union, the CI check and the deploy order that make the strict policy safe to keep.
$29
Works with the AI Agents you already use
CSP Hash-Pinned script-src for Static Sites
Example session with this skill installed
Our Next.js static site behind nginx has script-src locked to hashes with no unsafe-inline. After the last deploy the site loaded but nothing worked until we rolled back. Make deploys safe without loosening the policy.
- Read your context and instructions
- Compiled the csp hash-pinned script-src
Summary
The outage was the hash list: the new build's inline bootstrap scripts had new hashes and the header still listed the old ones. Added the hash union to the deploy, a CI check that refuses to ship without it, and a browser check after the pointer moves.
Diagnosis
node scripts/csp-hashes.mjs check out/ --header-file deploy/csp.txt
FAIL: the header lacks 3 of 3 inline-script hashes for out/; this build would not hydrate behind that header
'sha256-Qm9vdHN0cmFw...' <- index.html, docs/index.html, ...
'sha256-U2VsZi5fX25l...' <- index.html
'sha256-cGFnZURhdGE...' <- search/index.html
HTTP 200 on every page; zero hydration. Exactly the failure the policy hides.
Fix in the deploy script
node scripts/csp-hashes.mjs union out/ /srv/releases/current > deploy/script-src.txt(new build plus the rollback release: 5 unique hashes).- Write both
Content-Security-Policyadd_header lines with that list,nginx -t, reload. node scripts/csp-hashes.mjs check out/ --header-file deploy/csp.txt->ok: the header carries all 3 inline-script hashes for out/.- Move
/srv/releases/currentto the new build. - Playwright: type into the search box, expect results. Passed.
CI
The check step runs on every build against the header in the repo; a build whose hashes are not in the header fails the pipeline before anyone can deploy it. A header that still contained 'unsafe-inline' would also fail: with it present the hashes do nothing.
Monitoring
A synthetic browser check that performs one real interaction every hour; the uptime check that watched HTTP 200 for a month stays, but it is no longer the only signal.
Tests
node --test scripts/csp.test.mjs: 2 passed.
Connects securely to your tools. The creator never sees your data.
About this skill
A strict policy (script-src 'self' plus exact SHA-256 hashes, no unsafe-inline) is the right policy for a static site. It also has a failure mode no HTTP check can see: static exports bootstrap hydration through inline scripts whose hashes change with every build, so a release shipped without updating the header returns 200 on every page while React never hydrates and every interactive element is dead. That ran in production for a month before someone used the search box. This kit is the hasher, the union, the CI check and the deploy order that make the strict policy safe to keep.
csp-hashes.mjs: list walks a build and prints the 'sha256-...' tokens, hashing inline script text byte for byte as browsers do, skipping JSON-LD and template data blocks, including import maps, with --styles for a hash-pinned style-src and --json for tooling; union merges the new build and the rollback release so a rollback needs no header change; check compares a build against the header string or file you are about to deploy, exits 1 naming every missing hash and the files that carry it, and exits 1 when the header still contains 'unsafe-inline' (which makes the hashes theatre).
The deploy contract (reference/why-hashes-break-hydration.md): header with the union, config test and reload, then the release pointer, then a real interaction in a browser; a synthetic browser check per deploy and per hour, because status codes cannot see this.
2 offline tests including the CLI. Node 20+, no packages, no network.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.
Requires Node 20+. No support for inline event handlers (onclick). Post-hash HTML minification will break the hashes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago
- Software
Node.js 20+Web server CSP configuration
Web browserorbrowser automation
You need write access to the server's CSP header configuration. The browser runs the final check.
Permissions
Shell to run the node script and tests; read files for the built static tree, the rollback release and the header file. No writes, no network access, no environment variables.