Conversation

CSP is large and sprawling, but a "strict" subset of the policy language is _very_ effective at mitigating injection attacks (XSS). rolled that subset out at Google-scale, and walks through the mechanism in detail in web.dev/strict-csp/. It's worth your time to read.
Quote Tweet
If you want to learn how to mitigate XSS with a strict CSP based on nonces or hashes read: web.dev/strict-csp/ The "strict" CSP approach: ✅ doesn't suffer from allow-list bypasses, ✅ doesn't need customisation and ✅ effectively reduces the attack surface of your app.
1
54
This, of course, isn't new. mitigation.supply shows that ~15% of Chrome page views have at least one frame with a "strict" CSP, and ~10% of pages have at least one frame with a "better than strict" policy that avoids 'strict-dynamic'. Join the club! Defend your users.
1
3
Replying to
It's unfortunate that hash-source didn't support external scripts from the beginning. I'm used to working on sites where there's only static HTML which can be cached. I'd like to follow this advice rather than allowing 'self' but last time I checked browsers weren't ready for it.