59
1 Web Insecurity and Browser Exploitation ught to you by Michele “AntiSnatch ù and Integrat Web LTD 20th January 2009

Web Insecurity And Browser Exploitation

Embed Size (px)

DESCRIPTION

A 2 hour seminar in Munich, 20th January 2010

Citation preview

Page 1: Web Insecurity And Browser Exploitation

1

Web Insecurity and

Browser Exploitation

brought to you by Michele “AntiSnatchOr” Orrù and Integrating Web LTD

20th January 2009

Page 2: Web Insecurity And Browser Exploitation

Who am I?

Director and CSO of Integrating Web LTD

Bachelor Degree in Internet Sciences

Owner of http://antisnatchor.com security advisory blog

JEE developer

Outl

ine

2 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 3: Web Insecurity And Browser Exploitation

Seminar outline

Sem

inar

ou

tlin

e

3 of 59

http://www.integratingweb.com

Discuss the most relevant SANS top 25 errors that concern Web Applications

Practical demonstrations of some vulnerable Real World web applications (my totally independent security research)

Understand the impact of these threats on the most valuable web-app assets

Practical screen-casts that show how attackers exploit common flows

Browser exploitation discussion

http://antisnatchor.com

Page 4: Web Insecurity And Browser Exploitation

What we will discuss:

CWE-20: Improper Input Validation CWE-116: Improper Encoding or Escaping

of Output CWE-209: Error Message Information Leak CWE-89: Failure to Preserve SQL Query

Structure (SQL injection) CWE-79: Failure to Preserve Web Page

Structure (XSS) CWE-352: Cross-Site Request Forgery

(XSRF)

What

we w

ill d

iscu

ss

4 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 5: Web Insecurity And Browser Exploitation

CWE-20: Improper

Input Validation

The biggest issue on today’s Internet Applications (not just Web Applications)

Improper Input Validation can lead to security vulnerabilities when attackers can modify input in unexpected ways for the application

The only way to protect our applications is by understanding that all input can be malicious C

WE-2

0:

Imp

roper

Inpu

t Valid

ati

on

5 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 6: Web Insecurity And Browser Exploitation

CWE-20: Example 8e6 R3000 Internet Filter (commercial

HTTP(S) Proxy filter solution)

CW

E-2

0:

Exam

ple

6 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 7: Web Insecurity And Browser Exploitation

Credits: nnposter DNS based website blacklist can be

bypassed by providing a forged request with a custom HTTP header

Http request:

GET / HTTP/1.1

X-DecoyHost: www.milw0rm.orgHost: www.blocked.org

CW

E-2

0:

Exam

ple

7 of 59

http://www.integratingweb.com

CWE-20: Example

http://antisnatchor.com

Page 8: Web Insecurity And Browser Exploitation

CWE-20: Mitigation

Understand every potential attack areas: parameters, arguments, cookies, headers, files, database queries...

Whitelist approach instead of blacklist (you are certainly going to miss some character encoding variants)

WebApp case: use a WebApp Firewall (ModSecurity/F5) or an Input Validation Framework for your language.

CW

E-2

0:

Mit

igati

on

8 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 9: Web Insecurity And Browser Exploitation

CWE-20: Mitigation

ModSecurity

CW

E-2

0:

Mit

igati

on w

ith

M

od

Secu

rity

9 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 10: Web Insecurity And Browser Exploitation

CWE-20:MITIGATION OWASP ESAPI A common set of interfaces for

security controls such as:

Authentication Access Control Input Validation Output Encoding Cryptography Error handling/logging

CW

E-2

0:M

ITIG

ATIO

N O

WA

SP

ES

API

10 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 11: Web Insecurity And Browser Exploitation

CWE-20: MITIGATION

PHPIDS

Input validation framework for PHP based applications

Developed by skilled hackers (Mario Heiderich - .mario on sla.ckers.org)

Try their demo with your nasty attack vectors here: http://demo.php-ids.org

