Content Security Policy: which page actions may proceed?
A page wants to run a button’s code, load a picture or contact another site. Follow the browser’s gates, then change a rule and predict which action is permitted.
Start with what the page wants to load, run or embed.
Build a Sun page from a script, picture, stylesheet and data request.
Choose one ingredient to follow through its own rule.
Choose an example below, then use Next to watch the decision.
Change the policy or action
Changing a choice returns to the beginning. Restart restores this story’s original choices.
Offline teaching models for a CSP3 supporting browser. No page script, policy, nonce, site setting, network request or report is changed by these controls. These are selected HTTPS/classic-script fixtures, not a complete CSP engine. Space plays or pauses; Next, Previous and Restart follow the active scene.
Find a CSP directive by its job · 28 entries
CSP3 is a W3C Working Draft; implementations and extension support vary. This map distinguishes core rules, separate specifications, experimental features and deprecated directives. It is not a production policy generator.
| Directive | Job | Meaning and status |
|---|---|---|
| default-src Read source ↗ | Fetch | Fallback for fetch rules that have no more specific directive.Core CSP3 |
| script-src Read source ↗ | Fetch | Script source rules; also governs eval-like execution checks.Core CSP3 |
| script-src-elem Read source ↗ | Fetch | Script elements, including files and inline script blocks.Core CSP3 |
| script-src-attr Read source ↗ | Fetch | Inline script event handlers such as onclick.Core CSP3 |
| style-src Read source ↗ | Fetch | Stylesheets and fallback rules for style elements/attributes.Core CSP3 |
| style-src-elem Read source ↗ | Fetch | Style elements and stylesheet link elements.Core CSP3 |
| style-src-attr Read source ↗ | Fetch | Style attributes on individual elements.Core CSP3 |
| img-src Read source ↗ | Fetch | Images and favicons.Core CSP3 |
| connect-src Read source ↗ | Fetch | Controls where scripts may request data or open connections.Core CSP3 |
| font-src Read source ↗ | Fetch | Fonts loaded by the page.Core CSP3 |
| media-src Read source ↗ | Fetch | Audio, video and track resources.Core CSP3 |
| object-src Read source ↗ | Fetch | Object and embed resources.Core CSP3 |
| manifest-src Read source ↗ | Fetch | Web app manifests.Core CSP3 |
| frame-src Read source ↗ | Fetch | Child frames this page loads.Core CSP3 |
| child-src Read source ↗ | Fetch | Fallback for frame-src and worker-src.Core CSP3 |
| worker-src Read source ↗ | Fetch | Worker, SharedWorker and ServiceWorker script loads.Core CSP3 |
| base-uri Read source ↗ | Document | Allowed base element URLs; no default-src fallback.Core CSP3 |
| sandbox Read source ↗ | Document | Removes capabilities such as scripts, forms or same-origin identity unless specific allowances restore them. Not delivered through meta or enforced by Report-Only.Core CSP3 |
| form-action Read source ↗ | Navigation | Destinations for form submissions; no default-src fallback.Core CSP3 |
| frame-ancestors Read source ↗ | Embedding | Every ancestor that embeds this page must match; header only, no default-src fallback.Core CSP3 |
| report-to Read source ↗ | Reporting | Names a reporting endpoint group; the URL mapping is supplied separately.Core CSP3 |
| report-uri Read source ↗ | Reporting | Legacy report destination URL; ignored when a supported report-to directive applies.Deprecated; compatibility fallback |
| upgrade-insecure-requests Read source ↗ | Upgrade | Rewrites eligible insecure requests to HTTPS; does not guarantee the destination supports HTTPS or authorize it through other gates.Separate specification |
| require-trusted-types-for Read source ↗ | Trusted Types | Requires designated DOM injection sinks to receive appropriate Trusted Types values instead of ordinary strings. A separate feature with varying browser support.Separate specification; check support |
| trusted-types Read source ↗ | Trusted Types | Restricts creation of Trusted Types policy names. It does not make a policy’s transformation safe by itself.Separate specification; check support |
| fenced-frame-src Read source ↗ | Compatibility notes | Sources for fenced frames; outside this simulator.Experimental; limited support |
| prefetch-src Read source ↗ | Compatibility notes | Older proposed prefetch control; outside this simulator.Non-standard; do not rely on it |
| block-all-mixed-content Read source ↗ | Compatibility notes | Older mixed-content restriction; not a current deployment recommendation.Deprecated |
Key idea: A CSP policy restricts actions by the protected page. The directive, delivery, timing and disposition determine which gate applies.
Terms
- DOM
- The browser’s structured representation of a document, made of objects called nodes.
- HTML
- A language for describing the elements and structure of a web page.
- SRI
- A browser check comparing a downloaded resource with expected cryptographic digest information.
- non-parser-inserted
- Introduced by the shown script loader instead of by parsing an ordinary script tag in HTML.
- default-src
- Fallback for fetch rules that have no more specific directive.
- script-src
- Script source rules; also governs eval-like execution checks.
- script-src-elem
- Script elements, including files and inline script blocks.
- script-src-attr
- Inline script event handlers such as onclick.
- style-src
- Stylesheets and fallback rules for style elements/attributes.
- style-src-elem
- Style elements and stylesheet link elements.
- style-src-attr
- Style attributes on individual elements.
- img-src
- Restricts where this page’s images and small tab icons may be loaded from.
- connect-src
- Script connections such as fetch, XHR and WebSocket.
- font-src
- Fonts loaded by the page.
- media-src
- Audio, video and track resources.
- object-src
- Object and embed resources.
- manifest-src
- Restricts where a page can load the file describing an installable web app.
- frame-src
- Child frames this page loads.
- child-src
- Fallback for frame-src and worker-src.
- worker-src
- Worker, SharedWorker and ServiceWorker script loads.
- base-uri
- Allowed base element URLs; no default-src fallback.
- sandbox
- Removes capabilities such as scripts, forms or same-origin identity unless specific allowances restore them. Not delivered through meta or enforced by Report-Only.
- form-action
- Destinations for form submissions; no default-src fallback.
- frame-ancestors
- Every ancestor that embeds this page must match; header only, no default-src fallback.
- report-to
- Names a reporting endpoint group; the URL mapping is supplied separately.
- report-uri
- Legacy report destination URL; ignored when a supported report-to directive applies.
- upgrade-insecure-requests
- Rewrites eligible insecure requests to HTTPS; does not guarantee the destination supports HTTPS or authorize it through other gates.
- require-trusted-types-for
- Requires designated DOM injection sinks to receive appropriate Trusted Types values instead of ordinary strings. A separate feature with varying browser support.
- trusted-types
- Restricts creation of Trusted Types policy names. It does not make a policy’s transformation safe by itself.
- fenced-frame-src
- Sources for fenced frames; outside this simulator.
- prefetch-src
- Older proposed prefetch control; outside this simulator.
- block-all-mixed-content
- Older mixed-content restriction; not a current deployment recommendation.
- CSP
- Content Security Policy: rules a browser applies to actions by a protected page.
- directive
- One named rule inside a CSP policy.
- CSP policy
- A set of browser restrictions delivered together for a page.
- source list
- Alternative sources or permission expressions within one directive.
- source expression
- One item describing what a CSP source list allows.
- 'self'
- A CSP source expression referring to the protected page’s origin.
- 'none'
- When used alone in a source list, permits no sources for that rule.
- fallback
- The next rule to consult when a more specific rule is absent.
- nonce
- An unpredictable permission label attached to selected script or style elements for one response.
- hash-source
- A CSP permission based on a digest of exact code text.
- SHA-256
- A calculation that turns bytes into a fixed-length 256-bit digest.
- inline script
- Code written directly inside an HTML script element rather than loaded as a separate file.
- event handler
- Code attached to an event, such as a click on a button.
- eval
- A JavaScript operation that interprets a string as code.
- unsafe-inline
- A broad CSP source keyword permitting inline script or style behavior where applicable.
- unsafe-hashes
- A CSP source keyword allowing matching hashes to authorize certain inline attributes and script-like navigation.
- strict-dynamic
- A CSP source keyword that changes script-loading rules in supporting browsers.
- parser-inserted
- Introduced as part of parsing HTML, rather than created through the shown script loader.
- Report-Only
- A policy disposition that observes violations without enforcing blocking by that policy.
- violation
- An attempted action that does not satisfy a policy’s applicable rule.
- ancestor
- A page surrounding an embedded page, directly or through other nested frames.
- worker
- A separate browser execution context for background work, using a script.
- origin
- The scheme, host and port that identify a web origin.
- CDN
- Content delivery network: servers used to distribute files to readers.
- XSS
- Cross-site scripting: unwanted code runs in a page’s context.
- Trusted Types
- Browser values used to restrict dangerous conversions from strings into executable or document content.
- injection sink
- An API or operation where supplied text can become active document content or code.
- meta element
- An HTML element that can supply certain page metadata, including a limited CSP.
- reporting endpoint group
- A named reporting destination whose URL mapping is delivered separately.
- disposition
- Whether a policy is enforced as a restriction or monitored for violations.
Rules & examples
A CSP policy restricts actions by the protected page. The directive, delivery, timing and disposition determine which gate applies.
- A specific fetch directive replaces its fallback source list; it is not merged with it.
- Every enforced policy applies independently. Report-Only detects violations without blocking by that policy.
- A nonce authorizes matching script/style elements; it does not authorize an onclick attribute. Exact inline hashes include whitespace.
- frame-ancestors, base-uri and form-action do not inherit default-src. Meta delivery has limited support and only affects later processing.
This is a bounded offline CSP3 model, not a production policy generator. Sources match selected exact HTTPS origins; redirects, general URL/path matching, external-script SRI and browser compatibility fallbacks are not simulated. Production Visual RFC security headers are unchanged.