CSP Builder
Build a Content Security Policy from the sources you allow for scripts, styles, images, fonts, connections, frames and more. Keywords such as self and none are quoted for you and every source is checked. You get the header, a meta tag, nginx and Apache lines and a review of the policy that points out weak spots such as unsafe-inline scripts.
Frequently asked questions
Where should I start?
Start with default-src 'self', object-src 'none', base-uri 'self' and frame-ancestors 'none', which the form fills in, then add the domains your pages load scripts, styles, fonts and images from. Test with Report only first so nothing breaks while you adjust the list.
Do I have to type the quotes around self?
No. Keywords such as self, none, unsafe-inline and strict-dynamic, and nonce- and sha256- values, are quoted automatically. Without the quotes a browser would read self as a host name.
Why is the meta tag missing some directives?
Browsers ignore frame-ancestors, report-uri, report-to and sandbox in a meta tag, so the tool leaves them out there. Send the policy as an HTTP header to use them. A report-only policy cannot be set with a meta tag at all.
How does reporting work?
With a report URL the policy gets report-uri for older browsers and report-to with an endpoint named csp-endpoint, which the extra Reporting-Endpoints header defines. Browsers then send violation reports to that URL.
What does the review check?
It runs the same checks as the CSP Evaluator, such as scripts allowed through unsafe-inline, unsafe-eval, wildcards or whole schemes like https:, a missing object-src or base-uri and a missing frame-ancestors.
What does upgrade-insecure-requests do?
It tells browsers to load every http resource of the page over https instead. It helps sites that moved to https but still contain old http links in their content.