My favorites | Sign in
Project Home Wiki
Search
for
FindingDOMXSS  
This page lists ways to find and analyze DOMXSS vulnerabilities
Updated Apr 28, 2011 by Mario.He...@gmail.com

Finding DOMXSS

DOMXSS vulnerabilities are rather hard to find by using classic techniques such as scanners and black box testing methods.

Luckily the tester usually has full access to the JavaScript sources to apply a source code audit and use simple techniques to get an overview on where possible sources and sinks hide in the analyzed files.

One of the easiest methods to use is to just apply several regular expressions to the sources and have a look at the results. Most editors provide a way to use regular expressions as search pattern and will show the results highlighted very nicely so the tester can navigate from finding to finding and have a more detailed look if the possible sources and sinks can be exploited.

Regular Expressions

Finding Sources

The following regular expression attempts to match most common DOMXSS sources (BETA):

/(location\s*[\[.])|([.\[]\s*["']?\s*(arguments|dialogArguments|innerHTML|write(ln)?|open(Dialog)?|showModalDialog|cookie|URL|documentURI|baseURI|referrer|name|opener|parent|top|content|self|frames)\W)|(localStorage|sessionStorage|Database)/

Finding Sinks

The following regular expression attempts to match most common DOMXSS sinks (BETA):

/((src|href|data|location|code|value|action)\s*["'\]]*\s*\+?\s*=)|((replace|assign|navigate|getResponseHeader|open(Dialog)?|showModalDialog|eval|evaluate|execCommand|execScript|setTimeout|setInterval)\s*["'\]]*\s*\()/

Meta-Programming

Modern user agents allow overwriting and extending existing JavaScript and DOM properties. Using this to analyze the JavaScript code flow can help identifying DOMXSS vulnerabilities by just checking every incoming data before it's being written to the DOM. An approach to automatize this in the works and ill soon be released here.

Comment by pee...@gmail.com, Mar 14, 2012

This regular expression is not working in java.. it is throwing error of invalid escape sequence


Sign in to add a comment
Powered by Google Project Hosting