Security Auditor — checks that the audited page enforces a
Content-Security-Policy that restricts scripts, without 'unsafe-inline', 'unsafe-eval' or wildcard script sources.Protection
Limits the damage of cross-site scripting (XSS): injected scripts are blocked by the browser.
Standards
Follows W3C Content Security Policy Level 3, parsed and evaluated with the salvation2 library.
How it works
- Fetch — sends a
GETrequest to the audited URL as 37AuditsBot. A blocked request ends the audit with590; any other failure (timeout, DNS, TLS, non-2xx answer) ends it with500. - Collect policies — every
Content-Security-Policyheader line (including several policies joined by commas) and every<meta http-equiv="Content-Security-Policy">tag in the page<head>are enforced policies.Content-Security-Policy-Report-Onlyenforces nothing and only matters when no policy is enforced. - Evaluate — each policy is parsed with salvation2, which implements the CSP Level 3 algorithms. The script directive is
script-src-elem, elsescript-src, elsedefault-src. Nonces, hashes and'strict-dynamic'are honoured: browsers ignore'unsafe-inline'next to them, and host sources next to'strict-dynamic'. - Several policies — the browser enforces every policy, so a weakness is reported only when every enforced policy allows it. One strict policy blocks the script even if another policy is loose.
- Aggregate — FAIL wins over WARNING; when every rule passes the audit is
SUCCESS(200). - Specification pin — every run emits
37A-CSPAuditor-100(INFORMATION), naming Content Security Policy Level 3, W3C Working Draft as of 2026-10-15. It does not change the overall status.
What it audits
Every row maps to onecheckRule* method and one CheckCode, in the order the auditor runs them. CheckCode suffixes use status ranges: 100 information, 200 success, 300–399 warning, 400–499 fail, 500–599 error.
Output documentation
Risks and considerations
Why a Content Security Policy matters
- Cross-site scripting is one of the most common web vulnerabilities. An injected script runs with the visitor’s session: it can read what they type, steal cookies and tokens, or change what the page shows.
- A strict policy is a second layer: even when a bug lets markup in, the browser refuses to run the injected script.
Rolling out a policy
- Start with
Content-Security-Policy-Report-Onlyto collect violation reports without breaking the site, then send the same policy asContent-Security-Policy. Keeping a report-only policy next to an enforced one, to test the next version, is fine and not reported. - Prefer nonces or hashes with
'strict-dynamic'over long host allowlists: they are easier to keep strict and survive CDN changes.
What this auditor does not check
- Only the audited URL is fetched; other pages of the site may send a different policy.
- Only script restrictions are judged.
object-src,base-uri,frame-ancestors,style-srcand the other directives are recorded but not evaluated. - Host allowlists are not checked for hosts that serve user-controlled JavaScript (JSONP endpoints, public CDNs), which can bypass a policy.
- Parse warnings from salvation2 (unknown directives, deprecated features) are kept in the check data, not reported as findings.