Skip to main content
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.
A Content Security Policy tells the browser which scripts, styles and other resources a page may load. When an attacker manages to inject a script into the page (cross-site scripting), a strict policy stops the browser from running it. This auditor reads the policies the audited URL sends and reports the weaknesses that let injected scripts through.

How it works

  1. Fetch — sends a GET request to the audited URL as 37AuditsBot. A blocked request ends the audit with 590; any other failure (timeout, DNS, TLS, non-2xx answer) ends it with 500.
  2. Collect policies — every Content-Security-Policy header 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-Only enforces nothing and only matters when no policy is enforced.
  3. Evaluate — each policy is parsed with salvation2, which implements the CSP Level 3 algorithms. The script directive is script-src-elem, else script-src, else default-src. Nonces, hashes and 'strict-dynamic' are honoured: browsers ignore 'unsafe-inline' next to them, and host sources next to 'strict-dynamic'.
  4. 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.
  5. Aggregate — FAIL wins over WARNING; when every rule passes the audit is SUCCESS (200).
  6. 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 one checkRule* 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-Only to collect violation reports without breaking the site, then send the same policy as Content-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-src and 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.