--- outputs: - html title: "CSP bug reproduction" date: "2022-11-10T18:05:00-08:00" description: "A demonstration page to help diagnose Content-Security-Policy issues in browser software." --- If you're on this page, chances are you followed a link from a Content-Security-Policy (CSP)-related bug report. This page should help diagnose the offending part of the CSP. I made this page because [I noticed my site breaking browser software]({{}}), and wanted to fix said software. What this page demonstrates --------------------------- This is a test page that demonstrates the following Content-Security-Policy (CSP): ``` default-src 'none' 'report-sample';img-src 'self';style-src 'sha256-7cS8Hu9ov7dRhfioeeb9J8mtB9/iLLpVIZsMM+BJUcs=' 'report-sample';frame-ancestors 'none';base-uri 'none';form-action https://seirdy.one/webmentions/receive https://seirdy.one/search/;manifest-src 'self';media-src 'self';sandbox allow-same-origin allow-scripts allow-forms;report-uri https://collector.seirdy.one;connect-src https://collector.seirdy.one ``` Here's a multi-line version, to reduce horizontal scrolling: ``` default-src 'none' 'report-sample'; img-src 'self'; style-src 'sha256-HASH' 'report-sample'; frame-ancestors 'none'; base-uri 'none'; form-action https://seirdy.one/webmentions/receive https://seirdy.one/search/; manifest-src 'self'; media-src 'self'; sandbox allow-same-origin allow-scripts allow-forms; report-uri https://collector.seirdy.one; connect-src https://collector.seirdy.one ``` How to use this page -------------------- All pages on my site contain a strict CSP. Most pages on my site have a CSP containing a `sandbox` directive that does **not** specify the `allow-scripts` parameter. Here's the CSP for most of my other pages, such as my homepage: ``` default-src 'none'; img-src 'self'; style-src 'sha256-HASH'; frame-ancestors 'none'; base-uri 'none'; form-action https://seirdy.one/webmentions/receive https://seirdy.one/search/; manifest-src 'self'; upgrade-insecure-requests; sandbox allow-same-origin allow-forms ``` This page has a CSP that differs in four ways: - It includes a reporting endpoint - It specifies an `allow-scripts` parameter on its `sandbox` directive - It allows loading media (necessary for the `