Web Application Firewalls Detection, Bypassing And Exploitation

31
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 Web Application Firewalls: Detection, Bypassing and Exploitation Sandro Gauci and Wendel Guglielmetti Henrique EnableSecurity and Trustwave [email protected] December 2nd, 2009 Friday, 4 December 2009

description

A presentation and demonstration of issues that apply to Web application firewalls. Talks about how easy it is to fingerprint some web application firewalls, how bypassing them is possible. Finally it talks about how they can be used against your organization if they get compromised.

Transcript of Web Application Firewalls Detection, Bypassing And Exploitation

Page 1: Web Application Firewalls  Detection, Bypassing And Exploitation

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

Web Application Firewalls: Detection, Bypassing and Exploitation

Sandro Gauci and Wendel Guglielmetti HenriqueEnableSecurity and [email protected]

December 2nd, 2009

Friday, 4 December 2009

Page 2: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP 2

$ whois WendelGH

PT Consultant at Trustwave's SpiderLabsOver 7 years in the security industryVulnerability discovery Webmails, AP, Citrix, etcSpoke in YSTS 2.0, Defcon 16, H2HC and othersAffiliated to Hackaholic team

Friday, 4 December 2009

Page 3: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP 3

$ whois SandroGauci

Founder and CSO EnableSecurityFrom .mtSecurity software

VOIPPACK (CANVAS addon)Surfjack - insecure cookiesSIPVicious

Security research papersBeen around for > 9 years

Friday, 4 December 2009

Page 4: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Introduction

WAF - Web Application Firewallnext generation protectionwhat can we do?

can be identified, detectedbypassing the rulesexploit WAFs

4

Friday, 4 December 2009

Page 5: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

What is WAF?

Attack signatures or abnormal behavior basedWAFs products: software or hardware appliance. Flavors:

a reverse proxyembeddedconnected in a switch (SPAN or RAP)

WAF products detect both inboundSome also detect outbound attacks

5

Friday, 4 December 2009

Page 6: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Who uses WAFs?

Many banks around the worldCompanies which need high protectionMany companies in compliance with PCI DSS

(Payment Card Industry - Data Security Standard)

6

Friday, 4 December 2009

Page 7: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Operation Modes

Negative model (blacklist based)Positive model (whitelist based)Mixed / Hybrid

7

Friday, 4 December 2009

Page 8: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

The negative model

Relies on a database of known attacksEg. XSS strings like <script>, </script>,

String.fromCharCode, etc.Often regular expressions

8

Friday, 4 December 2009

Page 9: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Whitelist model

Whitelist basedLearning mode to create a security policy of

known “good” HTTP trafficKnown as dynamic profiling technology by some

Example:Page news.jsp, the field "id" only accept numbers [0-9] and starting at 0 until 65535news.jsp?id=-1 would not be allowed

9

Friday, 4 December 2009

Page 10: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Common Weaknesses

Design issuesWAFs have to be similar to the web apps and http

servers that they need to protectBlacklists are by design “flawed”

Bad implementationParsing issues

Again - a WAF needs to do a lot of things that the web app and http server doesergo they can have similar security flaws!

10

Friday, 4 December 2009

Page 11: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Detection

A number of products can be detectedsometimes by design

Detection is not a big deal but... sometimes we’re told that WAFs are ‘invisible’the better you know your enemy (or client), the

betterhelps in a penetration test or targeted attackshows that stealth attacks are possible

11

Friday, 4 December 2009

Page 12: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Detection

CookiesReason: some WAFs are also load balancers

HeadersHeader rewriting Most obvious would be "Server" Sometimes is a feature called “server cloaking”“Connection” header might be changed to Cneonction

or nnCoectionResponse codes

404 error codes for existent scriptsand 403 for non existent ones

12

Friday, 4 December 2009

Page 13: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Detection via response codes

404 error codes for existent scriptsDifferent error codes (404, 400, 401, 403, 501,

etc) for hostile parameters (even non existent ones) in valid pages.

13

Friday, 4 December 2009

Page 14: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 15: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 16: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Automating WAF detection

WAFW00FDetect 20 different WAF products

the number keeps changing thanks to contributions :-)

Options to detect multiple WAFs in placeGeneric detection methods included!

Get your copywaffit.googlecode.comPlease contribute

16

Friday, 4 December 2009

Page 17: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 18: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Bypassing a WAF

Fingerprint the rulesDetect allowed / denied stringsCombinations of allowed or denied stringsModify your attack to not match the blacklist

18

Friday, 4 December 2009

Page 19: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

More on bypassing WAFs

Encoding and language support, character setsSpaces, comments, case sensitive mutation,

Unicode (%uc0af and %c0%af), etcThe web server may parse, decode and interpret

and HTTP request differently from the WAFHTML and JS is very flexibleVarious methods to split and encode your strings

19

Friday, 4 December 2009

Page 20: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Bypassing rules

“Our Favorite XSS Filters and how to Attack Them” by Eduardo Vela & David LindsayBypass the rules by splitting the attack

(eval('al'%2b'lert(0)')“Shocking News in PHP Exploitation” by Stefan

EsserUsing “malformed” multipart/form-data to bypass

most Modsecurity rulesF5 BIG-IP ASM could be bypassed by sending it

multipart/form-data that was interpreted differently by PHP than ASM

20

Friday, 4 December 2009

Page 21: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP 21

Friday, 4 December 2009

Page 22: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

The positive model

It’s well known that the negative model is broken

What about positive model? They are really secure?If we find a positive model should we give up?

22

Friday, 4 December 2009

Page 23: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 24: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Testing WAFs for bypasses is a tedious job

Which is why we automate it :-)WAFFUN - works in progress

Checks if the script echos back (esp in the case of xss)

Can check if error suppression is supportedFinds out how the WAF responds when a it reacts to

an attackGoes through a list of well known blacklisted stringsIf any were blocked, it tries different encoding

methods, null characters, unicode

24

Friday, 4 December 2009

Page 25: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 26: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

WAFFUN: XSS constructor

Tries a number of tags to find out which are allowed through

Tries a number of DHTML event handlersTries a number of Javascript methods

26

Friday, 4 December 2009

Page 27: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP 27

Friday, 4 December 2009

Page 28: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

WAFs may be vulnerable too!

Security software is not necessarily secureWeb Application specific issues: XSS, SQLiOverflowsDoS

28

Friday, 4 December 2009

Page 29: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Known issues

ModSecurity 2.5.9addresses 2 vulnerabilities

"Fixed PDF XSS issue where a non-GET request for a PDF file would crash the Apache httpd process."

"Fixed parsing multipart content with a missing part header name which would crash Apache."

Profense 2.6.3Profense Web Application Firewall Cross-Site Scripting

and Cross-Site Request ForgeryDotDefender 3.8-5 (this week)

Command Execution in dotDefender Site Management (requires authentication) seems like it is vulnerable to XSRF 29

Friday, 4 December 2009

Page 30: Web Application Firewalls  Detection, Bypassing And Exploitation

Friday, 4 December 2009

Page 31: Web Application Firewalls  Detection, Bypassing And Exploitation

OWASP

Thank you

Do you have ideas / resources to improve our tools?

wsguglielmetti [em] gmail [ponto] comsandro [em] enablesecurity [ponto] comQuestions?

31

Friday, 4 December 2009