« XSS Countermeasures | Main | DOM Injection Attacks »
Friday
May042007

Defeating input filters for injection

Especially malicious input in URLs will look suspicious to someonewho has heard of these attacks, or at least to a security scanner. So an attacker will try to hide suspicious parts from the victim or the security scanner. For a human being thiscan be as easy as displaying a tidy link as an image, but in fact the image is linked to a malicious URL. Or the malicious part can be hidden in a very long URL where it does notstrike. When it comes to automatic scanners, the attacker has to use different technologies. If the web applications filter does not remove all HTML tags fromthe input data, but uses a blacklist filter, the attacker might use the following alternatives to the <script> tag, which work in most web browsers:
 
  • <<script> (if the scanner filters <script> and does comparison of the string inside the first matching bracket pairs)
  • <scrscriptipt> (bypasses scanners that remove the word script)
  • <script/src=... (bypasses scanners that look for <script> or <script xsrc=...)
  • <script a=">" " xsrc=... (bypass a scanner which allows <script>, but not <script xsrc=...)
  • or put a line feed after each character (works in Internet Explorer 6.0)
There are many more possibilities, and you have to take other tags into account, suchas <img>, <table>, <a>, or event handlers (on...). More examples are found at http://ha.ckers.org/xss.

Another very effective way to hide angle brackets or other characters from a security scanner is to use a different character encoding that the web browser might be able to process,but the web application might not. There are a lot of possibilities to encode characters, but of course the browser has to be set to read the document in the encoding. If the encoding is set to Auto-Select in Internet Explorer andthere is an UTF-7 or -8 encoded string in the first 4096 bytes, it will automatically treat the document as UTF-7 or -8.
 
If the user has set this option and/or the web application does not send a default character encoding, as it is the case with Railsapplications by default, cryptic UTF-8 encoded strings like the following will pop up a message box, if injected.
 
<IMG xsrc=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;
&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;
&#39;&#41;>
 
And if the user has set his browser to UTF-7 encoding, injecting the following will pop up a message box. Note that it does not include any angle brackets, so it might bypassfilters that look for them.

+ADw-SCRIPT+AD4-alert('vulnerable');+ADw-/SCRIPT+AD4-

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (249)

Quite interesting. Thank you for writing this up.

May 4, 2007 | Unregistered CommenterJames H

hbrcyvfi slhnia jcbh rkjmegnsh iszweo kiblyjq fzvxky

May 21, 2007 | Unregistered Commenterhfyd fgbskwo

I have been looking for sites like this for a long time. Thank you!



May 24, 2007 | Unregistered Commenterzyprexa

This is

June 5, 2007 | Unregistered CommenterNervin

Adderall....

June 15, 2007 | Unregistered CommenterAdderall.

Phentermine....

June 16, 2007 | Unregistered CommenterPhentermine.

Cialis....

June 17, 2007 | Unregistered CommenterCialis.

Diazepam buy diazepam buy diazepam online pharmacy. Buy diazepam news....

July 15, 2007 | Unregistered CommenterBuy diazepam.

Buy xanax without prescription in usa. Buy cheap xanax without prescription....

Phentermine diet pills. Phentermine diet pills di....

Valium liquid form....

July 16, 2007 | Unregistered CommenterValium liquid form.

Ultram. Canada pharmacy buy online ultram. Ultram tramadol. Ultram abuse. Side effects of ultram....

July 16, 2007 | Unregistered CommenterUltram tramadol.

Ambien generic available. Generic ambien. Is there a generic form of ambien....

Generic ambien....

Duration of oral diazepam. Duration of diazepam. Diazepam onset and duration....

July 16, 2007 | Unregistered CommenterDuration of diazepam.

Adipexdrug addiction order phentermine online....

Buy tramadol online save wholesale price yep. Buy tramadol. Tramadol hci online buy cheap tramadol hci online....

July 17, 2007 | Unregistered CommenterBuy tramadol.

Buy sublingual levitra online....

Viagra generic 25mg no prescription. Generic viagra. Generic lavitra offers an alternative to viagra....

July 17, 2007 | Unregistered CommenterGeneric viagra.

Buy cialis online viagra cialis buy cialis online. Cialis best price buy online. Buy viagra online uk cialis levitra....

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>