Skip to content

QuizNot attempted

What CSP is for

You add Content-Security-Policy: script-src 'self'. What does it do?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • Blocks inline scripts and scripts from other origins, so an injected <script> usually will not run
  • script-src 'self' tells the browser to run only scripts loaded from your own origin, so inline <script>, onerror= handlers and third-party scripts are blocked
  • it limits the damage when an XSS bug slips through.
  • Not escapes input: CSP never touches your data.
  • Not fixes the bug: the injection is still there, CSP just stops it executing.
  • Not stops CSRF: CSRF needs no script on your page at all.