A Content Security Policy is a header that tells the browser which sources a page may load scripts, styles, images and forms from, so injected code has nowhere to run.
It is one of the strongest protections against cross-site scripting: even if someone manages to inject a script, the browser refuses to run it unless it comes from an allowed source.Source 1 It can also limit where forms may send data.
A strict policy is easiest on a site with few third parties. Sites full of tag managers and widgets end up with long, leaky allow-lists.Source 2
How Regular approaches it
Regular's sites load almost everything from their own domain, which makes a tight policy simple. On Piggelinen, forms may only post to the one form service the school uses.
BenjaminWeb designer for sustainable and circular businessesSources and further reading
- Content Security Policy, MDN Web Docsdeveloper.mozilla.org
- Content Security Policy Cheat Sheet, OWASPcheatsheetseries.owasp.org