Integrated as a module in Drupal, works with the powerful Zend Framework (http://forum.php-ids.org/comments.php?DiscussionID=113) C

WE-2

0:

MIT

IGATIO

N P

HPID

S

11 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 12: Web Insecurity And Browser Exploitation

CWE-116: Improper

Encoding/Escaping of Output

Insufficient output encoding is the often-ignored sibling to poor input validation

Even if input has been filtered, application output could not be safe: it need to be encoded too

Common examples: HTML/JavaScript injection on web based applications

CW

E-1

16:

Imp

rop

er

En

codin

g o

f O

utp

ut

12 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 13: Web Insecurity And Browser Exploitation

CWE-116: Example Eclipse BIRT (reporting system that

integrates with Java/JEE applications)

CW

E-1

16:

Exam

ple

13 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 14: Web Insecurity And Browser Exploitation

Credits: antisnatchor [http://antisnatchor.com/2008/12/18/eclipse-birt-reflected-xss]

Java Exception stack trace was not HTML-encoded, so we can inject an iframe

GET/birt-viewer/run?__report='"><iframe

%20src=javascript:alert(666)>&r=-703171660 HTTP/1.1

Host: localhost:8780 Our code was executed correctly in

the application output

CW

E-1

16:

Exam

ple

14 of 59

http://www.integratingweb.com

CWE-116: Example

http://antisnatchor.com

Page 15: Web Insecurity And Browser Exploitation

CWE-116: Mitigation

Always encode Java stack traces (better to don’t show them to prevent Information Leakage)

Always encode application output, especially if it contains previously user-supplied input

WebApp firewall and ESAPI/PHPIDS (you lazy developers :-))

CW

E-1

16:

Mit

igati

on

15 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 16: Web Insecurity And Browser Exploitation

CWE-209: Error Message

Information Leak Chatty or debug error messages could disclose important important information to attackers

This information is used in the Penetration Testing phase called “Reconnaissance”

Even these little secrets can greatly

simplify a more concerted attack that yields much bigger rewards

CW

E-2

09:

Err

or

Mess

ag

e

Info

rmati

on L

eak

16 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 17: Web Insecurity And Browser Exploitation

CWE-209: Examples

1. www.dm.unibo.it

Credits: antisnatchor MySQL error when forging a malicious

request altering the anno parameter

GET /seminari/archivio.php?anno=2008%27 HTTP/1.1

Host: www.dm.unibo.it[...]Accept-Charset: ISO-8859-1,utf-

8;q=0.7,*;q=0.7Keep-Alive: 300Proxy-Connection: keep-aliveCookie: dm=[...] CW

E-2

09:

ww

w.d

m.u

nib

o.it

17 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 18: Web Insecurity And Browser Exploitation

Application response:

CW

E-2

09:

ww

w.d

m.u

nib

o.it

18 of 59

http://www.integratingweb.comCWE-209: Examples

1. www.dm.unibo.it

Causing an SQL syntax error we discovered that the DB backend is MySQL

We can now run more targeted attacks

http://antisnatchor.com

Page 19: Web Insecurity And Browser Exploitation

Credits: antisnatchor Session Management was (IS actually)

broken and can be manipulated If we are the hacker riding the victim’s

session, and the victim then logout from Uniwex, his session (and ours, because is the same) is invalidated.

If we invalidate a session and then we try to submit the previously “invalid” session token... MAGICALLY ...

CW

E-2

09:

unib

o.u

nib

o.it

19 of 59

http://www.integratingweb.com

CWE-209: Examples

2. uniwex.unibo.it

http://antisnatchor.com

Page 20: Web Insecurity And Browser Exploitation

CW

E-2

09:

unib

o.u

nib

o.it

20 of 59

http://www.integratingweb.comCWE-209: Examples

2. uniwex.unibo.it

http://antisnatchor.com

Page 21: Web Insecurity And Browser Exploitation

The JSP page /unique/UniqueNewException.jsp is clearly leaved there for debug purposes

It shouldn’t be there in production!!! This revealed us that Tomcat is used as

Application Server, and we’ve also obtained the specific version of a few frameworks on which the application was built:

/home/unimatica/uniwex/uniwexng-4.4.0/WEB-INF/lib/struts-

1.1.jar /home/unimatica/uniwex/uniwexng-4.4.0/WEB-INF/lib/

myfaces-api-1.1.4.jar

CW

E-2

09:

unib

o.u

nib

o.it

21 of 59

http://www.integratingweb.comCWE-209: Examples

2. uniwex.unibo.it

http://antisnatchor.com

Page 22: Web Insecurity And Browser Exploitation

CWE-89: SQL Injection

These days most software is all about the data and how it can be served to maximize user and business needs

The most common storage solution is a Relational Database(Oracle, MySQL, Postgres, MS-SQL, Sybase)

If attackers can influence the SQL that you use to communicate with your database, then they can do nasty things for fun and profit

CW

E-8

9:

SQ

L In

ject

ion

22 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 23: Web Insecurity And Browser Exploitation

CWE-89: SQL InjectionExploiting escape characters:"SELECT * FROM customers WHERE name= '" + customerName+ "';"

If customerName = marcus’ UNION SELECT 1,2,3,4 FROM admin_users;

Then the final query becomes: SELECT * FROM customers WHERE name='marcus’ UNION SELECT 1,2,3,4 FROM

admin_users;

Exploiting type handling:"SELECT * FROM product_data WHERE product_id = " + productId + ";"

If productId = 10078;DROP TABLE admin_users

Then the final query becomes:SELECT * FROM product_data WHERE product_id =10078;DROP TABLE admin_users;

CW

E-8

9:

SQ

L In

ject

ion

23 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 24: Web Insecurity And Browser Exploitation

Discovering which web application parameters/cookie/headers are querying the DB, we can test if input is properly escaped or not

The previous example on www.dm.unibo.it demonstrates that input is not being escaped at all

After we discovered the SQL injection we can fire-up our favorite injection tool to retrieve useful information

CW

E-8

9:

SQ

L In

ject

ion

24 of 59

http://www.integratingweb.com

CWE-89: SQL Injection

http://antisnatchor.com

Page 25: Web Insecurity And Browser Exploitation

CWE-89:Example

1. www.dm.unibo.it Credits: antisnatchor

Confirmed unescaped numeric injection on GET parameter “anno”

We were able to obtain details about the application stack: Apache 2.2.3, PHP 5.2.0, MySQL >= 5.0

For demonstration we retrieved the exact name of the database name to which the web app is bounded: dipartimento

CW

E-8

9:

ww

w.d

m.u

nib

o.it

25 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 26: Web Insecurity And Browser Exploitation

CW

E-8

9:

ww

w.d

m.u

nib

o.it

26 of 59

http://www.integratingweb.com http://antisnatchor.com

Screen-Castwww.dm.unibo.it

Page 27: Web Insecurity And Browser Exploitation

CWE-89:Example

2. www.virtus.it Credits: antisnatchor Confirmed unescaped numeric

injection on GET parameter “ID” (SPNewsDettaglio.asp)

We were able to obtain details about the application stack: Microsoft IIS 6, ASP and SQL Server 2000

We retrieved the exact name of the database name to which the web app is bounded: ServizioNews (and a few tables too) C

WE-8

9:

ww

w.v

irtu

s.it

27 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 28: Web Insecurity And Browser Exploitation

CWE-89: Mitigation

Implement a validation framework (previously discussed) to protect your application

Use stored procedures Hibernate on JEE, NHibernate on .NET DB specific: Oracle DBMS_ASSERT

directive, MySQL real_escape_string() function

Use a whitelist approach, permitting only “known good input”

CW

E-8

9:

Mit

igati

on

28 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 29: Web Insecurity And Browser Exploitation

CWE-89: Dangers

As you can see SQL injection can be devastating for the integrity of your data

Data loss is probably the most negative consequence for an Enterprise

If the web application (most of them, if not all) is storing web page content inside the DB, we can deface the site too

CW

E-8

9:

Dang

ers

29 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 30: Web Insecurity And Browser Exploitation

CW

E-8

9:

Lin

ks

30 of 59

http://www.integratingweb.com

Links

http://antisnatchor.com

Good books: http://www.amazon.co.uk/Web-Application-Hackers-Handbook-Discovering/dp/

0470170778/ref=sr_1_1?ie=UTF8&s=books&qid=1260264977&sr=8-1 http://www.amazon.com/Database-Hackers-Handbook-Defending-Servers/dp/

0764578014/ref=sr_1_2?ie=UTF8&s=books&qid=1260281547&sr=8-2 http://www.amazon.com/Web-Security-Testing-Cookbook-Systematic/dp/

0596514832/ref=sr_1_3?ie=UTF8&s=books&qid=1260281547&sr=8-3 SQLmap author: http://www.slideshare.net/inquis/sql-injection-not-only-and-11

Page 31: Web Insecurity And Browser Exploitation

CWE-79: The Plague ofCross Site Scripting We can inject JavaScript, HTML, VBscript or

other browser-executable content into pages generated by the application

The page is then accessed by other users, whose browsers execute that malicious script as if it came from the legitimate user (the victim)

It always happen when a server-side script/servlet/whatever process the malicious data to generate a page without properly sanitizing the response (non-DOM-based XSS)

CW

E-7

9:

The P

lag

ue o

f C

ross

Sit

e

Scr

ipti

ng

31 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 32: Web Insecurity And Browser Exploitation

CWE-79: Examples

1. www.cia.gov

CW

E-7

9:

ww

w.c

ia.g

ov

32 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 33: Web Insecurity And Browser Exploitation

CWE-79: Examples2.

portal.hotspotsvankpn.com

CW

E-7

9:

port

al.h

ots

pots

vankp

n.c

om

33 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 34: Web Insecurity And Browser Exploitation

CWE-79: Mitigation

A real world case example: Apache OFBiz implementation of ESAPI toolkit.

After my JIRA issue they started to take really care of security (I’m glad to)

See http://fisheye6.atlassian.com/changelog/ofbiz?cs=746409 and http://antisnatchor.com/2008/12/11/apache-ofbiz-multiple-security-vulnerabilities

CW

E-7

9:

Mit

igati

on

34 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 35: Web Insecurity And Browser Exploitation

CWE-79: Mitigation

The changes of StringUtil.java class:

CW

E-7

9:

Mit

igati

on

35 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 36: Web Insecurity And Browser Exploitation

CWE-79: Mitigation

The changes of ModelScreenWidget.java class:

CW

E-7

9:

Mit

igati

on

36 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 37: Web Insecurity And Browser Exploitation

CWE-79: Mitigation

Validate every parameter/cookie/header/input that can be manipulated by a potential attacker and then displayed on the page

Do not create your own filters: you’ll probably miss some attack vectors or encodings

Use well known Encoding/Validation frameworks such as ESAPI,PHPIDS,Microsoft Anti-XSS (yes, Microsoft, don’t laugh please :-)) C

