Skip to content

About

Scan HTTP security headers and find out what a Content Security Policy actually permits, not merely whether one exists

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

HeaderScope

Scan any URL to see which HTTP security headers it sends, and what its Content Security Policy actually allows. Includes a CSP builder that composes a policy from what your site really loads.

Free tool, no account. The paid side is daily monitoring.

Why this exists

Every other checker answers "is the header present". That is close to useless, because the common failure is a policy that exists and permits almost everything. A CSP containing 'unsafe-inline' in script-src passes a presence check while providing almost no protection against the attack it is there to stop.

This one reads the policy and works out what it permits.

Running it

npm install
npm run dev
npm test          # 69 tests, no network needed
npm run build
npm run deploy

How it is put together

Astro on Cloudflare Workers. Content pages are static, one API route runs on demand, no database.

src/lib/
  csp.ts       CSP parsing and the bypass analysis. The reason this product exists.
  headers.ts   Spec table for 8 headers. Drives the audit and the guide pages.
  audit.ts     Grades a response. Pure: headers in, issues out.
  safeurl.ts   SSRF guard, runs before any fetch.
  scan.ts      The only file that touches the network.

src/pages/
  index.astro          The scanner
  csp-builder.astro    Interactive policy builder
  header/[header].astro  8 guide pages
  api/scan.ts

Things the analysis gets right that most tools do not

Nonces make unsafe-inline irrelevant. When a nonce or hash is present, browsers ignore unsafe-inline entirely. Flagging it would be a false positive, so it is reported as a deliberate fallback for old browsers instead.

Some directives never inherit from default-src. base-uri, frame-ancestors and form-action have no fallback. A policy with a tight default-src still has gaps unless these are set explicitly, and that is one of the most common real mistakes.

frame-ancestors supersedes X-Frame-Options. When the CSP sets it, asking for the older header would be noise, so it is marked as covered.

A scheme on its own is nearly a wildcard. script-src https: matches every host on the web using HTTPS. Tools that check for * miss this.

Version numbers, not server names. Server: cloudflare tells an attacker nothing. X-Powered-By: PHP/8.1.2 does. Only the versioned case is reported.

Fetch behaviour

Uses GET rather than HEAD, because a meaningful number of servers answer HEAD from a different code path and omit headers they send on a real request. A 4xx response is still graded, since it carries headers; a 5xx is not, since it usually comes from a different server.

House style

copy.test.ts fails the build on em dashes, curly quotes and stock marketing verbs.

Deploying

Run ./deploy-wizard.sh. Set PUBLIC_SITE_URL before the first deploy.

Cost

No fixed cost. Cloudflare's free tier allows commercial use. A domain is the only thing to buy.

About

Scan HTTP security headers and find out what a Content Security Policy actually permits, not merely whether one exists

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages