We recently covered the most up-to-date list of OWASP Top 10 vulnerabilities. In subsequent future posts, we’ll be discussing some of those more prominent vulnerabilities in a little more depth. Starting with cross-site scripting (XSS), the common cold of security vulnerabilities.
XSS is a type of injection attack, which is another finding on the OWASP Top 10 vulnerabilities list. XSS involves injecting malicious code into a website that would otherwise appear harmless (e.g., a popular news site). Once a user navigates to this website, the site performs an action on the user's behalf without their knowledge. This client-side code can perform any action the user can in the affected application's domain within the user's web browser. (To see an example of this in action, check out our advisory on high-risk vulnerabilities in the Big Monitoring Fabric application. The XSS vulnerability could allow an unauthenticated remote attacker administrative access in the application.)
To better imagine XSS, think of a rental car. You rent the car and then do something strange to it before you return it to the car rental agency. If the agency neglects to do their due diligence before the car goes out to another customer, that customer will suffer as a result. This is similar to XSS in that if the app server doesn’t do “contextual output encoding” when the inputs cross trust boundaries, all visitors for that page are potentially affected.
Now, let’s sharpen our lens on XSS a little more.
Reflected XSS (aka Nonpersistent)
This is one of the most common forms of XSS out there. It occurs when malicious code is “reflected” unaltered from a web application executing in a user’s browser. In other words, that malicious code is reflected – or contained – in the application's response to the malicious requests. Users often are enticed to click a malicious link via phishing, and once they click, the exploit unfolds.
Stored XSS (aka Persistent)
Stored XSS means that the malicious code is stored within the application; whenever a user navigates to the affected webpage, the script will execute. So instead of targeting a single potential victim – everyone who navigates to that affected webpage could be compromised too (and imagine how disastrous that could be for a high-profile website.) Of all the XSS varieties thus far, this one has the ability to inflict the most damage.
This strain of XSS occurs in the document object model (DOM); it’s not apparently visible in the HTML. The primary difference of this XSS from its counterparts is the malicious client-side code is not visible within the application's response. Exploitation of this XSS works in the same manner as the other varieties; attackers would generally attempt to steal user sessions, force actions on their behalf, or perform a host of malicious client-side actions.
Try Burp Suite Professional or XSS Hunter. While you’ll find a great deal of “XSS scanners” online, a lot of them are nothing more than snake oil. Your two best options to scan for XSS vulnerabilities will be the tried-and-true Burp Suite Professional or the tool XSS Hunter.
Conduct a Penetration Test. We may be biased, but the gold-standard method to prevent XSS attacks is to work with a third-party vendor to perform a penetration test. This way, you’ll receive a comprehensive list of the vulnerabilities contained within your application.
As far as prevention goes, you can do the following to ensure your application stays as secure as it can within reason:
XSS vulnerabilities are extremely common among applications. But not all is lost, if you follow the tips and best practices we’ve outlined here, you can prevent many of these attacks and protect your users.
Any suggestions for the next OWASP Top 10 vulnerability we explain? Let us know - @bishopfox on Twitter, #AttacksExplained. Special thanks to Chris Davis!