Skip to content

Definition

Content Security Policy

Also called CSP

A Content Security Policy (CSP) is an HTTP response header that tells a browser which sources a page may load scripts, styles, images, and frames from, limiting the damage that injected or unwanted content can do.

What it means

The policy is a list of directives, each covering one kind of resource. A script-src directive limits where scripts may come from, and a frame-src directive limits which sites may be shown in an iframe.

Inline scripts are blocked unless they carry a nonce, a random value generated for each response and repeated on the trusted script tags. This is the main defence against cross-site scripting.

A policy that is too loose gives little protection, and one that is too strict breaks legitimate content, so the usual path is to start in report-only mode, fix what breaks, and then enforce.

Folio sends a Content Security Policy on its pages, uses a per-request nonce for scripts, and lists the exact map and video origins that may be framed on published sites.

Example

Content-Security-Policy: default-src 'self'; frame-src https://www.openstreetmap.org; script-src 'self' 'nonce-r4nd0m'

Frequently asked questions

Does a Content Security Policy replace other security?

No. It is a safety net that limits what injected content can do. Input validation, safe output encoding, and up-to-date software are still needed to prevent the injection in the first place.

Why did my embed disappear after I added a policy?

The policy probably does not list the embed source under frame-src. Add that exact origin, or remove the embed if you do not trust it.

Start free

Build your resume and portfolio in one place.

Resume PDF and DOCX export is free and unwatermarked on every plan, and every published portfolio ships with a sitemap, structured data, and llms.txt.