Guides · ← All guides
Content-Security-Policy Missing: What CSP Does and How to Add It Safely
Published: November 14, 2026 · Last reviewed: November 14, 2026 · 8 min read
Run a free BreachHunter assessment on your site →
Of the six headers in the scanner's SECURITY_HEADERS table, CSP is the one owners postpone — the others are one line each, while CSP describes your whole site. That postponement is understandable and expensive: cross-site scripting stays on every year's most-exploited list precisely because so many pages will execute whatever script lands on them.
This guide explains what CSP actually enforces, what a scanner sees when it is absent, and the staged rollout — report-only first, enforce second — that lets a small team add it without a broken checkout as the price.
What does a Content-Security-Policy actually control?
CSP is a set of directives. default-src is the fallback; script-src, style-src, img-src, font-src, connect-src and frame-ancestors refine it per resource type. A policy like default-src 'self'; script-src 'self' https://cdn.example-cdn.com tells the browser: run scripts only from our own origin and that one CDN, refuse everything else — including a script tag an attacker injected into a product review.
The scanner's own finding text puts it plainly: “Without a CSP, cross-site scripting and data-injection attacks are far easier to pull off.” The header does not patch the injection hole. It decides whether the hole, once found, is a defaced comment or a session-stealing, payment-skimming incident. That blast-radius difference is what the MEDIUM rating prices.
Why do assessments flag it if it is not a vulnerability?
Because assessments measure exposure, not just open doors. A missing CSP is recorded alongside your cookie flags and TLS settings as part of the web-audit phase described in what a website security assessment tests: the phase that reads your responses the way a browser does and inventories the protections you have declined.
There is also a reporting reality: enterprise buyers and cyber-insurance questionnaires ask about CSP by name. Having the header — and being able to show when it was added — answers a line item that “we take security seriously” does not.
Worked example: fernwickstudio.example
Fernwick Studio, a nine-person design studio, ran its portfolio and client-login site with no CSP at all. The BreachHunter web audit returned the standard finding — Missing Content-Security-Policy, MEDIUM, 3 points — and the report's curl evidence showed a response carrying HSTS and X-Frame-Options but nothing else:
curl -I https://fernwickstudio.example HTTP/2 200 strict-transport-security: max-age=31536000 x-frame-options: DENY (content-security-policy: absent)
Instead of enforcing a guessed policy, the studio spent one week in report-only mode. The violation reports named three origins nobody had written down: a fonts CDN, an analytics endpoint, and an embedded scheduling widget on the contact page. The enforced policy that followed allowed exactly those, plus 'self'. Total engineering time: about three hours, most of it reading reports. On retest the finding was gone and the score recovered its 3 points — with a policy the team could explain line by line, which is the version that survives a client questionnaire.
The five actions to take
Adding CSP without breaking your own site comes down to inventory before enforcement:
- Inventory what your pages load: crawl your five most important templates and list every script, style, font and image origin.
- Send Content-Security-Policy-Report-Only with your draft policy and a reporting endpoint, and run it for at least a few days of real traffic.
- Fix the allow-list from the violation reports — every surprise origin is either legitimate (allow it) or a finding in itself (remove it).
- Enforce the policy, keeping default-src 'self' as the base and frame-ancestors set if you do not also send X-Frame-Options.
- Re-scan and keep the before/after reports: the closed finding is your evidence for clients and insurers.
Run a free BreachHunter assessment on your site →
Frequently asked questions
Is a missing Content-Security-Policy a security breach?
No. It is a missing mitigation. The scanner rates it MEDIUM because an attacker still needs an injection point to exploit it — but if they find one, the absence of CSP is what lets injected code run unchecked. Think of it as a seatbelt finding, not a crash.
What is the safest CSP to start with?
Start in report-only mode with default-src 'self' and add the specific origins your violation reports prove you need. A strict policy you derived from your own traffic beats a permissive one copied from a tutorial, and report-only means a wrong guess breaks nothing.
Does CSP replace fixing XSS vulnerabilities?
No. CSP is a second line of defense. Parameterized output encoding and input handling fix the hole; CSP limits what an attacker can do through any hole that remains. Assessments report both layers separately for exactly this reason.
Will CSP break my analytics or embedded widgets?
It will block them until they are allow-listed — which is why the report-only week matters. Every legitimate third-party origin shows up in violation reports with its exact hostname, so the fix is mechanical rather than guesswork.
How does the scanner check for CSP?
The web-audit phase reads your response headers and compares them against the six-header set in its check table. If content-security-policy is absent, it files the finding with the standard fix text: add a policy that whitelists the sources your site actually uses.
Rolling CSP out without breaking the site: report-only first
The safe rollout starts with a second header: Content-Security-Policy-Report-Only. The browser enforces nothing in report-only mode. It just tells you, per page, what the policy would have blocked — the analytics beacon, the chat widget, the one legacy script nobody remembers adding. Run it for a week of real traffic before you enforce anything.
Then enforce in stages. Start with the directives that cannot break layout — object-src 'none', base-uri 'self', frame-ancestors — and only then tighten script-src, which is where breakage lives. Teams that skip report-only learn about their third-party scripts from angry customers. Teams that use it learn from a log file. Same lesson, much cheaper teacher.
Sources
The authorities this guide is built on, in the form we check our own work against:
- MDN — Content Security Policy (2025) — directive-by-directive reference for building a policy.
- W3C Content Security Policy Level 3 (2023) — the specification browsers implement.
- OWASP Content Security Policy Cheat Sheet (2024) — deployment patterns that avoid the usual breakage.