What is a Content Security Policy (CSP)?
A Content Security Policy is a set of rules a website sends to browsers listing which sources of scripts, connections and other content the page may load, so the browser blocks anything else.
What is a Content Security Policy (CSP)?
A Content Security Policy is a set of rules a website sends to browsers listing which sources of scripts, connections and other content the page may load, so the browser blocks anything else.
Why it matters
Modern sites load code from many vendors, and attackers who change a vendor's script can steal card numbers or session cookies from every site that uses it. A strict CSP limits where scripts can come from and where data can be sent, and its violation reports warn you when something unexpected runs.
Example
On 16 November 2026 an attacker wrote malicious JavaScript into Optimizely customer projects, served from Optimizely's own CDN to 178 organizations' sites, skimming card data and swapping crypto wallet addresses (Report URI).
How to defend against it
- Set a restrictive script-src and connect-src that list only the domains you need.
- Turn on CSP violation reporting and alert on new blocked sources.
- Mark session cookies HttpOnly so scripts cannot read them.
- Monitor third-party scripts for content changes, not just availability.
Related terms
Supply chain attack, Magecart skimming, subresource integrity
Sources
From AgentSec Brief, the daily brief on securing agentic AI. Subscribe free at https://www.agentsecbrief.com