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 5 n Bypassing Client-Side Controls 119<br />

The classic example of this security flaw is a retailing <strong>application</strong> that stores<br />

<strong>the</strong> prices of products within hidden form fields. In <strong>the</strong> early days of <strong>web</strong> <strong>application</strong>s,<br />

this vulnerability was extremely widespread, and by no means has it<br />

been eliminated today. Figure 5-1 shows a typical form.<br />

Figure 5-1: A typical HTML form<br />

The code behind this form is as follows:<br />

<br />

Product: iPhone 5 <br />

Price: 449 <br />

Quantity: (Maximum quantity is 50)<br />

<br />

<br />

<br />

<br />

Notice <strong>the</strong> form field called price, which is flagged as hidden. This field is sent<br />

to <strong>the</strong> server when <strong>the</strong> user submits <strong>the</strong> form:<br />

POST /shop/28/Shop.aspx?prod=1 HTTP/1.1<br />

Host: mdsec.net<br />

Content-Type: <strong>application</strong>/x-www-form-urlencoded<br />

Content-Length: 20<br />

quantity=1&price=449<br />

TRY IT!<br />

http://mdsec.net/shop/28/<br />

Although <strong>the</strong> price field is not displayed on-screen, and <strong>the</strong> user cannot edit<br />

it, this is solely because <strong>the</strong> <strong>application</strong> has instructed <strong>the</strong> browser to hide <strong>the</strong><br />

field. Because everything that occurs on <strong>the</strong> client side is ultimately within<br />

<strong>the</strong> user’s control, this restriction can be circumvented to edit <strong>the</strong> price.<br />

One way to achieve this is to save <strong>the</strong> source code for <strong>the</strong> HTML page, edit<br />

<strong>the</strong> field’s value, reload <strong>the</strong> source into a browser, and click <strong>the</strong> Buy button.<br />

However, an easier and more elegant method is to use an intercepting proxy to<br />

modify <strong>the</strong> desired data on-<strong>the</strong>-fly.

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

Saved successfully!

Ooh no, something went wrong!