WE-7

9:

Mit

igati

on

37 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 38: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts

Bypassing anti-XSS filters As we said many times before, we don’t recommend

to write an anti-XSS filter from scratch At CERN they usually develop application from

scratch, like Indico (http://indico.cern.ch). Indico is the main solution used by the EGEE partners around Europe (many thousand of users)

We found a way to bypass a basic anti-XSS filter implemented in the application

Bracelets (< >) are correctly escaped with &lt; and &gt;, thus preventing almost all the attack vectors……

CW

E-7

9:

Advance

d c

on

cep

ts

38 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 39: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts

Bypassing anti-XSS filters ….. We said almost because we can create attack vectors even

without bracelets:

http://indico.cern.ch/search.py?categId=0&p=cloud&f=title%22&collections=&startDate=&endDate=&sortOrder=d

The rendered HTML after processing the request is the following:<form id="NextFormEvents" method="GET"

action="http://indico.cern.ch/search.py"> <input type="hidden" name="startDate" value=""/> <input type="hidden" name="endDate" value=""/> <input type="hidden" name="p" value="cloud"/> <input type="hidden" name="f" value="title""/> <!-- <-- here is

the problem --> <input type="hidden" name="collections" value="Events"/> <input type="hidden" name="categId" value="0" /></form>

CW

E-7

9:

Advance

d c

on

cep

ts

39 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 40: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts Bypassing anti-XSS filters

The following is working on Microsoft Internet Explorer 6 and 7:

"style%3d"width: expression(alert('XSS'));"

The malicious code will add to the "input" element a "style" attribute: note that expression is understood only by IE.

The rendered HTML after processing the request is the following:<form id="NextFormEvents" method="GET"

action="http://indico.cern.ch/search.py"> <input type="hidden" name="startDate" value=""/> <input type="hidden" name="endDate" value=""/> <input type="hidden" name="p" value="cloud"/> <input type="hidden" name="f" value="title” style=“width:

expression(alert('XSS'));”/> <input type="hidden" name="collections" value="Events"/> <input type="hidden" name="categId" value="0" /></form>

CW

E-7

9:

Advance

d c

on

cep

ts

40 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 41: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts

XSS proxiesForcing the victim to load a malicious

Javascript code (with XSS/social engineering), we can open an AJAX communication that can talk cross-domain

CW

E-7

9:

Advance

d c

on

cep

ts

41 of 59

http://www.integratingweb.com http://antisnatchor.com

Image Copyright: Ferruh Mavituna

Page 42: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts

CW

E-7

9:

Advance

d c

on

cep

ts

42 of 59

http://www.integratingweb.com http://antisnatchor.com

XSS tunnelingHaving an Inter-protocol communication

channel (such as in the example before) we can basically tunnel HTTP traffic into it.

Applications that supports HTTP proxies (vulnerability scanners for example) can be proxified…

Thanks to tunneling the attacks made with a proxified vulnerability scanner will be generated in fact by the victim browser

Page 43: Web Insecurity And Browser Exploitation

CWE-79: Advanced concepts

XSS tunnels: tunneling a vulnerability scanner

CW

E-7

9:

Advance

d c

on

cep

ts

43 of 59

http://www.integratingweb.com http://antisnatchor.com

Image Copyright: Ferruh Mavituna

Page 44: Web Insecurity And Browser Exploitation

CWE-79: Example1. KonaKart

CW

E-7

9:

KonaK

art

44 of 59

http://www.integratingweb.com http://antisnatchor.com

Credits: antisnatchor KonaKart is a free Java based web

application to manage e-commerce websites (www.konakart.com)

Stored XSS has been found and verified in the backend

More info here: http://antisnatchor.com/2008/12/22/konakart-2260-responsible-disclosure/

Let see how we can exploit them

Page 45: Web Insecurity And Browser Exploitation

CW

E-7

9:

KonaK

art

45 of 59

http://www.integratingweb.com http://antisnatchor.com

Screen-CastKonaKart

Page 46: Web Insecurity And Browser Exploitation

CWE-79: Examples2. WMSmonitor

CW

E-7

9:

WM

Sm

onit

or

46 of 59

http://www.integratingweb.com http://antisnatchor.com

Credits: antisnatchor Internal Penetration Test at INFN (National

Institute of Nuclear Physics) Workload Management System (distribute

job execution between multiple Computing Elements on a Grid infrastructure) monitor

Some serious flows have been identified Unsecure handling of X.509 client certificates Reflected XSS TRACE method enabled

Let see how can we take full control of the victim browser

Page 47: Web Insecurity And Browser Exploitation

CW

E-7

9:

WM

Sm

onit

or

47 of 59

http://www.integratingweb.com http://antisnatchor.com

Screen-CastWMSmonitor

Page 48: Web Insecurity And Browser Exploitation

CW

E-7

9:

Links

48 of 59

http://www.integratingweb.com http://antisnatchor.com

Links Wade Alcorn’s works:

BeEF: http://www.bindshell.net/tools/beef/ Inter-Protocol Exploitation: http://www.bindshell.net/papers/ipe The Advanced Cross-Site Scripting Virus:

http://www.bindshell.net/papers/axssv

Rsnake & al. works: XSS cheat sheet: http://ha.ckers.org/xss.html XSS proxies: http://ha.ckers.org/blog/20060718/attacking-applications-via-xss-proxies/ http://xss-proxy.sourceforge.net/shmoocon-XSS-Proxy.ppt XSS tunneling: http://www.portcullis-security.com/uplds/whitepapers/XSSTunnelling.pdf XSS worm context: http://ha.ckers.org/blog/20080106/diminutive-xss-worm-contest-

drama-and-status-update/

AntiSnatcOr works research: Advisories on SecurityFocus:

http://antisnatchor.com/2009/10/14/finally-on-bugtraq/

Page 49: Web Insecurity And Browser Exploitation

CW

E-7

9:

Links

49 of 59

http://www.integratingweb.com http://antisnatchor.com

Links

Good books: http://www.amazon.co.uk/Web-Application-Hackers-Handbook-Discovering/dp/

0470170778/ref=sr_1_1?ie=UTF8&s=books&qid=1260264977&sr=8-1 http://www.amazon.com/XSS-Attacks-Scripting-Exploits-Defense/dp/1597491543/

ref=sr_1_4?ie=UTF8&s=books&qid=1260281547&sr=8-4 http://www.amazon.com/Web-Security-Testing-Cookbook-Systematic/dp/

0596514832/ref=sr_1_3?ie=UTF8&s=books&qid=1260281547&sr=8-3 http://www.amazon.com/Hacking-Next-Generation-Animal-Guide/dp/

0596154577/ref=sr_1_1?ie=UTF8&s=books&qid=1263982791&sr=8-1

Page 50: Web Insecurity And Browser Exploitation

CWE-352: Cross Site

Request Forgery It exploits the trust that a website has for the currently authenticated user and executes unwanted actions on a web application on his behalf

Once the request gets to the application, it looks as if it came from the user, not the attacker

If the victim has admin privileges on the application: GAME OVER

CW

E-3

52:

Cro

ss S

ite R

eq

uest

Fo

rgery

50 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 51: Web Insecurity And Browser Exploitation

CWE-352: XSRF Concrete

Consequences Performing illegal actions such as using victim's shopping cart, executing stock trades

Changing DNS settings of home routers (thanks pdp & GNUCITIZEN)

Performing a Denial Of Service attack on the application

Combining it with XSS to build WORMS

CW

E-3

52:

XS

RF

Concr

ete

C

on

sequ

en

ces

51 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 52: Web Insecurity And Browser Exploitation

1. Find a page with a lost-password form inside and find out which fields would be updated

2. Trick the administrator to load the hacker page with a malicious request on it that submits a new email

3. Administrator's e-mail is now changed to the email submitted by hacker

4. The hacker performs a lost-password request and receives a new password

CW

E-3

52:

XS

RF

Concr

ete

C

on

sequ

en

ces

52 of 59

http://www.integratingweb.com

CWE-352: XSRF Concrete

Consequences (I)

http://antisnatchor.com

Page 53: Web Insecurity And Browser Exploitation

1. Find a router that doesn’t use cookies or URL tokens to identify the user session on the web management interface (most of them)

Ex.: http://192.168.1.1/changeDNS?dns=1.2.3.4

2. Just send the link to the victim with a bit of social engineering (or embedding it for auto-execution in places you know the victim will access)

3 The victim is now using your chosen DNS, where you probably altered her common used domains with your phishing ones

CW

E-3

52:

XS

RF

Concr

ete

C

on

sequ

en

ces

53 of 59

http://www.integratingweb.com

CWE-352: XSRF Concrete Consequences

(II)

http://antisnatchor.com

Page 54: Web Insecurity And Browser Exploitation

CWE-352: XSRFWho has been vulnerable?

ING direct [We discovered CSRF vulnerabilities in ING's site that allowed an attacker to open additional accounts on behalf of a user and transfer funds from a user's account to the attacker's account.]

Youtube New York Times Gmail

[http://directwebremoting.org/blog/joe/2007/01/01/csrf_attacks_or_how_to_avoid_

exposing_your_gmail_contacts.html]

CW

E-3

52

: X

SR

F W

ho h

as

been

vu

lnera

ble

?

54 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 55: Web Insecurity And Browser Exploitation

CWE-352: XSRF

1. Apache OFBiz Read my advisory here: https://issues.apache.org/jira/browse/OFBIZ-1959

We can create a malicious form that will add a product (eventually with some JS inside) to the Catalog

If the victim is already authenticated she will not even realize what she did

CW

E-3

52:

Ap

ach

e O

FBiz

55 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 56: Web Insecurity And Browser Exploitation

<form method="POST" id="xsrf" name="xsrf"

action="https://127.0.0.1:8443/catalog/control/createProduct">

<input type=hidden name="isCreate" value="true">

<input type=hidden name="productId" value="hack02">

<input type=hidden name="productTypeId" value="DIGITAL_GOOD">

<input type=hidden name="internalName" value="hack02<script>alert(document.cookie)</script>">

</form>

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

CW

E-3

52:

Ap

ach

e O

FBiz

56 of 59

http://www.integratingweb.comCWE-352: XSRF

1. Apache OFBiz

http://antisnatchor.com

Page 57: Web Insecurity And Browser Exploitation

CWE-352: XSRF

Mitigation• Add a unique randomly-generated token to each

request (maybe as an hidden form value): this n bit token is changed for every request and is verified by the application

<input id="fkey" name="fkey" type="hidden" value="df8652852f139" />

• Use a secure framework such as ESAPI to add random token to your requests

• Implement AJAX functionalities with secure libraries such as DWR-2.0 (Direct Web Remoting) that automatically prevents XSRF CW

E-3

52:

XS

RF

Mit

igati

on

57 of 59

http://www.integratingweb.com http://antisnatchor.com

Page 58: Web Insecurity And Browser Exploitation

Bro

wse

r Exp

loit

ati

on

58 of 59

http://www.integratingweb.com http://antisnatchor.com

Browser Exploitation discussion

1. Google and China, Internet Explorer bugs

2. ScreenCast: Browser Exploitation

with BeEF and Metasploit

Page 59: Web Insecurity And Browser Exploitation

Thanks for your attention!

Take a look at: http://antisnatchor.com

Quest

ions?

59 of 59

http://www.integratingweb.com http://antisnatchor.com