User Agent Lockdown - HackPra 2014

User Agent Lockdown - HackPra 2014

3c27881a0d8695811b0fa23bd794e696?s=128

Mike West

April 16, 2014
Tweet

Transcript

  1. User Agent Lockdown Mike West https://mikewest.org G+: mkw.st/+ Twitter: @mikewest

    Slides: https://mkw.st/r/hackpra14
  2. None
  3. http://traumwerk.stanford.edu/philolog/2009/10/homers_odyssey_in_art_sirens_f.html

  4. http://traumwerk.stanford.edu/philolog/2009/10/homers_odyssey_in_art_sirens_f.html

  5. http://traumwerk.stanford.edu/philolog/2009/10/homers_odyssey_in_art_sirens_f.html Principle of Least Privilege

  6. Privileges we should reconsider: 1. Browsers allow content to load

    over unencrypted connections. 2. Browsers accept whatever happens to live at a URL as canonical. 3. Browsers load any and all resources a page requests.
  7. "Enigma" - skittledog, http://flic.kr/p/9VjJz5 Never load unencrypted content.

  8. None
  9. None
  10. None
  11. Set-Cookie: ...; secure; HttpOnly

  12. Strict-Transport- Security: max-age=2592000; includeSubDomains

  13. None
  14. Public-Key-Pins: max-age=2592000; pin-sha256="4n972H…yw4uqe/baXc="

  15. https://www.startssl.com/

  16. https://www.ssllabs.com/ssltest/

  17. Verify resource integrity. "Stop Corruption" - kennymiller, https://www.flickr.com/photos/kennymiller/796971032

  18. <script src="https://cdn.example.net/script.js"></script>

  19. https://w3c.github.io/webappsec/specs/subresourceintegrity/ https://mkw.st/r/subint

  20. <script src="https://cdn.example.net/script.js" integrity="ni:///sha256;aje...87w?ct=application/javascript" ></script>

  21. "Finance - Financial Injection - Finance" - doug8888, http://www.flickr.com/photos/doug88888/4561376850/ Mitigate

    content injection.
  22. scheme://host:port

  23. <script> beAwesome(); </script> <script> beEvil(); </script>

  24. <script> beAwesome(); </script> <!-- <p>Hello, {$name}!</p> --> <p>Hello, <script> beEvil();

    </script></p>
  25. <style> p { color: {{USER_COLOR}}; } </style> <p> Hello {{USER_NAME}},

    view your <a href="{{USER_URL}}">Account</a>. </p> <script> var id = {{USER_ID}}; </script> <!-- DEBUG: {{INFO}} -->
  26. "I discount the probability of perfection." -Alex Russell

  27. "We are all idiots with deadlines." -Mike West

  28. http://www.html5rocks.com/en/tutorials/security/content-security-policy/ https://mkw.st/r/csp

  29. None
  30. Content-Security-Policy: default-src 'none'; style-src https://mikewestdotorg.hasacdn.net; frame-src https://www.youtube.com https://www.speakerdeck.com; script-src https://mikewestdotorg.hasacdn.net

    https://ssl.google-analytics.com; img-src 'self' https://mikewestdotorg.hasacdn.net https://ssl.google-analytics.com; font-src https://mikewestdotorg.hasacdn.net
  31. Content-Security-Policy: default-src ...; script-src ...; object-src ...; style-src ...; img-src

    ...; media-src ...; frame-src ...; font-src ...; connect-src ...; sandbox ...; report-uri https://example.com/reporter.cgi
  32. Content-Security-Policy-Report-Only: default-src https:; report-uri https://example.com/csp-violations { "csp-report": { "document-uri": "http://example.org/page.html",

    "referrer": "http://evil.example.com/haxor.html", "blocked-uri": "http://evil.example.com/img.png", "violated-directive": "default-src 'self'", "original-policy": "...", "source-file": "http://example.com/script.js", "line-number": 10, "column-number": 11, } }
  33. <script> function handleClick() { ... } </script> <button onclick="handleClick()">Click me!</button>

    <a href="javascript:handleClick()">Click me!</a>
  34. <!-- index.html --> <script src="clickHandler.js"></script> <button class="clckr">Click me!</button> <a href="#"

    class="clckr">Click me!</a> <!-- clickHandler.js --> function handleClick() { ... } function init() { for (var e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); }
  35. Content-Security-Policy: script-src 'nonce-THIS-IS-A-RANDOM-NONCE'; <button class="clckr">Click me!</button> <a href="#" class="clckr">Click me!</a>

    <script nonce="THIS-IS-A-RANDOM-NONCE"> function handleClick() { ... } function init() { var e; for (e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); } </script>
  36. Content-Security-Policy: script-src 'sha256-kjhhuy...poiIOY-AI'; <button class="clckr">Click me!</button> <a href="#" class="clckr">Click me!</a>

    <script> function handleClick() { ... } function init() { var e; for (e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); } </script>
  37. "Framed in the Valley" - cobalt123, http://www.flickr.com/photos/cobalt/5354090310/ Limit Unanticipated Framing.

  38. Click me! I am happy!

  39. "X-Frame-Options: All about Clickjacking?" https://cure53.de/xfo-clickjacking.pdf

  40. X-Frame-Options: DENY or X-Frame-Options: SAMEORIGIN

  41. Content-Security-Policy: frame-ancestors 'none' or Content-Security-Policy: frame-ancestors 'self' or Content-Security-Policy: frame-ancestors

    [source list]
  42. Thanks for your time! 1. HTTPS all the things. 2.

    Deploy Content Security Policy (mkw.st/r/csp) to mitigate content injection attacks. 3. Follow the progress of Subresource Integrity (mkw.st/r/subint). 4. Ask questions, now, or on Twitter: @mikewest.