Browsers Anti-XSS methods in ASP (classic) have been defeated!
This time, I want to start with the summary section first to break the rules!
The intention of this paper is to prove the client-side XSS protection methods must have rules for different web application languages, otherwise they will be bypassed. This research is based on ASP classic web applications, but it can be performed in other web application languages as well.
I researched different methods of sending inputs to an ASP (classic) page. I found out that almost all of the browsers’ Anti-XSS protection methods are not aware of different features of ASP that accept the inputs; therefore, all of them can be bypassed.
Note: NoScript has already added all of these rules to its application and it is more secure than the others currently (thanks to Giorgio Maone for patching the application as quickly as possible). IE9 has better sense about ASP than Google Chrome, but it does not still have all the rules.
In order to make you more interested, I will start with two examples:
Example 1: Do you think Anti-XSS methods should detect this easy XSS attack?
Please try it in IE8/9/10 and Google Chrome to see the result.
Example 2: What about this?
Example 3: Or, sometimes, the bypass can be complicated! This is how I solved my XSS1 and XSS2 questions with a single solution in SecProject.com Challenge Series 1:
As you see, I am only using 1 input parameter to bypass everything! (Note: this special page in xss1 converts “<” and “>” to “<” and “>” which was used to bypass NoScript as well – it is not a NoScript bug)
Why can you bypass XSS protections? I will tell you now.
Interesting ASP Input Features
1- HTTP Parameter Pollution (HPP): ASP is one of the web application languages which can receive several inputs with one single name. Although this feature was/is used legitimately in some of the web applications, it can be useful for attackers to bypass some restrictions as well .
2- Certain UTF-8 characters will be transformed to their ASCII equivalents , . It can be used in both of parameter names and their values. Therefore, “inPut1=<scriPt/>” is equal to “%u0131n%u2119ut1=%u3008scr%u0131%u2119t>”
3- Parameter names in ASP are not case sensitive. Therefore, “input1” is equal to “InPuT1”.
4- Anything after the Null character will be ignored in parameter names and their values. Therefore, “input1=test” is equal to “input1Something=testAnything”
5- Percentage characters (“%”) will be ignored when there is no Hex value after them in parameter names and their values. Therefore, “input1=test” is equal to “%input1%=t%%est%”
6- When a parameter name after the ampersand character (“&”) is not followed by an equal sign (“=”), ASP does not count it as a separate input. As a result, in “?&input1=test” the parameter name is “&input1”; or, in “?&input1&input1=test” the parameter name is “&input1&input1”.
Bypassing browsers Anti-XSS protections
Now we know many different interesting features of ASP. We can mix these features together to bypass the browsers protections which do not understand these rules. Please see the above examples again to identify the feature types which have been used.
Note 1: URL Encoding can be used in ASP to obfuscate the attack.
Note 3: Normally, a UTF-8 encoded string should have a lowercase “u”. Therefore, “%u0041” (which is “A”) is not equal to “%U0041” (which is “U0041”). However, sometimes server configurations can make these equal!
Note 4: If you have more than 1 input (multi-injection), reordering the input parameters may bypass the protections (input disorder method ).
Please let me know via twitter or email if you know or have found any other interesting features.
This research was based on ASP classic language. However, other languages such as PHP can be studied in the same way; for example, PHP ignores spaces before the parameter names and anything after the “” or a null character (“”) in the parameter names, or in PHP, space, dot, and a lone square-bracket characters (“ .[”) in parameter names will be converted to an underscore character (“_”).
If you like my blog, Please Donate Me