The Pos Ronda gate: each arrival matched to a CSP directive, then in a test frame your own browser decides which style and image load. unsafe-inline, nonce…
Why it matters
A CSP is the second layer against XSS: if there is a hole and a <script> is slipped into the page, a strict CSP makes the browser refuse it. But one wrong token, like 'unsafe-inline' or a missing default-src, quietly switches the protection off. Knowing how the browser matches each source lets you write a rule that really guards.
The key idea
A CSP lists what may come in, not what is banned
Common mistakes
Using 'unsafe-inline' to make it work fast It switches off the heart of a CSP: every slipped-in inline script gets through. Move scripts to their own files, or mark your own with a random per-response 'nonce-…'; onclick handlers move to addEventListener.
The same nonce on every response A nonce must be random and new per response, made by the server with a secure random generator. A fixed nonce can be read off any page, so a slipped-in script carrying it gets through too.
Forgetting default-src A directive not written falls back to default-src. Without it, fonts, fetches, frames and images come from anywhere. Write default-src 'self' first, then loosen per directive.
Try it in this playground
See an inline script refused With no 'unsafe-inline' and no nonce, an inline script may not come in.
Switch on 'unsafe-inline' The button’s onclick gets through too: every inline is open.
Use a nonce Only the marked tag gets through; other inlines stay out.
Leave out default-src Images, fonts and fetches from outside walk in: no rule covers them.