Content Security Policy (CSP)
A browser rule set that controls which sources of scripts and content a page is allowed to load.
What it is
A Content Security Policy is a header that tells the browser exactly which sources of scripts, styles, images, and other content a page may use. By restricting content to trusted sources, it makes it much harder for injected malicious scripts to run. It is one of the strongest browser-enforced defenses against cross-site scripting.
Why it matters
A good CSP acts as a safety net that can neutralize cross-site scripting even when an injection flaw slips through, significantly reducing impact.
How to fix it
Define a restrictive policy that allowlists only trusted content sources, avoid broad exceptions, and test it carefully to avoid breaking legitimate functionality.