SlideShare a Scribd company logo
Client-side JavaScriptSecurity vulnerabilitiesThe Twilight Zone of Web Application Security Ory SegalSecurity Products Architect, Rational
ORY  SEGALSecurity products architect, RationalAppScan product managerWeb Application Security Consortium officerContributor (WASC, MITRE, NIST, OWASP)Renowned application security expertAppScan
From server to client side – The migration story of web application logic
1990<HTML>Capable of presenting only text and hyperlinks1993<IMG>Embedded images in web pages (3rd. Party allowed)1995<SCRIPT>JavaScript enables programmatic modifications to HTML1996<IFRAME>Embeds a page within a page (3rd party contents)<EMBED>Embed an Adobe Flash file for animation1999Client-side API (e.g. JS). Send & receive HTTP traffic programmatically, without refreshing the entire pageXHRFetch data asynchronously using XHR reducing the time spent waiting on page loads. Desktop app look & feelAJAX2005Canvas, Media, Offline storage, D&D, Geolocation, Local SQL, …HTML5 & APIs2011
Logic is Migrating from Server to Client…We counted server-side vs. client-side LoC in popular web applications in 2005 and in 2010
Client-side JavaScript Security Issues
DOM-Based Cross-site ScriptingA type of XSS (the third type after “Reflected” & “Stored”)Application doesn’t need to echo back user input like in Type I & Type IIWe poison a DOM element, which is used in JavaScript codeExamplehttp://www.vuln.site/welcome.html?name=Ory1:<HTML>2: <TITLE>Welcome!</TITLE>3:  Hi4:  <SCRIPT>5:    var pos = document.URL.indexOf("name=") + 5;6:    document.write(document.URL.substring(pos,document.URL.length));7:  </SCRIPT> <BR/>8:  Welcome to our system9:</HTML>Source	:	document.URLSink	:	document.write()Results	:	document.write("Ory")
DOM-Based Cross-site ScriptingAttack Examplehttp://www.vuln.site/welcome.html#?name=<script>alert('hacked')</script>1: <HTML>2: <TITLE>Welcome!</TITLE>3:  Hi4:  <SCRIPT>5:    var pos = document.URL.indexOf("name=") + 5;6:    document.write(document.URL.substring(pos,document.URL.length));7:  </SCRIPT> <BR/>8:  Welcome to our system9: </HTML>Source	: document.URLSink	: document.write()Results	: document.write("<script>alert('hacked')</script>")The attack took place entirely on the client-side (# fragment identifier)
Hacker controlled DOM elements may include:  document.URL, document.location, document.referrer, window.location, etc.Client-side Open RedirectJavaScript code automatically redirects the browser to a new locationNew location is taken from a DOM element (URL, Query, Referrer, etc.)Examplehttp://www.vuln.site/redirect.html?a=5&url=http://www.some.site...12: varsData = document.location.search.substring(1);13: varsPos = sData.indexOf("url=") + 4;14: varePos = sData.indexOf("&", sPos);15: varnewURL;16: if (ePos< 0) { newURL = sData.substring(sPos);} 17: else { newURL = sData.substring(sPos, ePos);}18:window.location.href = newURL;Source	: document.locationSink	: window.location.hrefResults	: window.location.href = "http://www.some.site";
Stored DOM-Based Cross-Site ScriptingExploiting HTML5 localStorage API...17: var pos = document.URL.indexOf("name=") + 5;18: varyourName = document.URL.substring(pos,document.URL.length)19: decodeURI(yourName);20: window.localStorage.name = yourName;21: }...welcomeregister...3: <div id="header"></div>4: <script>5:  varelem = document.getElementById("header");6:  varname = window.localStorage.name;7:  elem.innerHTML = "Hello, " + name;8: </script>...Source	: document.URLStorage	: window.localStorage.nameSink	: elem.innerHTMLResults	: elem.innerHTML = <value_of_name_parameter>
So, how common are client-side JavaScript issues?
(Lack of) Statistics on Client-Side JS IssuesTwo options for gathering statisticsAutomated discoveryManual discoveryAutomated toolsDynamic analysis tools only uncover ~30%Static analysis tools struggle with dynamic code (AJAX)Manual code review is hell – have you seen JavaScript lately?dojo._xdReset();if(dojo["_xdDebugQueue"]&&dojo._xdDebugQueue.length>0){dojo._xdDebugFileLoaded();}else{dojo._xdNotifyLoaded();}};dojo._xdNotifyLoaded=function(){for(var _99 in dojo._xdInFlight){if(typeofdojo._xdInFlight[_99]=="boolean"){return;}}dojo._inFlightCount=0;if(dojo._initFired&&!dojo._loadNotifying){dojo._callLoaded();}};if(typeof window!="undefined"){dojo.isBrowser=true;dojo._name="browser";(function(){var d=dojo;if(document&&document.getElementsByTagName){var _9a=document.getElementsByTagName("script");var _9b=/dojo(\.xd)?\.js(\W|$)/i;for(vari=0;i<_9a.length;i++){varsrc=_9a[i].getAttribute("src");if(!src){continue;}var m=src.match(_9b);if(m){if(!d.config.baseUrl){d.config.baseUrl=src.substring(0,m.index);}varcfg=_9a[i].getAttribute("djConfig");if(cfg){var _9c=eval("({ "+cfg+" })");for(var x in _9c){dojo.config[x]=_9c[x];}}break;}}}d.baseUrl=d.config.baseUrl;var n=navigator;vardua=n.userAgent,dav=n.appVersion,tv=parseFloat(dav);if(dua.indexOf("Opera")>=0){d.isOpera=tv;}if(dua.indexOf("AdobeAIR")>=0){d.isAIR=1;}d.isKhtml=(dav.indexOf("Konqueror")>=0)?tv:0;d.isWebKit=parseFloat(dua.split("WebKit/")[1])||undefined;d.isChrome=parseFloat(dua.split("Chrome/")[1])||undefined;d.isMac=dav.indexOf("Macintosh")>=0;var _9d=Math.max(dav.indexOf("WebKit"),dav.indexOf("Safari"),0);if(_9d&&!dojo.isChrome){d.isSafari=parseFloat(dav.split("Version/")[1]);if(!d.isSafari||parseFloat(dav.substr(_9d+7))<=419.3){d.isSafari=2;}}if(dua.indexOf("Gecko")>=0&&!d.isKhtml&&!d.isWebKit){d.isMozilla=d.isMoz=tv;}if(d.isMoz){d.isFF=parseFloat(dua.split("Firefox/")[1]||dua.split("Minefield/")[1])||undefined;}if(document.all&&!d.isOpera){d.isIE=parseFloat(dav.split("MSIE ")[1])||undefined;var _9e=document.documentMode;if(_9e&&_9e!=5&&Math.floor(d.isIE)!=_9e){d.isIE=_9e;}}if(dojo.isIE&&window.location.protocol==="file:") {dojo.config.ieForceActiveXXhr=true;}d.isQuirks=document.compatMode=="BackCompat";d.locale=dojo.config.locale||(d.isIE?n.userLanguage:n.language).toLowerCase();
Introducing JavaScript Security Analyzer
What is JSA?1st and only to auto-detect client-side issues such as:DOM-based XSSPhishing through Open RedirectHTML5 Notification API PhishingHTML5 Web Storage API PoisoningHTML5 Client-side SQL InjectionHTML5 Client-side Stored XSSHTML5 Web Worker Script URL ManipulationEmail Attribute Spoofing\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21asiudasdfiuashdofuiashdofuiashdfoiasuhdfoasuidfhoasdufhasodfuihasodfuihasodfiuhasdofiuahsdfouiashdfouashdfoasuidhfoasiudhfasoidf[‘epqwkrqpw9k45032452309450we09f9c90asdkf0q9wkerq2w34123aspasdfoiasdpfoiasjdfpoiasjdfpoaisjdfp;asoidfjas;dfoijasd;fioajsdf;ioasjdf;aosidfja;soidfjasd;fiajsdf;asijdf;asidfjas;dfiojasd;fijdsf;oaisjdf;asifdjas;difjas;dfioajsd;foiasjdf;iasojdf;asiodfjas;dfoijasoifjpasDE-OBFUSCATIONSTRING/* analysis */HTML5AnalysisHybrid
Using JavaScript Security AnalyzerZero configuration requiredSuper-simpleSuper-fast
16Viewing JSA Results in AppScan StandardAppScan Standard – Scan ResultsVulnerable URL and line of codeTainted data flow information
Lets try again…How common are client-side JavaScript issues?
Using JSA we ran a research on real sitesFortune 500175 Most popular sitesNon-obtrusive automated reviewManually verified resultsScary outcome…
14.5% Vulnerable169,443 Total Pages90,929 Unique Pages1659 Pages with VulnerabilitiesLikelihood for a web page to be vulnerable is  1 : 55
Who wrote these vulnerabilities?62%In house38%3rd PartyMarketing campaign JavaScript snippets
Flash embedding JavaScript snippets
Social networking JavaScript snippets
Deep linking JavaScript libraries for Flash and AJAX applicationsIssue DistributionDOM-based XSSOpen Redirect
JavaScript is becoming prominent Modern applications HTML5 AJAX Web2.0Application logic is shifting to client-sideMore code == more vulnerabilitiesHappens when code relies on parts of the DOM that are hacker-controlledDetection requires tedious manual workAppScan with JSA can automate client-side issues detection

More Related Content

What's hot (20)

PDF
Polyglot payloads in practice by avlidienbrunn at HackPra
Mathias Karlsson
 
PDF
Practical django secuirty
Andy Dai
 
PDF
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
bugcrowd
 
PDF
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
CODE BLUE
 
PDF
Bug Bounty Hunter Methodology - Nullcon 2016
bugcrowd
 
PPTX
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
PPTX
04. xss and encoding
Eoin Keary
 
PDF
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
PPT
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
PPT
(In)Security Implication in the JS Universe
Stefano Di Paola
 
PPTX
Preventing In-Browser Malicious Code Execution
Stefano Di Paola
 
PPTX
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
PDF
Integrity protection for third-party JavaScript
Francois Marier
 
PDF
Google chrome presentation
reza jalaluddin
 
PPTX
Make profit with UI-Redressing attacks.
n|u - The Open Security Community
 
PDF
Integrity protection for third-party JavaScript
Francois Marier
 
PPTX
W3 conf hill-html5-security-realities
Brad Hill
 
PPT
Same Origin Policy Weaknesses
kuza55
 
PDF
Flash умер. Да здравствует Flash!
Positive Hack Days
 
PDF
Defeating Cross-Site Scripting with Content Security Policy (updated)
Francois Marier
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Mathias Karlsson
 
Practical django secuirty
Andy Dai
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
bugcrowd
 
[CB16] 80時間でWebを一周:クロムミウムオートメーションによるスケーラブルなフィンガープリント by Isaac Dawson
CODE BLUE
 
Bug Bounty Hunter Methodology - Nullcon 2016
bugcrowd
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
CODE BLUE
 
04. xss and encoding
Eoin Keary
 
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
Django (Web Applications that are Secure by Default)
Kishor Kumar
 
(In)Security Implication in the JS Universe
Stefano Di Paola
 
Preventing In-Browser Malicious Code Execution
Stefano Di Paola
 
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
Integrity protection for third-party JavaScript
Francois Marier
 
Google chrome presentation
reza jalaluddin
 
Make profit with UI-Redressing attacks.
n|u - The Open Security Community
 
Integrity protection for third-party JavaScript
Francois Marier
 
W3 conf hill-html5-security-realities
Brad Hill
 
Same Origin Policy Weaknesses
kuza55
 
Flash умер. Да здравствует Flash!
Positive Hack Days
 
Defeating Cross-Site Scripting with Content Security Policy (updated)
Francois Marier
 

Viewers also liked (15)

PDF
Java script security for java developers
Johann-Peter Hartmann
 
PPTX
Testing web application firewalls (waf) accuracy
Ory Segal
 
PDF
JavaScript Security
Johann-Peter Hartmann
 
PPTX
Client & server side scripting
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Kyberterorismus a hacktivismus
Tereza Simandlová
 
PPTX
JavaScript Static Security Analysis made easy with JSPrime
Nishant Das Patnaik
 
PDF
Jsme vidět? Česká open access komunita
Tereza Simandlová
 
PPT
Exploiting Php With Php
Jeremy Coates
 
PPTX
App Retargeting and Re-engagement Success Stories
Vizury - Growth Marketing Platform
 
PPT
Client Side Exploits using PDF
n|u - The Open Security Community
 
PPTX
Client side exploits
nickyt8
 
PPTX
Zalora
vicksontan
 
KEY
How to break web applications
Dinis Cruz
 
PPT
WeChat
vicksontan
 
PDF
Alphorm.com Formation Hacking et Sécurité, l'essentiel
Alphorm
 
Java script security for java developers
Johann-Peter Hartmann
 
Testing web application firewalls (waf) accuracy
Ory Segal
 
JavaScript Security
Johann-Peter Hartmann
 
Client & server side scripting
baabtra.com - No. 1 supplier of quality freshers
 
Kyberterorismus a hacktivismus
Tereza Simandlová
 
JavaScript Static Security Analysis made easy with JSPrime
Nishant Das Patnaik
 
Jsme vidět? Česká open access komunita
Tereza Simandlová
 
Exploiting Php With Php
Jeremy Coates
 
App Retargeting and Re-engagement Success Stories
Vizury - Growth Marketing Platform
 
Client Side Exploits using PDF
n|u - The Open Security Community
 
Client side exploits
nickyt8
 
Zalora
vicksontan
 
How to break web applications
Dinis Cruz
 
WeChat
vicksontan
 
Alphorm.com Formation Hacking et Sécurité, l'essentiel
Alphorm
 
Ad

Similar to Client-side JavaScript Vulnerabilities (20)

PPT
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Shreeraj Shah
 
PPTX
Cross Site Scripting ( XSS)
Amit Tyagi
 
PPT
Pascarello_Investigating JavaScript and Ajax Security
amiable_indian
 
PPT
Browser Security
Roberto Suggi Liverani
 
PPT
Reversing JavaScript
Roberto Suggi Liverani
 
PPT
Hacking Web 2.0 - Defending Ajax and Web Services [HITB 2007 Dubai]
Shreeraj Shah
 
PDF
Secure java script-for-developers
n|u - The Open Security Community
 
PPT
4.Xss
phanleson
 
PDF
Dom XSS - Encounters of the 3rd Kind (Bishan Singh Kochher)
ClubHack
 
PPT
CTS Conference Web 2.0 Tutorial Part 2
Geoffrey Fox
 
PPT
Krug Fat Client
Paul Klipp
 
PDF
Html5 security
tsinghua university
 
PPT
Lessons from the Trenches: Engineering Great AJAX Experiences
goodfriday
 
PPT
Lessons
guest1019f4
 
PDF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Mark Stanton
 
PPTX
Java Script - A New Look
rumsan
 
PDF
Ajax tutorial
Kat Roque
 
PPTX
Dom XSS: Encounters of the3rd kind
Bishan Singh
 
PDF
25 Million Flows Later – Large-scale Detection of DOM-based XSS
Ben Stock
 
PPTX
Web security: Securing Untrusted Web Content in Browsers
Phú Phùng
 
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Shreeraj Shah
 
Cross Site Scripting ( XSS)
Amit Tyagi
 
Pascarello_Investigating JavaScript and Ajax Security
amiable_indian
 
Browser Security
Roberto Suggi Liverani
 
Reversing JavaScript
Roberto Suggi Liverani
 
Hacking Web 2.0 - Defending Ajax and Web Services [HITB 2007 Dubai]
Shreeraj Shah
 
Secure java script-for-developers
n|u - The Open Security Community
 
4.Xss
phanleson
 
Dom XSS - Encounters of the 3rd Kind (Bishan Singh Kochher)
ClubHack
 
CTS Conference Web 2.0 Tutorial Part 2
Geoffrey Fox
 
Krug Fat Client
Paul Klipp
 
Html5 security
tsinghua university
 
Lessons from the Trenches: Engineering Great AJAX Experiences
goodfriday
 
Lessons
guest1019f4
 
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Mark Stanton
 
Java Script - A New Look
rumsan
 
Ajax tutorial
Kat Roque
 
Dom XSS: Encounters of the3rd kind
Bishan Singh
 
25 Million Flows Later – Large-scale Detection of DOM-based XSS
Ben Stock
 
Web security: Securing Untrusted Web Content in Browsers
Phú Phùng
 
Ad

Recently uploaded (20)

PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
Reimaginando la Ciberdefensa: De Copilots a Redes de Agentes
Cristian Garcia G.
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
Practical Applications of AI in Local Government
OnBoard
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 

Client-side JavaScript Vulnerabilities

  • 1. Client-side JavaScriptSecurity vulnerabilitiesThe Twilight Zone of Web Application Security Ory SegalSecurity Products Architect, Rational
  • 2. ORY SEGALSecurity products architect, RationalAppScan product managerWeb Application Security Consortium officerContributor (WASC, MITRE, NIST, OWASP)Renowned application security expertAppScan
  • 3. From server to client side – The migration story of web application logic
  • 4. 1990<HTML>Capable of presenting only text and hyperlinks1993<IMG>Embedded images in web pages (3rd. Party allowed)1995<SCRIPT>JavaScript enables programmatic modifications to HTML1996<IFRAME>Embeds a page within a page (3rd party contents)<EMBED>Embed an Adobe Flash file for animation1999Client-side API (e.g. JS). Send & receive HTTP traffic programmatically, without refreshing the entire pageXHRFetch data asynchronously using XHR reducing the time spent waiting on page loads. Desktop app look & feelAJAX2005Canvas, Media, Offline storage, D&D, Geolocation, Local SQL, …HTML5 & APIs2011
  • 5. Logic is Migrating from Server to Client…We counted server-side vs. client-side LoC in popular web applications in 2005 and in 2010
  • 7. DOM-Based Cross-site ScriptingA type of XSS (the third type after “Reflected” & “Stored”)Application doesn’t need to echo back user input like in Type I & Type IIWe poison a DOM element, which is used in JavaScript codeExamplehttp://www.vuln.site/welcome.html?name=Ory1:<HTML>2: <TITLE>Welcome!</TITLE>3: Hi4: <SCRIPT>5: var pos = document.URL.indexOf("name=") + 5;6: document.write(document.URL.substring(pos,document.URL.length));7: </SCRIPT> <BR/>8: Welcome to our system9:</HTML>Source : document.URLSink : document.write()Results : document.write("Ory")
  • 8. DOM-Based Cross-site ScriptingAttack Examplehttp://www.vuln.site/welcome.html#?name=<script>alert('hacked')</script>1: <HTML>2: <TITLE>Welcome!</TITLE>3: Hi4: <SCRIPT>5: var pos = document.URL.indexOf("name=") + 5;6: document.write(document.URL.substring(pos,document.URL.length));7: </SCRIPT> <BR/>8: Welcome to our system9: </HTML>Source : document.URLSink : document.write()Results : document.write("<script>alert('hacked')</script>")The attack took place entirely on the client-side (# fragment identifier)
  • 9. Hacker controlled DOM elements may include: document.URL, document.location, document.referrer, window.location, etc.Client-side Open RedirectJavaScript code automatically redirects the browser to a new locationNew location is taken from a DOM element (URL, Query, Referrer, etc.)Examplehttp://www.vuln.site/redirect.html?a=5&url=http://www.some.site...12: varsData = document.location.search.substring(1);13: varsPos = sData.indexOf("url=") + 4;14: varePos = sData.indexOf("&", sPos);15: varnewURL;16: if (ePos< 0) { newURL = sData.substring(sPos);} 17: else { newURL = sData.substring(sPos, ePos);}18:window.location.href = newURL;Source : document.locationSink : window.location.hrefResults : window.location.href = "http://www.some.site";
  • 10. Stored DOM-Based Cross-Site ScriptingExploiting HTML5 localStorage API...17: var pos = document.URL.indexOf("name=") + 5;18: varyourName = document.URL.substring(pos,document.URL.length)19: decodeURI(yourName);20: window.localStorage.name = yourName;21: }...welcomeregister...3: <div id="header"></div>4: <script>5: varelem = document.getElementById("header");6: varname = window.localStorage.name;7: elem.innerHTML = "Hello, " + name;8: </script>...Source : document.URLStorage : window.localStorage.nameSink : elem.innerHTMLResults : elem.innerHTML = <value_of_name_parameter>
  • 11. So, how common are client-side JavaScript issues?
  • 12. (Lack of) Statistics on Client-Side JS IssuesTwo options for gathering statisticsAutomated discoveryManual discoveryAutomated toolsDynamic analysis tools only uncover ~30%Static analysis tools struggle with dynamic code (AJAX)Manual code review is hell – have you seen JavaScript lately?dojo._xdReset();if(dojo["_xdDebugQueue"]&&dojo._xdDebugQueue.length>0){dojo._xdDebugFileLoaded();}else{dojo._xdNotifyLoaded();}};dojo._xdNotifyLoaded=function(){for(var _99 in dojo._xdInFlight){if(typeofdojo._xdInFlight[_99]=="boolean"){return;}}dojo._inFlightCount=0;if(dojo._initFired&&!dojo._loadNotifying){dojo._callLoaded();}};if(typeof window!="undefined"){dojo.isBrowser=true;dojo._name="browser";(function(){var d=dojo;if(document&&document.getElementsByTagName){var _9a=document.getElementsByTagName("script");var _9b=/dojo(\.xd)?\.js(\W|$)/i;for(vari=0;i<_9a.length;i++){varsrc=_9a[i].getAttribute("src");if(!src){continue;}var m=src.match(_9b);if(m){if(!d.config.baseUrl){d.config.baseUrl=src.substring(0,m.index);}varcfg=_9a[i].getAttribute("djConfig");if(cfg){var _9c=eval("({ "+cfg+" })");for(var x in _9c){dojo.config[x]=_9c[x];}}break;}}}d.baseUrl=d.config.baseUrl;var n=navigator;vardua=n.userAgent,dav=n.appVersion,tv=parseFloat(dav);if(dua.indexOf("Opera")>=0){d.isOpera=tv;}if(dua.indexOf("AdobeAIR")>=0){d.isAIR=1;}d.isKhtml=(dav.indexOf("Konqueror")>=0)?tv:0;d.isWebKit=parseFloat(dua.split("WebKit/")[1])||undefined;d.isChrome=parseFloat(dua.split("Chrome/")[1])||undefined;d.isMac=dav.indexOf("Macintosh")>=0;var _9d=Math.max(dav.indexOf("WebKit"),dav.indexOf("Safari"),0);if(_9d&&!dojo.isChrome){d.isSafari=parseFloat(dav.split("Version/")[1]);if(!d.isSafari||parseFloat(dav.substr(_9d+7))<=419.3){d.isSafari=2;}}if(dua.indexOf("Gecko")>=0&&!d.isKhtml&&!d.isWebKit){d.isMozilla=d.isMoz=tv;}if(d.isMoz){d.isFF=parseFloat(dua.split("Firefox/")[1]||dua.split("Minefield/")[1])||undefined;}if(document.all&&!d.isOpera){d.isIE=parseFloat(dav.split("MSIE ")[1])||undefined;var _9e=document.documentMode;if(_9e&&_9e!=5&&Math.floor(d.isIE)!=_9e){d.isIE=_9e;}}if(dojo.isIE&&window.location.protocol==="file:") {dojo.config.ieForceActiveXXhr=true;}d.isQuirks=document.compatMode=="BackCompat";d.locale=dojo.config.locale||(d.isIE?n.userLanguage:n.language).toLowerCase();
  • 14. What is JSA?1st and only to auto-detect client-side issues such as:DOM-based XSSPhishing through Open RedirectHTML5 Notification API PhishingHTML5 Web Storage API PoisoningHTML5 Client-side SQL InjectionHTML5 Client-side Stored XSSHTML5 Web Worker Script URL ManipulationEmail Attribute Spoofing\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21asiudasdfiuashdofuiashdofuiashdfoiasuhdfoasuidfhoasdufhasodfuihasodfuihasodfiuhasdofiuahsdfouiashdfouashdfoasuidhfoasiudhfasoidf[‘epqwkrqpw9k45032452309450we09f9c90asdkf0q9wkerq2w34123aspasdfoiasdpfoiasjdfpoiasjdfpoaisjdfp;asoidfjas;dfoijasd;fioajsdf;ioasjdf;aosidfja;soidfjasd;fiajsdf;asijdf;asidfjas;dfiojasd;fijdsf;oaisjdf;asifdjas;difjas;dfioajsd;foiasjdf;iasojdf;asiodfjas;dfoijasoifjpasDE-OBFUSCATIONSTRING/* analysis */HTML5AnalysisHybrid
  • 15. Using JavaScript Security AnalyzerZero configuration requiredSuper-simpleSuper-fast
  • 16. 16Viewing JSA Results in AppScan StandardAppScan Standard – Scan ResultsVulnerable URL and line of codeTainted data flow information
  • 17. Lets try again…How common are client-side JavaScript issues?
  • 18. Using JSA we ran a research on real sitesFortune 500175 Most popular sitesNon-obtrusive automated reviewManually verified resultsScary outcome…
  • 19. 14.5% Vulnerable169,443 Total Pages90,929 Unique Pages1659 Pages with VulnerabilitiesLikelihood for a web page to be vulnerable is 1 : 55
  • 20. Who wrote these vulnerabilities?62%In house38%3rd PartyMarketing campaign JavaScript snippets
  • 23. Deep linking JavaScript libraries for Flash and AJAX applicationsIssue DistributionDOM-based XSSOpen Redirect
  • 24. JavaScript is becoming prominent Modern applications HTML5 AJAX Web2.0Application logic is shifting to client-sideMore code == more vulnerabilitiesHappens when code relies on parts of the DOM that are hacker-controlledDetection requires tedious manual workAppScan with JSA can automate client-side issues detection
  • 25. Q & A
  • 26. Thank YouYou can download the full whitepaper at:http://tinyurl.com/5w6koqj