diff --git a/docs/csp-headers.md b/docs/csp-headers.md new file mode 100644 index 0000000000..23998480c7 --- /dev/null +++ b/docs/csp-headers.md @@ -0,0 +1,22 @@ +# CSP headers in local dev and on Vercel + +## Why + +Production CSP headers are set server-side in Nexus, so why should we set the headers on Vercel and the Vite dev server too? We are not _that_ concerned about security in those environments. The main reason is so we can know as early as possible in the development process whether a given CSP directive breaks something the web console. + +## What + +The base headers are defined in `vercel.json` and imported into `vite.config.ts` to avoid repeating them. + +The `content-security-policy` is based on the recommendation by the [OWASP Secure Headers Project](https://owasp.org/www-project-secure-headers/index.html) (click the "Best Practices" tab). The directives: + +- `default-src 'self'`: By default, restrict all resources to same-origin. +- `style-src 'unsafe-inline' 'self'`: Restrict CSS to same-origin and inline use. See #2183 for eventually removing `'unsafe-inline'` +- `frame-src 'none'`: Disallow nested browsing contexts (`` and `