Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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.

Slide 7

Slide 7 text

"Enigma" - skittledog, http://flic.kr/p/9VjJz5 Never load unencrypted content.

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Set-Cookie: ...; secure; HttpOnly

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

https://www.startssl.com/

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

scheme://host:port

Slide 23

Slide 23 text

beAwesome(); beEvil();

Slide 24

Slide 24 text

beAwesome();

Hello, beEvil();

Slide 25

Slide 25 text

p { color: {{USER_COLOR}}; }

Hello {{USER_NAME}}, view your Account.

var id = {{USER_ID}};

Slide 26

Slide 26 text

"I discount the probability of perfection." -Alex Russell

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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, } }

Slide 33

Slide 33 text

function handleClick() { ... } Click me! Click me!

Slide 34

Slide 34 text

Click me! Click me! function handleClick() { ... } function init() { for (var e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); }

Slide 35

Slide 35 text

Content-Security-Policy: script-src 'nonce-THIS-IS-A-RANDOM-NONCE'; Click me! Click me! function handleClick() { ... } function init() { var e; for (e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); }

Slide 36

Slide 36 text

Content-Security-Policy: script-src 'sha256-kjhhuy...poiIOY-AI'; Click me! Click me! function handleClick() { ... } function init() { var e; for (e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); }

Slide 37

Slide 37 text

"Framed in the Valley" - cobalt123, http://www.flickr.com/photos/cobalt/5354090310/ Limit Unanticipated Framing.

Slide 38

Slide 38 text

Click me! I am happy!

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

Content-Security-Policy: frame-ancestors 'none' or Content-Security-Policy: frame-ancestors 'self' or Content-Security-Policy: frame-ancestors [source list]

Slide 42

Slide 42 text

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.