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.

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

n If an <strong>application</strong> receives data via some out-of-band channel and renders<br />

this within its <strong>web</strong> interface, any stored XSS bugs can be exploited without<br />

submitting any malicious payload using HTTP.<br />

n Attacks against DOM-based XSS may not involve submitting any malicious<br />

payload to <strong>the</strong> server. If <strong>the</strong> fragment technique is used, <strong>the</strong> payload<br />

remains on <strong>the</strong> client at all times.<br />

Some <strong>application</strong>s employ a more sophisticated client-side script that performs<br />

stricter parsing of <strong>the</strong> query string. For example, it may search <strong>the</strong> URL for <strong>the</strong><br />

parameter name followed by <strong>the</strong> equals sign but <strong>the</strong>n extract what follows only<br />

until it reaches a relevant delimiter such as & or #. In this case, <strong>the</strong> two attacks<br />

described previously could be modified as follows:<br />

http://mdsec.net/error/79/Error.ashx?foomessage=alert(1)&message=Sorry%2c+an+error+occurred<br />

http://mdsec.net/error/79/Error.ashx#message=alert(1)<br />

In both cases, <strong>the</strong> first match for message= is followed immediately by <strong>the</strong><br />

attack string, without any intervening delimiter, so <strong>the</strong> payload is processed<br />

and copied into <strong>the</strong> HTML page source.<br />

TRY IT!<br />

http://mdsec.net/error/79/<br />

In some cases, you may find that complex processing is performed on DOMbased<br />

data. Therefore, it is difficult to trace all <strong>the</strong> different paths taken by usercontrollable<br />

data, and all <strong>the</strong> manipulation being performed, solely through static<br />

review of <strong>the</strong> JavaScript source code. In this situation, it can be beneficial to use<br />

a JavaScript debugger to monitor <strong>the</strong> script’s execution dynamically. The FireBug<br />

extension to <strong>the</strong> Firefox browser is a full-fledged debugger for client-side code<br />

and content. It enables you to set breakpoints and watches on interesting code<br />

and data, making <strong>the</strong> task of understanding a complex script considerably easier.<br />

COMMON MYTH<br />

“We’re safe. Our <strong>web</strong> <strong>application</strong> scanner didn’t find any XSS bugs.”<br />

As you will see in Chapter 19, some <strong>web</strong> <strong>application</strong> scanners do a reasonable<br />

job of finding common flaws, including XSS. However, it should be<br />

evident at this point that many XSS vulnerabilities are subtle to detect, and<br />

creating a working exploit can require extensive probing and experimentation.<br />

At <strong>the</strong> present time, no automated tools can reliably identify all <strong>the</strong>se bugs.

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

Saved successfully!

Ooh no, something went wrong!