1 of 7

More XSS

Cybersecurity Club

2 of 7

Club Stuff

3 of 7

Content Security Policy (CSP)

  • XSS mitigation (among other things)
  • Limits the URLs you can access
  • HTTP Response header

4 of 7

Example

  • content-security-policy: script-src: 'self' https://example.com/
    • Allowed: <script src="/foo.js"> <script src="https://example.com/foo.js">
    • Disallowed: <script>alert(1)</script> <script src="https://foo.com/foo.js">

5 of 7

CSP Directives

  • default-src applies to everything
  • script-src applies to script tags
  • connect-src applies to fetch
  • Lots more (learn more here and here)
  • Example with multiple directives:
    • default-src: 'self'; script-src: 'none'; connect-src: https://a.com/ https://b.com/

6 of 7

Circumventing CSP

  • Look through the script-src for any pages that you control and upload the script to there
  • If default-src isn't set or is bad, look for abusable directives
  • If iframes are allowed and there's a page without CSP, you can abuse that (not needed for this week's challenge)

7 of 7

Try it yourself!

(last week's challenge)

https://xss.blairsec.mbhs.edu/

(this week's fancy CSP challenge)

https://xss2.blairsec.mbhs.edu/