Slide 1

Slide 1 text

Mitigate Maliciousness Mike West https://mikewest.org/ G+: https://mkw.st/+ Twitter: @mikewest

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

doAstoundinglyAwesomeThing(); sneakilyExfiltrateUserData();

Slide 4

Slide 4 text

XSS is scary.

Slide 5

Slide 5 text

scheme://host:port

Slide 6

Slide 6 text

https://www.owasp.org/index.php/ XSS_Filter_Evasion_Cheat_Sheet

Slide 7

Slide 7 text

p { color: {{USER_COLOR}}; }

Hello {{USER_NAME}}, view your Account.

var id = {{USER_ID}};

Slide 8

Slide 8 text

[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[]) [+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[]) [+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[] +!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[] +!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]] +(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+ [[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+ [[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+ (!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+ ([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+ [])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[] +!+[]]]]+(!![]+[])[+[[+!+[]]]]]((![]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[!+[]+!+ []+!+[]]]]+(!![]+[])[+[[+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+ []+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+ (!![]+[])[+[[+!+[]]]]]+[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+[+!+[]]+([][(![]+[])[+[[+[]]]]+ ([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+ [[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]])()

Slide 9

Slide 9 text

[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[]) [+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[]) [+[[!+[]+!+[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]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+ (!![]+[])[+[[+!+[]]]]]+[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+[+!+[]]+([][(![]+[])[+[[+[]]]]+ ([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+ [[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]])() alert(1)

Slide 10

Slide 10 text

“I discount the probability of perfection.” -Alex Russell

Slide 11

Slide 11 text

Not “if”, but “when”.

Slide 12

Slide 12 text

Before all else, send data securely

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

$ curl -I http://mkw.st/ HTTP/1.1 301 Moved Permanently Server: nginx/1.3.7 Date: Sun, 11 Nov 2012 19:36:15 GMT Content-Type: text/html Content-Length: 184 Connection: keep-alive Keep-Alive: timeout=20 Location: https://mkw.st/

Slide 18

Slide 18 text

Set-Cookie: ...; secure; HttpOnly

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Public-Key-Pins: max-age=2592000; pin-sha1="4n972H…60yw4uqe/baXc="; pin-sha1="IvGeLsbqzP…j2xVTdXgc=" http://tools.ietf.org/html/draft-ietf-websec-key-pinning

Slide 21

Slide 21 text

http://www.html5rocks.com/en/tutorials/ security/transport-layer-security/

Slide 22

Slide 22 text

Limit the browser’s capabilities “Every program and every privileged user of the system should operate using the least amount of privilege necessary to complete the job.” Jerome H. Saltzer, "Protection and the control of information sharing in multics"

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

http://w3.org/TR/CSP11

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Content-Security-Policy: default-src 'none'; style-src https://mikewestdotorg.hasacdn.net; frame-src https://www.youtube.com http://www.slideshare.net; script-src https://mikewestdotorg.hasacdn.net https://ssl.google-analytics.com; img-src 'self' https://mikewestdotorg.hasacdn.net https://ssl.google-analytics.com data:; font-src https://mikewestdotorg.hasacdn.net

Slide 27

Slide 27 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 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 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/image.png", "violated-directive": "default-src 'self'", "original-policy": "...", "line-number": "10" } }

Slide 31

Slide 31 text

http://www.html5rocks.com/en/tutorials/ security/content-security-policy/

Slide 32

Slide 32 text

Remember two things: HTTPS: http://goo.gl/Pw6wU CSP: http://goo.gl/QcuaK Questions? [email protected] mkw.st/+ @mikewest

Slide 33

Slide 33 text

Even fewer privileges!

Slide 34

Slide 34 text

Slide 35

Slide 35 text

Slide 36

Slide 36 text

Slide 37

Slide 37 text

http://www.html5rocks.com/en/tutorials/ security/sandboxed-iframes/