Build and check a Content Security Policy, with the directives that never fall back to default-src called out and unsafe-inline explained, not just flagged.
Content-Security-Policy
11 directives.
Space or comma separated. Remember the WebSocket scheme for connect-src — a wss:// endpoint needs listing separately, and so does any analytics or error-reporting endpoint, which otherwise stops reporting silently.
default-src 'self'; script-src 'self' 'nonce-{NONCE}'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requestsdefault-src 'self'The fallback for most other fetch directives. Does not fall back to default-src.
script-src 'self' 'nonce-{NONCE}'Where scripts may be loaded from, and whether inline script runs.
style-src 'self' 'unsafe-inline'Where stylesheets may come from.
img-src 'self' data:Where images may be loaded from.
font-src 'self'Where fonts may be loaded from.
connect-src 'self'Where fetch, XHR, WebSocket and EventSource may connect.
object-src 'none'Where plugins may be loaded from.
base-uri 'self'What the page may set as its base URL. Does not fall back to default-src.
form-action 'self'Where a form on this page may submit to. Does not fall back to default-src.
frame-ancestors 'none'Who may put this page in an iframe. Does not fall back to default-src.
upgrade-insecure-requestsRewrites http:// subresource requests to https://.
style-src allows 'unsafe-inline'. This is a much smaller hole than inline script, and most frameworks make it hard to avoid — but a style can still read data through attribute selectors, so it is a trade rather than a free pass.
An enforcing policy breaks whatever it does not allow, immediately and for everyone. Deploy it as Content-Security-Policy-Report-Only first, read the reports for a week, then enforce.
{NONCE} is a placeholder. The nonce has to be generated fresh on every response and put into the matching script tags — a nonce reused across responses, or baked into a cached page, allows exactly what it was meant to block.
A policy is only correct relative to a real page, and this one has never seen yours — it cannot know which origins your page loads from. Deploy it as Content-Security-Policy-Report-Only first, read the reports for a week, then enforce. An enforcing policy blocks whatever it does not allow, immediately and for every visitor, and a missed origin is a blank page rather than a warning.
Content Security Policy Builder runs entirely on your device — nothing is fetched or uploaded.
You’re on the Free plan. Compare plans
CSP's most consequential detail is which directives do not inherit from `default-src`. `frame-ancestors`, `form-action` and `base-uri` have no fallback, so a policy with a strict `default-src` and none of those three is open on all of them — your page can be framed anywhere, forms can post anywhere, and an injected `<base>` tag can redirect every relative URL on the page. The builder reports each missing one specifically.
The checker reads a repeated directive the way browsers do: the first occurrence wins and later ones are ignored. That matters because the natural assumption is the opposite, and a policy with a strict `script-src` added after a loose one is doing nothing at all.
`unsafe-inline` in `script-src` is explained rather than just flagged, because what it does is remove the main thing CSP was built to prevent. With it, an injected `<script>` tag executes. Nonces and hashes are the way to allow the inline scripts you do have without allowing the ones an attacker adds — and a nonce must be unique per response, which is noted because a hardcoded one is a policy that looks strict and is not.
Report-only mode is recommended first, with the reason: a policy strict enough to be useful will break something you did not know your page depended on, and report-only tells you what without taking the site down.
Nothing is sent anywhere. The policy is parsed and built in your browser, and no site is fetched to test it against.
`frame-ancestors`, `form-action` and `base-uri`, among others. A policy with a strict `default-src` and none of those three leaves framing, form submission and relative-URL rewriting unrestricted — which is precisely what clickjacking and base-tag injection use.
The first occurrence is used and the rest are ignored. People assume the last wins, or that they combine. A strict `script-src` added after a loose one has no effect at all.
Because it allows any inline script to execute, including one an attacker injected — which is the attack CSP exists to stop. If you have inline scripts you cannot remove, use a per-response nonce or a hash of each script instead.
Yes. A useful policy will block something you did not know your page used — a third-party widget, an inline handler, a font. Report-only sends you the violations without breaking the page.
No. The policy is parsed as text in your browser. Nothing is requested, so this checks the policy's shape rather than whether your pages comply with it.