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 129<br />

It updates each time <strong>the</strong> resource is modified. If <strong>the</strong> server possesses a newer<br />

version of <strong>the</strong> resource than <strong>the</strong> date specified in <strong>the</strong> If-Modified-Since<br />

header, or if <strong>the</strong> Etag of <strong>the</strong> current version matches <strong>the</strong> one specified in <strong>the</strong><br />

If-None-Match header, <strong>the</strong> server responds with <strong>the</strong> latest version of <strong>the</strong><br />

resource. O<strong>the</strong>rwise, it returns a 304 response, as shown here, informing <strong>the</strong><br />

browser that <strong>the</strong> resource has not been modified and that <strong>the</strong> browser should<br />

use its cached copy.<br />

When this occurs, and you need to intercept and modify <strong>the</strong> resource that<br />

<strong>the</strong> browser has cached, you can intercept <strong>the</strong> relevant request and remove<br />

<strong>the</strong> If-Modified-Since and If-None-Match headers. This causes <strong>the</strong> server<br />

to respond with <strong>the</strong> full version of <strong>the</strong> requested resource. Burp Proxy contains<br />

an option to strip <strong>the</strong>se headers from every request, <strong>the</strong>reby overriding<br />

all cache information sent by <strong>the</strong> browser.<br />

HACK STEPS<br />

1. Look for form elements containing a maxlength attribute. Submit data<br />

that is longer than this length but that is formatted correctly in o<strong>the</strong>r<br />

respects (for example, it is numeric if <strong>the</strong> <strong>application</strong> expects a number).<br />

2. If <strong>the</strong> <strong>application</strong> accepts <strong>the</strong> overlong data, you may infer that <strong>the</strong> clientside<br />

validation is not replicated on <strong>the</strong> server.<br />

3. Depending on <strong>the</strong> subsequent processing that <strong>the</strong> <strong>application</strong> performs<br />

on <strong>the</strong> parameter, you may be able to leverage <strong>the</strong> defects in validation to<br />

exploit o<strong>the</strong>r vulnerabilities, such as SQL injection, cross-site scripting, or<br />

buffer overflows.<br />

Script-Based Validation<br />

The input validation mechanisms built into HTML forms <strong>the</strong>mselves are extremely<br />

simple and are insufficiently fine-grained to perform relevant validation of<br />

many kinds of input. For example, a user registration form might contain fields<br />

for name, e-mail address, telephone number, and zip code, all of which expect<br />

different types of input. Therefore, it is common to see customized client-side<br />

input validation implemented within scripts. Consider <strong>the</strong> following variation<br />

on <strong>the</strong> original example:<br />

<br />

Product: Samsung Multiverse <br />

Price: 399

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

Saved successfully!

Ooh no, something went wrong!