19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

to span an XSS payload across several “different” request parameters with<br />

<strong>the</strong> same name, bypassing <strong>the</strong> blacklist with each separate value, all of<br />

which <strong>the</strong> server recombines.<br />

TRY IT!<br />

Currently <strong>the</strong> following XSS exploit succeeds in bypassing <strong>the</strong> IE XSS filter:<br />

http://mdsec.net/error/5/Error.ashx?message= alert(‘xss’)<br />

Third, <strong>the</strong> way in which <strong>the</strong> filter sanitizes script code in <strong>application</strong> responses<br />

can actually be leveraged to deliver attacks that o<strong>the</strong>rwise would be impossible. The<br />

core reason for this is that <strong>the</strong> filter operates passively, looking only for correlations<br />

between script-like inputs and script-like outputs. It cannot interactively probe<br />

<strong>the</strong> <strong>application</strong> to confirm whe<strong>the</strong>r a given piece of input actually causes a given<br />

piece of output. As a result, an attacker can actually leverage <strong>the</strong> filter to selectively<br />

neutralize <strong>the</strong> <strong>application</strong>’s own script code that appears within responses. If <strong>the</strong><br />

attacker includes part of an existing script within <strong>the</strong> value of a request parameter,<br />

<strong>the</strong> IE XSS filter sees that <strong>the</strong> same script code appears in <strong>the</strong> request and<br />

<strong>the</strong> response and modifies <strong>the</strong> script in <strong>the</strong> response to prevent it from executing.<br />

Some situations have been identified where neutralizing an existing script<br />

changes <strong>the</strong> syntactic context of a subsequent part of <strong>the</strong> response that contains<br />

a reflection of user input. This change in context may mean that <strong>the</strong> <strong>application</strong>’s<br />

own filtering of <strong>the</strong> reflected input is no longer sufficient. Therefore, <strong>the</strong> reflection<br />

can be used to deliver an XSS attack in a way that was impossible without<br />

<strong>the</strong> changes made by <strong>the</strong> IE XSS filter. However, <strong>the</strong> situations in which this<br />

has arisen generally have involved edge cases with unusual features or have<br />

revealed defects in earlier versions of <strong>the</strong> IE XSS filter that have since been fixed.<br />

More significantly, an attacker’s ability to selectively neutralize an <strong>application</strong>’s<br />

own script code could be leveraged to deliver entirely different attacks by interfering<br />

with an <strong>application</strong>’s security-relevant control mechanisms. One generic example<br />

of this relates to <strong>the</strong> removal of defensive framebusting code (see Chapter 13), but<br />

numerous o<strong>the</strong>r examples may arise in connection with <strong>application</strong>-specific code<br />

that performs key defensive security tasks on <strong>the</strong> client side.<br />

Finding and Exploiting Stored XSS Vulnerabilities<br />

The process of identifying stored XSS vulnerabilities overlaps substantially<br />

with that described for reflected XSS. It includes submitting a unique string in<br />

every entry point within <strong>the</strong> <strong>application</strong>. However, you must keep in mind some<br />

important differences to maximize <strong>the</strong> number of vulnerabilities identified.

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

Saved successfully!

Ooh no, something went wrong!