csp-toolkit: Analyzing Content Security Policy Headers at Scale

There’s no Python library for parsing Content Security Policy headers. I checked PyPI, I checked GitHub — nothing. Google has a CSP Evaluator web tool and an npm package, but if you want to analyze CSP programmatically in Python — for recon scripts, bug bounty automation, or CI pipelines — you’re on your own. So I built one. csp-toolkit is a Python library and CLI tool that parses CSP headers, runs 21 weakness checks, finds bypass vectors against a database of 79 known-exploitable domains, scores policies A+ to F, and does a lot more. It’s on PyPI now. ...

March 27, 2026 · 4 min · Carl Sampson

Content Security Policy

Content Security Policy (CSP) is a security measure that helps protect web applications from various attacks, including Cross-Site Scripting (XSS) and data injection. CSP works by specifying a set of Content Security Rules that dictate what resources are allowed to load on a page. This can be used to whitelist trusted sources of content, or to block untrusted content entirely. One advantage of Content Security Policy is that it can help to prevent malicious code from running on a page. This is because CSP blocks resources from loading unless they are explicitly allowed by the Content Security Rules. As a result, CSP can act as a barrier against XSS attacks and other types of malicious code injection. ...

February 23, 2023 · 1 min · chs