« Defeating input filters for injection | Main | Cross-Site Scripting (User Agent Injection) Attack Methods »
Friday
May042007

DOM Injection Attacks

Besides the classic Cross-Site Scripting where the playload moves to the server and back, there is another form of user agent injection attacks, which does not depend on the payload to be embedded in the response, but rather on thepayload in the Document Object Model (DOM). The DOM is the standard object model in browsers to represent HTML documents and meta data in an object-oriented way, whichis provided to the JavaScript code. The most important object is the document object, which not only includes all elements from the HTML document, but also meta-objects,such as URL, URLUnencoded, location (also in window.location) or referrer, which contain the complete URL of the current document or the referring one, respectively. There aremany web applications that access the DOM, and a few parse the meta-objects mentioned above, which makes them vulnerable to DOM-based injection, as in http://www.webappsec.org/projects/articles/071105.html. Here is an example of avulnerable script, which is supposed to extract the user's name from the document's URL (by searching for "name=" and returning the string after it):
 
Hello <script> var pos = document.URL.indexOf("name=")+5;

document.write(document.URL.substring(pos,document.URL.length));
</script>

Do not think that everyone enters his real name like Joe or Alice, take a look at this user name:

http://www.domain.com/welcome?name=
<script>alert(document.cookie)</script>

And if the server filters the parameter name, then xyzname will not be filtered, but the script in the document will use the first occurence:
 
http://www.domain.com/welcome?xyzname=
<script>alert(document.cookie)</script>&name=Alice
 
Notice the number sign (#) here, it is usually used to refer to a part of a document and never sent to the server, so any server-side checks will have no effect, but the local script will use the malicious code nevertheless.
 
http://www.domain.com/welcome#name=
<script>alert(document.cookie)</script>
 
To be continued ... 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (349)

Thank you again. Frankly I had only heard of this type of attack recently and find it quite intriguing.

May 4, 2007 | Unregistered CommenterJames H

[...] If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!http://www.rorsecurity.info/2007/05/04/dom-injection-attacks/ [...]

Lovely. Made my day (which is saying something)

June 2, 2007 | Unregistered Commenterbe debt free

What a nice site, been surfing on it for the whole night and day and i neva got bored for a single minute. Keep up your good work and all of the best in everything you do! :-)

This is a great web site. I have some great web pages myself if you are interested to share. But I should not go on about my site too much, that is not fair, right?

Very exceptional pieces of information. Very nice webpage though. I applaud

June 3, 2007 | Unregistered Commenterconstruction loan

I just want you to know that I think you did a terrific job on this websight.

Howdy! Great site. Great content. Great! I can recommend this site to others!

Ich finde Ihre Homepage sehr gut und fundiert. Die Informationen helfen mir bei einer Diplomarbeit für den Bereich der Medizinischen Dokumentation vielen Dank und weiter so.

perfect site !!!!!!!! Perfect piece of work fellows !!!!!!!

June 4, 2007 | Unregistered Commenterguide

This is such a wonderful and informative way to reach others. I Will be more than glad to share this site

I like your website I will share this with friends

Nice website. Great online affiliate program. Thank you.

June 5, 2007 | Unregistered Commentertablet

I dont even remember how i reached your site but it doesnt matter, cause i'm so happy i found it, it really made me think, keep up the good work

June 6, 2007 | Unregistered Commentercasino promotion

Thank you for opening a wonderfully new sight..I wish you the best of luck with your new venture.

June 7, 2007 | Unregistered Commenterzyrtec d

Thank you for the great web site - a true resource, and one many people clearly enjoy

Lovely to see such a wonderful site. Thank you

Just stopped by to visit and got the crunch on your stuff in here - bravo!

interesting site

June 9, 2007 | Unregistered Commenterinsurance rates

Hi there, I must say that you have done a wonderful job on your site and I thoroughly enjoyed my stay here, I thank you for sharing it with me…

June 10, 2007 | Unregistered Commentercash till payday

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>