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.

546 Chapter 13 n Attacking Users: O<strong>the</strong>r Techniques<br />

aimed at an external domain. The best an attacker can probably achieve is to<br />

frame a URL that redirects a user to a different URL within <strong>the</strong> same <strong>application</strong>.<br />

This attack normally does not accomplish anything, because if <strong>the</strong> attacker<br />

can induce a user to visit one URL within <strong>the</strong> <strong>application</strong>, he can presumably<br />

just as easily feed <strong>the</strong> second URL to <strong>the</strong> user directly.<br />

TRY IT!<br />

http://mdsec.net/updates/72/<br />

In cases where <strong>the</strong> redirect is initiated using client-side JavaScript that queries<br />

data from <strong>the</strong> DOM, all <strong>the</strong> code responsible for performing <strong>the</strong> redirect and any<br />

associated validation typically are visible on <strong>the</strong> client. You should review this<br />

closely to determine how user-controllable data is being incorporated into <strong>the</strong><br />

URL, whe<strong>the</strong>r any validation is being performed, and, if so, whe<strong>the</strong>r any bypasses<br />

to <strong>the</strong> validation exist. Bear in mind that, as with DOM-based XSS, some additional<br />

validation may be performed on <strong>the</strong> server before <strong>the</strong> script is returned<br />

to <strong>the</strong> browser. The following JavaScript APIs may be used to perform redirects:<br />

n document.location<br />

n document.URL<br />

n document.open()<br />

n window.location.href<br />

n window.navigate()<br />

n window.open()<br />

TRY IT!<br />

http://mdsec.net/updates/76/<br />

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

http://mdsec.net/updates/82/<br />

http://mdsec.net/updates/91/<br />

http://mdsec.net/updates/92/<br />

http://mdsec.net/updates/95/<br />

Preventing Open Redirection Vulnerabilities<br />

The most effective way to avoid open redirection vulnerabilities is to not incorporate<br />

user-supplied data into <strong>the</strong> target of a redirect. Developers are inclined<br />

to use this technique for various reasons, but alternatives usually are available.<br />

For example, it is common to see a user interface that contains a list of links,

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

Saved successfully!

Ooh no, something went wrong!