MORTIMERDEV LABS / CSP FREE · BETA
Understand your CSP.
See what it really allows.
Paste a Content-Security-Policy to see what each rule means, which fallbacks apply and what’s worth fixing. Then test real URLs and inline code against it.
YOUR POLICY
Here’s what your policy does.
Worth a look
What each resource type uses
Browsers pick the most specific directive that’s set and ignore the rest; there’s no merging. Grey rows aren’t restricted by this policy.
Rule by rule
Test it
Check whether a specific URL or piece of inline code would be allowed. Results follow the CSP specification; where Chrome behaves differently, we tell you.
CSP REFERENCE
Every directive and source, in plain English.
What each rule controls, what it falls back to and the mistakes we see most, with links to MDN and the specification. Browser versions are from MDN’s compatibility data.
Nothing matches that filter.
Fetch directives
Where each type of resource may load from. Most fall back to default-src when they’re missing.
default-srcThe fallback for other fetch directives that you haven’t set yourself.
When a more specific fetch directive is missing, the browser uses default-src instead. It covers scripts, styles, images, fonts, connections, media, frames, workers, manifests and plugins. There’s no merging: if you set script-src, default-src no longer applies to scripts at all. It does not cover base-uri, form-action, frame-ancestors, sandbox or the reporting directives.
This is the final fallback for fetch directives.
Common mistakes
- Expecting default-src to protect against clickjacking or form hijacking. frame-ancestors, form-action and base-uri never fall back to it.
- Assuming a specific directive adds to default-src. It replaces it for that resource type.
script-srcWhere JavaScript may come from, and whether inline script and eval() are allowed.
Controls <script> elements, inline <script> blocks, inline event handlers such as onclick, javascript: URLs, eval() and similar functions, and WebAssembly compilation. It’s also the fallback for script-src-elem, script-src-attr and (after child-src) worker-src.
If it’s missing, browsers use default-src.
Common mistakes
- Adding 'unsafe-inline' to make inline scripts work. It allows injected scripts too. Use nonces or hashes instead.
- Allowing a whole CDN or https: as a script source. Anyone who can host a file there can run code on your page.
script-src-elemWhere <script> elements and inline <script> blocks may come from.
Overrides script-src for <script> elements (external and inline) and javascript: URLs. It doesn’t affect inline event handlers (script-src-attr), eval() or WebAssembly, which still use script-src, and it isn’t a fallback for worker-src.
If it’s missing, browsers use script-src, then default-src.
Common mistakes
- Putting 'unsafe-eval' here. eval() is only controlled by script-src (or default-src), so it has no effect in script-src-elem.
Browser support: Chrome 75, Firefox 108, Safari 15.4. Older browsers ignore it and use script-src.
script-src-attrWhether inline event handlers such as onclick may run.
Overrides script-src for event handler attributes. Nonces never apply to attributes. A handler can only run with 'unsafe-inline', or with 'unsafe-hashes' plus a hash of the attribute’s exact value.
If it’s missing, browsers use script-src, then default-src.
Common mistakes
- Adding a nonce and expecting onclick handlers to work. Nonces only apply to <script> and <style> elements.
Browser support: Chrome 75, Firefox 108, Safari 15.4. Older browsers ignore it and use script-src.
style-srcWhere stylesheets may come from, and whether inline CSS is allowed.
Controls <link rel="stylesheet">, @import, stylesheets from the Link header, inline <style> blocks and style attributes. It’s the fallback for style-src-elem and style-src-attr.
If it’s missing, browsers use default-src.
Common mistakes
- Forgetting that style="…" attributes are inline styles. They’re blocked unless the policy allows them.
style-src-elemWhere stylesheets and inline <style> blocks may come from.
Overrides style-src for <link rel="stylesheet">, @import, Link-header stylesheets and inline <style> blocks. Style attributes use style-src-attr instead.
If it’s missing, browsers use style-src, then default-src.
Browser support: Chrome 75, Firefox 108, Safari 26.2. Safari 15.4 to 26.1 parsed it but it had no effect.
style-src-attrWhether style="…" attributes are applied.
Overrides style-src for inline style attributes. Nonces don’t apply to attributes. Allow them with 'unsafe-inline', or with 'unsafe-hashes' plus a hash of the attribute’s exact value. Setting element.style from JavaScript isn’t an inline style attribute and isn’t blocked.
If it’s missing, browsers use style-src, then default-src.
Browser support: Chrome 75, Firefox 108, Safari 15.4. Older browsers ignore it and use style-src.
img-srcWhere images and favicons may load from.
Covers <img>, CSS background images, favicons and other image requests. Images embedded as data: URLs need data: in the list.
If it’s missing, browsers use default-src.
Common mistakes
- Forgetting data: for inline SVG or base64 images, or blob: for images created in the browser.
font-srcWhere web fonts loaded with @font-face may come from.
Applies to font files requested by @font-face rules, such as fonts from a font CDN.
If it’s missing, browsers use default-src.
Common mistakes
- Allowing the stylesheet host (for example fonts.googleapis.com) but not the separate host that serves the font files.
connect-srcWhich URLs scripts may connect to with fetch(), XMLHttpRequest, WebSocket and similar APIs.
Covers fetch(), XMLHttpRequest, WebSocket, EventSource, navigator.sendBeacon() and <a ping>. Restricting it limits where a script can send data.
If it’s missing, browsers use default-src.
Common mistakes
- Forgetting analytics, error-reporting or API hosts. They usually need to be listed here.
- Relying on 'self' for WebSocket connections. MDN notes that not every browser matches 'self' to ws: or wss: URLs, so list the WebSocket URL explicitly.
media-srcWhere <audio>, <video> and <track> content may load from.
Applies to audio, video and text-track files.
If it’s missing, browsers use default-src.
frame-srcWhich URLs this page may load in <iframe> and <frame> elements.
Controls what you embed. To control who may embed your page, use frame-ancestors.
If it’s missing, browsers use child-src, then default-src.
Common mistakes
- Using frame-src to stop other sites framing your page. That’s frame-ancestors.
child-srcA shared fallback for frames and workers.
Used for iframes when frame-src is missing, and for workers when worker-src is missing. Prefer frame-src and worker-src so each is explicit.
If it’s missing, browsers use default-src.
worker-srcWhere Worker, SharedWorker and service worker scripts may come from.
If it’s missing, the browser tries child-src, then script-src, then default-src. script-src-elem is never used for workers.
If it’s missing, browsers use child-src, then script-src, then default-src.
Common mistakes
- Expecting workers to inherit this page’s policy. A worker loaded from a normal URL uses the CSP sent with the worker script itself.
Browser support: Chrome 59, Firefox 58, Safari 15.5. Older browsers use child-src or script-src instead.
manifest-srcWhere the web app manifest may load from.
Applies to the file linked with <link rel="manifest">.
If it’s missing, browsers use default-src.
object-srcWhere <object> and <embed> content may load from.
Plugin-style content can be used to run script, so the specification recommends restricting it. Most sites can set object-src 'none'. This also applies to content loaded by an <object> element, even HTML.
If it’s missing, browsers use default-src.
Common mistakes
- Leaving it unset with no default-src. The CSP specification recommends controlling both scripts and plugins.
fenced-frame-srcWhere content in <fencedframe> elements may load from.Experimental
An experimental directive for fenced frames. If it’s missing, the browser uses frame-src, then child-src, then default-src.
If it’s missing, browsers use frame-src, then child-src, then default-src.
Browser support: Partially supported in Chrome 156. Not supported in Firefox or Safari.
prefetch-srcA deprecated, non-standard directive for prefetched resources.Deprecated
It isn’t in the current CSP specification. Chrome and Firefox don’t support it; Safari has supported it since 16.3.
If it’s missing, browsers use default-src.
Common mistakes
- Relying on it. Most browsers ignore it.
Document directives
Properties of the page itself. These don’t fall back to default-src.
base-uriWhich URLs a <base> element may set as the page’s base URL.
An injected <base href> can change where every relative URL points, including script URLs. base-uri doesn’t fall back to default-src. 'self' or 'none' suits most sites.
Doesn’t fall back to default-src. If it’s missing, this isn’t restricted.
Common mistakes
- Assuming default-src covers it. Without base-uri, any <base> URL is allowed.
sandboxApplies iframe-style sandbox restrictions to the page itself.
With no value, every restriction applies: no scripts, no forms, no popups and a unique opaque origin. Each allow-… keyword lifts one restriction. Browsers ignore sandbox in a <meta> tag and in Content-Security-Policy-Report-Only.
Doesn’t fall back to default-src. If it’s missing, this isn’t restricted.
Common mistakes
- Adding it to a <meta> tag or a Report-Only header, where browsers ignore it.
Navigation directives
Where forms can submit and who can frame the page. These don’t fall back to default-src.
form-actionWhich URLs forms on this page may submit to.
form-action doesn’t fall back to default-src. Without it, forms can submit anywhere.
Doesn’t fall back to default-src. If it’s missing, this isn’t restricted.
Common mistakes
- Assuming default-src 'self' stops forms posting to other sites. It doesn’t.
frame-ancestorsWhich sites may embed this page in a frame.
Protects against clickjacking. 'none' is similar to X-Frame-Options: DENY and 'self' to SAMEORIGIN. When an enforced policy includes frame-ancestors, browsers ignore X-Frame-Options. Only scheme sources, host sources, 'self' and 'none' are allowed. It doesn’t fall back to default-src and is ignored in a <meta> tag.
Doesn’t fall back to default-src. If it’s missing, this isn’t restricted.
Common mistakes
- Setting it in a <meta> tag. It only works as an HTTP header.
- Confusing it with frame-src, which controls what your page embeds.
Reporting directives
Where to send reports when something is blocked.
report-toNames the reporting endpoint that receives violation reports.
The value is an endpoint name, not a URL. Map the name to a URL with the Reporting-Endpoints response header. Browsers that support report-to ignore report-uri when both are present.
Common mistakes
- Putting a URL here instead of an endpoint name.
- Forgetting the Reporting-Endpoints header, so reports have nowhere to go.
Browser support: Chrome 70, Firefox 149, Safari 16.4.
report-uriA deprecated way to send violation reports to a URL.Deprecated
Superseded by report-to. Browsers that support report-to ignore report-uri when both are set, so sending both keeps older browsers reporting. It’s ignored in a <meta> tag.
Other directives
Upgrading requests, Trusted Types and more.
upgrade-insecure-requestsUpgrades the page’s http:// requests to https:// automatically.
Useful for sites with many legacy http:// URLs. It doesn’t upgrade people arriving from other sites via http:// links, so pair it with HSTS (Strict-Transport-Security). It takes no value.
block-all-mixed-contentAn obsolete directive for blocking mixed content.Deprecated
Marked obsolete: content that isn’t blocked is now upgraded to HTTPS anyway. Firefox removed support in version 122. Use upgrade-insecure-requests if you need a directive.
require-trusted-types-forRequires Trusted Types for DOM XSS sinks such as innerHTML.
With 'script', risky DOM sinks like innerHTML stop accepting plain strings and only accept values created by a Trusted Types policy. 'script' is the only defined value.
Browser support: Chrome 83, Firefox 148, Safari 26.
trusted-typesLists the Trusted Types policy names the page may create.
trustedTypes.createPolicy() throws for names not listed. 'none' (or no value) allows no policies, * allows any unique name and 'allow-duplicates' lets a name be used more than once. Enforcing Trusted Types at DOM sinks also needs require-trusted-types-for.
Common mistakes
- Setting trusted-types without require-trusted-types-for and expecting sinks to be protected.
Browser support: Chrome 83, Firefox 148, Safari 26.
webrtcAllows or blocks WebRTC connections.Experimental
Defined in the CSP Level 3 editor’s draft with 'allow' or 'block'. Anything other than a single 'allow' blocks WebRTC connections. MDN has no compatibility data for it yet, so check browser support before relying on it.
Sources and keywords
The values inside a directive, such as 'self' or https://cdn.example.com. Keywords, nonces and hashes need single quotes; hosts and schemes don’t.
'none'Allows nothing.
Blocks every resource of that type. It only works on its own: if other sources are listed too, 'none' has no effect. A directive with no value at all also allows nothing.
Used in: Any directive that takes a source list.
'self'Allows the page’s own origin.
Matches URLs with the same scheme, host and port as the page. It also allows upgrades on the same host, using the page’s port or the default port: an https:// page may also use wss://, and an http:// page may also use ws://, https:// and wss://. It never matches blob: or data: URLs, and doesn’t include subdomains.
Used in: Any directive that takes a source list.
*Allows any http:// or https:// URL.
The bare wildcard matches any URL whose scheme is http or https, plus URLs with the same scheme as the page. It doesn’t match data:, blob: or other schemes; list those explicitly if you need them.
Used in: Any directive that takes a source list.
Host sourceAllows a host, such as cdn.example.com, *.example.com or https://example.com/js/.
Scheme, port and path are optional. Without a scheme, the page’s scheme is used (with upgrades: http allows https). Without a port, only the default port matches. *.example.com matches subdomains at any depth but not example.com itself. A path ending in / matches everything under it; any other path must match exactly. Query strings aren’t allowed, and paths are ignored after a redirect.
Used in: Any directive that takes a source list.
Scheme sourceAllows every URL with a scheme, such as https:, data: or blob:.
The colon is required. Secure upgrades are allowed: http: also matches https:, and ws: also matches wss:. https: allows any HTTPS site, so it’s very broad for scripts.
Used in: Any directive that takes a source list.
'nonce-…'Allows <script> and <style> elements, and stylesheet links, that carry a matching nonce attribute.
The server generates a new, unguessable value for every response and adds it both to the policy and to the nonce attribute of trusted elements. The specification recommends at least 128 bits of randomness. Nonces don’t apply to event handlers, style attributes or javascript: URLs. When a nonce or hash is present, 'unsafe-inline' is ignored in that directive.
Used in: script-src, script-src-elem, style-src, style-src-elem and default-src.
'sha256-…' (hash)Allows an inline script or style whose exact content has this hash.
Use sha256, sha384 or sha512, with the base64 (or base64url) digest of the exact text between the tags, encoded as UTF-8. Whitespace matters. For external scripts, the hash matches only if the <script> has an integrity attribute whose hashes are all listed. With 'unsafe-hashes', hashes can also allow specific event handlers and style attributes. When a hash or nonce is present, 'unsafe-inline' is ignored in that directive.
Used in: script-src, script-src-elem, script-src-attr, style-src, style-src-elem, style-src-attr and default-src.
'unsafe-inline'Allows all inline scripts or styles, including injected ones.
For scripts this allows inline <script> blocks, event handlers and javascript: URLs, which removes most of CSP’s protection against cross-site scripting. For styles it allows <style> blocks and style attributes. It’s ignored when the same directive contains a nonce or hash, and for scripts when it contains 'strict-dynamic'.
Used in: Script and style directives (including -elem and -attr) and default-src.
'unsafe-eval'Allows eval(), new Function() and string arguments to setTimeout() and setInterval().
These turn strings into code, so an attacker who controls the string can run code. It also allows WebAssembly compilation. Only script-src (or default-src when script-src is missing) controls this.
Used in: script-src, or default-src when script-src is missing.
'wasm-unsafe-eval'Allows WebAssembly compilation without allowing eval().
A narrower alternative to 'unsafe-eval' for sites that use WebAssembly.
Used in: script-src, or default-src when script-src is missing.
Browser support: Chrome 97, Firefox 102, Safari 16.
'unsafe-hashes'Lets hashes allow specific event handlers and style attributes.
Without it, hashes only apply to <script> and <style> elements. Safer than 'unsafe-inline' but still risky: an allowed handler’s code could also be injected as a <script>.
Used in: script-src, script-src-attr, style-src, style-src-attr and default-src.
Browser support: Chrome 69, Firefox 109, Safari 15.4.
'strict-dynamic'Trusts scripts loaded by already-trusted scripts, and ignores host-based allowlists.
Scripts allowed by a nonce or hash can add more scripts with document.createElement(). Host sources, scheme sources, 'self' and 'unsafe-inline' are ignored for scripts, so older browsers can use them as a fallback. Scripts in your HTML need a nonce or hash, and scripts added with document.write() are blocked.
Used in: script-src, script-src-elem and default-src.
Browser support: Chrome 52, Firefox 52, Safari 15.4.
'report-sample'Includes the first 40 characters of blocked inline code in violation reports.
Makes reports easier to act on. Samples are only included for inline scripts, event handlers, styles and eval, not for external files.
Used in: Script and style directives and default-src.
Browser support: Chrome 59, Firefox 63, Safari 15.4.
'inline-speculation-rules'Allows inline <script type="speculationrules"> blocks.Non-standard
For the Speculation Rules API. It isn’t in the CSP specification.
Used in: script-src, script-src-elem and default-src.
Browser support: Chrome 110, Safari 27.3. Not supported in Firefox.
'trusted-types-eval'Allows eval() and similar functions only when they receive Trusted Types values.
Applies when Trusted Types are enforced with require-trusted-types-for. Use it instead of 'unsafe-eval', so eval() stays blocked in browsers without Trusted Types.
Used in: script-src, or default-src when script-src is missing.
Browser support: Chrome 145, Firefox 148, Safari 26.
Browser versions: @mdn/browser-compat-data 8.1.10. Specification: W3C Content Security Policy Level 3 editor’s draft.
Your policy stays with you.
Policies, URLs and code are processed in your browser. They aren’t uploaded, logged or saved, and this page doesn’t run analytics. Everything is cleared when you leave the page.
Accurate, and honest about limits.
The rules follow the W3C CSP Level 3 specification and were checked against real Chrome behaviour. Where browsers differ, results say so. This explains your policy; it isn’t a full security audit.
View the processing code: explainer · reference data
Beta feedback helps shape Labs. Tell Andy what would help — please leave out sensitive data.
