Friday, 27 April 2012
HTML5
One of the hottest topics among the members of web and security communities is HTML5. Lately, we've been getting a lot of requests from our customers regarding the ability to scan HTML5 applications with our static analysis products. Everyone wants to say that they've done something to secure their HTML5 apps, but few know what that actually means. I think the problem stems from the fact that HTML5 spec is not even complete, and yet the browsers already provide implementations for the proposed features. Plus, HTML5 isn't a completely new language – it's a collection of new features that present themselves through new HTML tags and attributes, JavaScript APIs, and HTTP headers.
In this post I won't go into detailed analysis of HTML5 security, but I would like to say that in my opinion the most sensitive areas of this new technology are going to be Cross-Origin Resource Sharing (CORS) policy that allows for communication between scripts running on different domains and client-side storage. We've already seen evidence that this can be abused in two alarming ways: storing sensitive information insecurely and storing code that gets eval'ed without proper sanitization. The latter is especially problematic when an application also contains a vulnerability that allows an attacker to inject malicious code into the client-side storage.
There are a number of other HTML5 features that I think will have a lot of security ramifications, such as cross-origin messaging, web sockets, file system APIs, as well as various others. However, I do not know whether anyone is using these primitives right now. What I do know is that the two features I mentioned above are already being used and abused. As it was pointed out here, there are already several cases of applications using local storage code caching with one of the scripts vulnerable to reflected XSS seen in the wild. On the other hand, according to the HP ESP’s 2011 Top Cyber Security Risks Report, 5% of sampled applications are CORS-enabled, and 75% of them allow any domain to be able to communicate to scripts running on their domains.
Going back to the question of statically scanning HTML5 applications for security vulnerabilities, I'd like to point out that it's not trivial. Mostly due to the dynamic nature of JavaScript: doing dataflow analysis on callbacks and anonymous functions is a challenge. Nevertheless, we have begun to address some of the relevant features in one of our older releases, and our next rulepack update will contain support for CORS and client-side storage, and potentially others. So, stay tuned.







