W EB P LATFORM : T HE N OT C OMPLETELY AND O BVIOUSLY I NSECURE P - - PowerPoint PPT Presentation

w eb p latform t he n ot c ompletely
SMART_READER_LITE
LIVE PREVIEW

W EB P LATFORM : T HE N OT C OMPLETELY AND O BVIOUSLY I NSECURE P - - PowerPoint PPT Presentation

W EB P LATFORM : T HE S ECURE P ARTS Mike West @mikewest, mkw.st/+ Slides: https://mkw.st/r/goto13 W EB P LATFORM : T HE N OT C OMPLETELY AND O BVIOUSLY I NSECURE P ARTS Mike West @mikewest, mkw.st/+ Slides: https://mkw.st/r/goto13 Insert


slide-1
SLIDE 1

WEB PLATFORM: THE SECURE PARTS

Mike West @mikewest, mkw.st/+ Slides: https://mkw.st/r/goto13

slide-2
SLIDE 2
slide-3
SLIDE 3

WEB PLATFORM: THE NOT COMPLETELY

AND OBVIOUSLY INSECURE PARTS

Mike West @mikewest, mkw.st/+ Slides: https://mkw.st/r/goto13

slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8

Insert STARTSSL HERE.

startssl.com

slide-9
SLIDE 9

$ curl -I http://mkw.st/ HTTP/1.1 301 Moved Permanently Server: nginx/1.5.0 Date: Mon, 1 Oct 2013 19:36:15 GMT Content-Type: text/html Content-Length: 184 Connection: keep-alive Keep-Alive: timeout=20 Location: https://mkw.st/

slide-10
SLIDE 10

$ curl -I https://mkw.st/ HTTP/1.1 200 OK Server: nginx/1.5.0 Date: Mon, 1 Oct 2013 19:42:31 GMT ... Strict-Transport-Security: max-age=2592000; includeSubDomains ...

slide-11
SLIDE 11

Set-Cookie: ...; secure; HttpOnly

slide-12
SLIDE 12

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

slide-13
SLIDE 13

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

goo.gl/0aMqHM

slide-14
SLIDE 14

Content injection is scary.

slide-15
SLIDE 15

scheme://host:port

slide-16
SLIDE 16

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

slide-17
SLIDE 17

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

slide-18
SLIDE 18

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

slide-19
SLIDE 19

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

alert(1);

slide-21
SLIDE 21

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

goo.gl/XE0aW

slide-22
SLIDE 22

"I discount the probability of perfection."

  • Alex Russell
slide-23
SLIDE 23

"We are all idiots with deadlines."

  • Mike West
slide-24
SLIDE 24

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

slide-25
SLIDE 25

Principle of Least Privilege

slide-26
SLIDE 26

http://w3.org/TR/CSP11

slide-27
SLIDE 27

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

https://mkw.st/r/csp

slide-28
SLIDE 28
slide-29
SLIDE 29

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-30
SLIDE 30

Content-Security-Policy: default-src ...; script-src ...;

  • bject-src ...;

style-src ...; img-src ...; media-src ...; frame-src ...; font-src ...; connect-src ...; sandbox ...; report-uri https://example.com/reporter.cgi

slide-31
SLIDE 31

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-32
SLIDE 32

https://twitter.com/rwaldron/status/371801007829041153

slide-33
SLIDE 33

<script> function handleClick() { ... } </script> <button onclick="handleClick()">Click me!</button> <a href="javascript:handleClick()">Click me!</a>

slide-34
SLIDE 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); }

slide-35
SLIDE 35

Content-Security-Policy: script-src 'nonce-afbvjn+afpo-j1qer'; <button class="clckr">Click me!</button> <a href="#" class="clckr">Click me!</a> <script nonce="oafbvjn+afpo-j1qer"> function handleClick() { ... } function init() { var e; for (e in document.querySelectorAll('.clckr')) e.addEventListener('click', handleClick); } </script>

slide-36
SLIDE 36

`eval()` is evil?

slide-37
SLIDE 37

<iframe src="page.html" sandbox></iframe> <!-- * Unique origin * No plugins. * No script. * No form submissions. * No top-level navigation. * No popups. * No autoplay. * No pointer lock. * No seamless iframes.

  • ->
slide-38
SLIDE 38

<iframe src="page.html" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-top-navigation"> </iframe> <!-- * No plugins. * No seamless iframes.

  • ->
slide-39
SLIDE 39

<!-- User-generated content? (in The Near Future™) --> <iframe seamless srcdoc="<p>This is a comment!</p>" sandbox></iframe>

slide-40
SLIDE 40

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

goo.gl/WJjv10

slide-41
SLIDE 41

https://mkw.st/r/goto13

Thanks!

Mike West https://mikewest.org G+: mkw.st/+ Twitter: @mikewest Slides: https://mkw.st/r/goto13