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.

122 Chapter 5 n Bypassing Client-Side Controls<br />

n Where a form uses <strong>the</strong> POST method and its target URL contains preset<br />

parameters<br />

n Where an <strong>application</strong> uses pop-up windows or o<strong>the</strong>r techniques to conceal<br />

<strong>the</strong> browser location bar<br />

Of course, in any such case <strong>the</strong> values of any URL parameters can be modified<br />

as previously discussed using an intercepting proxy.<br />

The Referer Header<br />

Browsers include <strong>the</strong> Referer header within most HTTP requests. It is used to<br />

indicate <strong>the</strong> URL of <strong>the</strong> page from which <strong>the</strong> current request originated — ei<strong>the</strong>r<br />

because <strong>the</strong> user clicked a hyperlink or submitted a form, or because <strong>the</strong> page<br />

referenced o<strong>the</strong>r resources such as images. Hence, it can be leveraged as a<br />

mechanism for transmitting data via <strong>the</strong> client. Because <strong>the</strong> URLs processed by<br />

<strong>the</strong> <strong>application</strong> are within its control, developers may assume that <strong>the</strong> Referer<br />

header can be used to reliably determine which URL generated a particular<br />

request.<br />

For example, consider a mechanism that enables users to reset <strong>the</strong>ir password<br />

if <strong>the</strong>y have forgotten it. The <strong>application</strong> requires users to proceed through<br />

several steps in a defined sequence before <strong>the</strong>y actually reset <strong>the</strong>ir password’s<br />

value with <strong>the</strong> following request:<br />

GET /auth/472/CreateUser.ashx HTTP/1.1<br />

Host: mdsec.net<br />

Referer: https://mdsec.net/auth/472/Admin.ashx<br />

The <strong>application</strong> may use <strong>the</strong> Referer header to verify that this request originated<br />

from <strong>the</strong> correct stage (Admin.ashx). If it did, <strong>the</strong> user can access <strong>the</strong><br />

requested functionality.<br />

However, because <strong>the</strong> user controls every aspect of every request, including<br />

<strong>the</strong> HTTP headers, this control can be easily circumvented by proceeding directly<br />

to CreateUser.ashx and using an intercepting proxy to change <strong>the</strong> value of <strong>the</strong><br />

Referer header to <strong>the</strong> value that <strong>the</strong> <strong>application</strong> requires.<br />

The Referer header is strictly optional according to w3.org standards. Hence,<br />

although most browsers implement it, using it to control <strong>application</strong> functionality<br />

should be regarded as a hack.<br />

TRY IT!<br />

http://mdsec.net/auth/472/

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

Saved successfully!

Ooh no, something went wrong!