toStaticHTML: The Second Encounter (CVE-2012-1858)
The following post describes the second bypass I found to the toStaticHTML function in IE - back in 2012.
Introduction:
The toStaticHTML component, which is found in Internet Explorer > 8, SharePoint and Lync is used to sanitize HTML fragments from dynamic and potentially malicious content.
If an attacker is able to break the filtering mechanism and pass malicious code through this function, he/she may be able to perform HTML injection based attacks (i.e. XSS).
It has been a year since the first encounter was published, I though I give it another go.
Vulnerability:
An attacker is able to create a specially formed CSS entity that will overcome toStaticHTML's security logic; therefore, after passing the specially crafted CSS string through the toStaticHTML function, it will contain an expression that triggers a JavaScript call.
The following JavaScript code demonstrates the vulnerability (splitted into multi lines for readability):
<script>document.write(toStaticHTML("<style>
div{font-family:rgb('0,0,0)'''}foo');color=expression(alert(1));{}
</style><div>POC</div>"))</script>
In this case the function's return value would be JavaScript executable:
<style>div{font-family:rgb('0,0,0)''';}foo');color=expression(alert(1));{;}</style><div>POC</div>
The reason this code bypasses the filter engine is due to two reasons:
The filtering engine allows the string "expression(" to exists in "non-dangerous" locations within the CSS.
A bug in Internet Explorer's CSS parsing engine doesn't properly terminate strings that are opened inside a function. The only way to truly terminate them is to have an quote sign immediately followed by a closing bracket ')
When combining these two factors the attacker is able to "confuse" the filtering mechanism into "thinking" that a string is open when in fact it is terminated and vice versa. With this ability the attacker can trick the filtering mechanism into entering a state of the selector context which is considered safer where in fact the code is just a new declaration of the same selector, thus breaking the state machine and bypassing the filter.
Impact:
Every application that relies on the toStaticHTML component to sanitize user supplied data had probably been vulnerable to XSS.
Remediation:
Microsoft has issued several updates to address this vulnerability.
An old post from 2012. Originally published under Watchfire's (IBM) Blog
Discovered by - Adi Cohen, IBM Application Security Research
Recent Posts
See AllBackground AMP is most commonly used as a framework to develop fast-loading content on the web. One of AMP's projects, AMP4Email has been...
The following post describes a new method to exploit injections in JSON file - Back in 2012 Introduction: In the world of Web2.0 and mash...
The following post describes the second bypass I found to the toStaticHTML function in IE - back in 2012. Introduction: The Microsoft...
Opmerkingen