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 13 n Attacking Users: O<strong>the</strong>r Techniques 543<br />

HACK STEPS<br />

1. Identify every instance within <strong>the</strong> <strong>application</strong> where a redirect occurs.<br />

2. An effective way to do this is to walk through <strong>the</strong> <strong>application</strong> using an<br />

intercepting proxy and monitor <strong>the</strong> requests made for actual pages (as<br />

opposed to o<strong>the</strong>r resources, such as images, stylesheets, and script files).<br />

3. If a single navigation action results in more than one request in succession,<br />

investigate what means of performing <strong>the</strong> redirect is being used.<br />

The majority of redirects are not user-controllable. For example, in a typical<br />

login mechanism, submitting valid credentials to /login.jsp might return an<br />

HTTP redirect to /myhome.jsp. The target of <strong>the</strong> redirect is always <strong>the</strong> same, so<br />

it is not subject to any vulnerabilities involving redirection.<br />

However, in o<strong>the</strong>r cases, data supplied by <strong>the</strong> user is used in some way to<br />

set <strong>the</strong> target of <strong>the</strong> redirect. A common instance of this is when an <strong>application</strong><br />

forces users whose sessions have expired to return to <strong>the</strong> login page and<br />

<strong>the</strong>n redirects <strong>the</strong>m to <strong>the</strong> original URL following successful reau<strong>the</strong>ntication.<br />

If you encounter this type of behavior, <strong>the</strong> <strong>application</strong> may be vulnerable to a<br />

redirection attack, and you should investigate fur<strong>the</strong>r to determine whe<strong>the</strong>r<br />

<strong>the</strong> behavior is exploitable.<br />

HACK STEPS<br />

1. If <strong>the</strong> user data being processed in a redirect contains an absolute URL,<br />

modify <strong>the</strong> domain name within <strong>the</strong> URL, and test whe<strong>the</strong>r <strong>the</strong> <strong>application</strong><br />

redirects you to <strong>the</strong> different domain.<br />

2. If <strong>the</strong> user data being processed contains a relative URL, modify this into<br />

an absolute URL for a different domain, and test whe<strong>the</strong>r <strong>the</strong> <strong>application</strong><br />

redirects you to this domain.<br />

3. In both cases, if you see behavior like <strong>the</strong> following, <strong>the</strong> <strong>application</strong> is certainly<br />

vulnerable to an arbitrary redirection attack:<br />

GET /updates/8/?redir=http://mdattacker.net/ HTTP/1.1<br />

Host: mdsec.net<br />

HTTP/1.1 302 Object moved<br />

Location: http://mdattacker.net/

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

Saved successfully!

Ooh no, something went wrong!