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.

740 Chapter 19 n Finding Vulnerabilities in Source Code<br />

will be used, <strong>the</strong> taint mode protection fails, and <strong>the</strong> <strong>application</strong> is still vulnerable.<br />

In effect, <strong>the</strong> taint mode mechanism reminds programmers to perform<br />

suitable validation on all input before using it in dangerous operations. It cannot<br />

guarantee that <strong>the</strong> input validation implemented will be adequate.<br />

JavaScript<br />

Client-side JavaScript can, of course, be accessed without requiring any privileged<br />

access to <strong>the</strong> <strong>application</strong>, enabling you to perform a security-focused<br />

code review in any situation. A key focus of this review is to identify any<br />

vulnerabilities such as DOM-based XSS, which are introduced on <strong>the</strong> client<br />

component and leave users vulnerable to attack (see Chapter 12). A fur<strong>the</strong>r<br />

reason for reviewing JavaScript is to understand what kinds of input validation<br />

are implemented on <strong>the</strong> client, and also how dynamically generated user<br />

interfaces are constructed.<br />

When reviewing JavaScript, you should be sure to include both .js files and<br />

scripts embedded in HTML content.<br />

The key APIs to focus on are those that read from DOM-based data and that<br />

write to or o<strong>the</strong>rwise modify <strong>the</strong> current document, as shown in Table 19-12.<br />

Table 19-12: JavaScript APIs That Read from DOM-Based Data<br />

API<br />

document.location<br />

document.URL<br />

document.URLUnencoded<br />

DESCRIPTION<br />

Can be used to access DOM data that may be<br />

controllable via a crafted URL, and may <strong>the</strong>refore<br />

represent an entry point for crafted data to<br />

attack o<strong>the</strong>r <strong>application</strong> users.<br />

document.referrer<br />

window.location<br />

document.write()<br />

document.writeln()<br />

document.body.innerHtml<br />

eval()<br />

window.execScript()<br />

Can be used to update <strong>the</strong> document’s contents<br />

and to dynamically execute JavaScript<br />

code. If attacker-controllable data is passed to<br />

any of <strong>the</strong>se APIs, this may provide a way to<br />

execute arbitrary JavaScript within a victim’s<br />

browser.<br />

window.setInterval()<br />

window.setTimeout()

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

Saved successfully!

Ooh no, something went wrong!