# Content Security Policy (CSP)

DevFeed: [Content Security Policy (CSP)](<https://devfeed.tech/articles/content-security-policy-csp-89166.md>)

Original publisher: [Read original article](<https://specification.website/spec/security/content-security-policy/>)

Author: Joost de Valk

Published: 2026-07-09T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Website Specification](<https://devfeed.tech/sources/the-website-specification.md>)

Topics: [Security](<https://devfeed.tech/topics/security.md>), [frontend security](<https://devfeed.tech/topics/frontend-security.md>), [XSS](<https://devfeed.tech/topics/xss.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>)

Tags: [csp](<https://devfeed.tech/tags/csp.md>), [data-exfiltration](<https://devfeed.tech/tags/data-exfiltration.md>), [recommended](<https://devfeed.tech/tags/recommended.md>), [security](<https://devfeed.tech/tags/security.md>), [security-policy](<https://devfeed.tech/tags/security-policy.md>), [xss](<https://devfeed.tech/tags/xss.md>)

## AI overview

Content Security Policy (CSP) is a browser-enforced response header that controls which sources a page may load and execute. This tutorial explains how nonce-based policies, directives such as `strict-dynamic` and `frame-ancestors`, and violation reports can help limit cross-site scripting, data exfiltration, and clickjacking. It also covers common configuration mistakes and ways to verify a policy.

## Source excerpt

A CSP tells browsers which sources of script, style, image, and frame content to trust. A good policy stops most XSS and data-exfiltration attacks dead.