Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Client-side JavaScript Vulnerabilities

34.402 visualizaciones

Publicado el

Automatically detecting client side JavaScript vulnerabilities using IBM Rational AppScan and JavaScript Security Analyzer (hybrid analysis)

Publicado en: Tecnología
  • ➤➤ How Long Does She Want You to Last? Here's the link to the FREE report ♥♥♥
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • nice
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • I guess I don't understand. You can manually execute any javascript from the client anyway just by typing 'javascript:{...}' in the address bar of any modern browser and the webkit browsers have a console where you can type and execute your own javascript commands, so if one wanted to call APIs from his own client, he could easily do it without js injection....

    I guess someone could create a malicious link as in the examples, but http could be configured not to run cross domains so you can't extract any information from any http request. Most sites require authentication before you access sensitive information anyway, so for the 'attack' to have any effect you would have to be logged in in one tab and then click on a link in another that redirects you back to a hacked page on the first, which would be a strange thing to do.
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • FYI - JSA has been improved greatly recently, and now actually located that 40% of the F500 web sites are actually vulnerable!
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí

Client-side JavaScript Vulnerabilities

  1. 1. Client-side JavaScript<br />Security vulnerabilities<br />The Twilight Zone of Web Application Security <br />Ory Segal<br />Security Products Architect, Rational<br />
  2. 2. ORY SEGAL<br />Security products architect, Rational<br />AppScan product manager<br />Web Application Security Consortium officer<br />Contributor (WASC, MITRE, NIST, OWASP)<br />Renowned application security expert<br />AppScan<br />
  3. 3. From server to client side – The migration story of web application logic<br />
  4. 4. 1990<br /><HTML><br />Capable of presenting only text and hyperlinks<br />1993<br /><IMG><br />Embedded images in web pages (3rd. Party allowed)<br />1995<br /><SCRIPT><br />JavaScript enables programmatic modifications to HTML<br />1996<br /><IFRAME><br />Embeds a page within a page (3rd party contents)<br /><EMBED><br />Embed an Adobe Flash file for animation<br />1999<br />Client-side API (e.g. JS). Send & receive HTTP traffic programmatically, without refreshing the entire page<br />XHR<br />Fetch data asynchronously using XHR reducing the time spent waiting on page loads. Desktop app look & feel<br />AJAX<br />2005<br />Canvas, Media, Offline storage, D&D, Geolocation, Local SQL, …<br />HTML5 & <br />APIs<br />2011<br />
  5. 5. Logic is Migrating from Server to Client…<br />We counted server-side vs. client-side LoC in popular web applications in 2005 and in 2010<br />
  6. 6. Client-side JavaScript Security Issues <br />
  7. 7. DOM-Based Cross-site Scripting<br />A type of XSS (the third type after “Reflected” & “Stored”)<br />Application doesn’t need to echo back user input like in Type I & Type II<br />We poison a DOM element, which is used in JavaScript code<br />Example<br /><br />1:<HTML>2: <TITLE>Welcome!</TITLE>3: Hi4: <SCRIPT>5: var pos = document.URL.indexOf("name=") + 5;<br />6: document.write(document.URL.substring(pos,document.URL.length));<br />7: </SCRIPT> <BR/>8: Welcome to our system<br />9:</HTML><br />Source : document.URL<br />Sink : document.write()<br />Results : document.write("Ory")<br />
  8. 8. DOM-Based Cross-site Scripting<br />Attack Example<br /><script>alert('hacked')</script><br />1: <HTML>2: <TITLE>Welcome!</TITLE>3: Hi4: <SCRIPT>5: var pos = document.URL.indexOf("name=") + 5;<br />6: document.write(document.URL.substring(pos,document.URL.length));<br />7: </SCRIPT> <BR/>8: Welcome to our system<br />9: </HTML><br />Source : document.URL<br />Sink : document.write()<br />Results : document.write("<script>alert('hacked')</script>")<br /><ul><li>The attack took place entirely on the client-side (# fragment identifier)
  9. 9. Hacker controlled DOM elements may include: document.URL, document.location, document.referrer, window.location, etc.</li></li></ul><li>Client-side Open Redirect<br />JavaScript code automatically redirects the browser to a new location<br />New location is taken from a DOM element (URL, Query, Referrer, etc.)<br />Example<br /><br />...<br />12: varsData =;<br />13: varsPos = sData.indexOf("url=") + 4;<br />14: varePos = sData.indexOf("&", sPos);<br />15: varnewURL;<br />16: if (ePos< 0) { newURL = sData.substring(sPos);} <br />17: else { newURL = sData.substring(sPos, ePos);}<br />18:window.location.href = newURL;<br />Source : document.location<br />Sink : window.location.href<br />Results : window.location.href = "";<br />
  10. 10. Stored DOM-Based Cross-Site Scripting<br />Exploiting HTML5 localStorage API<br />...<br />17: var pos = document.URL.indexOf("name=") + 5;<br />18: varyourName = document.URL.substring(pos,document.URL.length)<br />19: decodeURI(yourName);<br />20: = yourName;<br />21: }<br />...<br />welcome<br />register<br />...<br />3: <div id="header"></div><br />4: <script><br />5: varelem = document.getElementById("header");<br />6: varname =;<br />7: elem.innerHTML = "Hello, " + name;<br />8: </script><br />...<br />Source : document.URL<br />Storage :<br />Sink : elem.innerHTML<br />Results : elem.innerHTML = <value_of_name_parameter><br />
  11. 11. So, how common are client-side JavaScript issues?<br />
  12. 12. (Lack of) Statistics on Client-Side JS Issues<br />Two options for gathering statistics<br />Automated discovery<br />Manual discovery<br />Automated tools<br />Dynamic analysis tools only uncover ~30%<br />Static analysis tools struggle with dynamic code (AJAX)<br />Manual code review is hell – have you seen JavaScript lately?<br />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;}}<br />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)<br />{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,<br />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)<br />{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();<br />
  13. 13. Introducing JavaScript Security Analyzer<br />
  14. 14. What is JSA?<br />1st and only to auto-detect client-side issues such as:<br />DOM-based XSS<br />Phishing through Open Redirect<br />HTML5 Notification API Phishing<br />HTML5 Web Storage API Poisoning<br />HTML5 Client-side SQL Injection<br />HTML5 Client-side Stored XSS<br />HTML5 Web Worker Script URL Manipulation<br />Email Attribute Spoofing<br />x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x2x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21x48x65x6Cx6Cx6Fx20x57x6Fx72x6Cx64x21asiudasdfiuashdofuiashdofuiashdfoiasuhdfoasuidfhoasdufhasodfuihasodfuihasodfiuhasdofiuahsdfouiashdfouashdfoasuidhfoasiudhfasoidf[‘epqwkrqpw9k45032452309450we09f9c90asdkf0q9wkerq2w34123aspasdfoiasdpfoiasjdfpoiasjdfpoaisjdfp;asoidfjas;dfoijasd;fioajsdf;ioasjdf;aosidfja;soidfjasd;fiajsdf;asijdf;asidfjas;dfiojasd;fijdsf;oaisjdf;asifdjas;difjas;dfioajsd;foiasjdf;iasojdf;asiodfjas;dfoijasoifjpas<br />DE-OBFUSCATION<br />STRING<br />/* analysis */<br />HTML5<br />Analysis<br />Hybrid<br />
  15. 15. Using JavaScript Security Analyzer<br />Zero configuration required<br />Super-simple<br />Super-fast<br />
  16. 16. 16<br />Viewing JSA Results in AppScan Standard<br />AppScan Standard – Scan Results<br />Vulnerable URL and line of code<br />Tainted data flow information<br />
  17. 17. Lets try again…How common are client-side JavaScript issues?<br />
  18. 18. Using JSA we ran a research on real sites<br />Fortune 500<br />175 Most popular sites<br />Non-obtrusive automated review<br />Manually verified results<br />Scary outcome…<br />
  19. 19. 14.5% Vulnerable<br />169,443 Total Pages<br />90,929 Unique Pages<br />1659 Pages with Vulnerabilities<br />Likelihood for a web page to be vulnerable is 1 : 55 <br />
  20. 20. Who wrote these vulnerabilities?<br />62%<br />In house<br />38%<br />3rd Party<br /><ul><li>Marketing campaign JavaScript snippets
  21. 21. Flash embedding JavaScript snippets
  22. 22. Social networking JavaScript snippets
  23. 23. Deep linking JavaScript libraries for Flash and AJAX applications</li></li></ul><li>Issue Distribution<br />DOM-based XSS<br />Open Redirect<br />
  24. 24. JavaScript is becoming prominent <br />Modern applications HTML5 AJAX Web2.0<br />Application logic is shifting to client-side<br />More code == more vulnerabilities<br />Happens when code relies on parts of the DOM that are hacker-controlled<br />Detection requires tedious manual work<br />AppScan with JSA can automate client-side issues detection<br />
  25. 25. Q & A<br />
  26. 26. Thank You<br />You can download the full whitepaper at:<br /> <br />