19.09.2017 Views

the-web-application-hackers-handbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

488 Chapter 12 n Attacking Users: Cross-Site Scripting<br />

If a standard test string does not happen to result in valid syntax when it<br />

is processed and inserted, <strong>the</strong> embedded JavaScript does not execute, and no<br />

dialog appears, even though <strong>the</strong> <strong>application</strong> may be vulnerable to a properly<br />

crafted attack. Short of submitting every conceivable XSS attack string into every<br />

parameter, <strong>the</strong> basic approach inevitably misses a large number of vulnerabilities.<br />

A more effective approach to identifying DOM-based XSS bugs is to review<br />

all client-side JavaScript for any use of DOM properties that may lead to a vulnerability.<br />

Various tools are available to help automate this process. One such<br />

effective tool is DOMTracer, available at <strong>the</strong> following URL:<br />

www.blueinfy.com/tools.html<br />

HACK STEPS<br />

Using <strong>the</strong> results of your <strong>application</strong> mapping exercises from Chapter 4,<br />

review every piece of client-side JavaScript for <strong>the</strong> following APIs, which may<br />

be used to access DOM data that can be controlled via a crafted URL:<br />

n document.location<br />

n document.URL<br />

n document.URLUnencoded<br />

n document.referrer<br />

n window.location<br />

Be sure to include scripts that appear in static HTML pages as well as<br />

dynamically generated pages. DOM-based XSS bugs may exist in any location<br />

where client-side scripts are used, regardless of <strong>the</strong> type of page or whe<strong>the</strong>r<br />

you see parameters being submitted to <strong>the</strong> page.<br />

In every instance where one of <strong>the</strong> preceding APIs is being used, closely<br />

review <strong>the</strong> code to identify what is being done with <strong>the</strong> user-controllable<br />

data, and whe<strong>the</strong>r crafted input could be used to cause execution of arbitrary<br />

JavaScript. In particular, review and test any instance where your data is being<br />

passed to any of <strong>the</strong> following APIs:<br />

n document.write()<br />

n document.writeln()<br />

n document.body.innerHtml<br />

n eval()<br />

n window.execScript()<br />

n window.setInterval()<br />

n window.setTimeout()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!