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.

208 Chapter 7 n Attacking Session Management<br />

HACK STEPS<br />

In many <strong>application</strong>s that use <strong>the</strong> standard cookie mechanism to transmit<br />

session tokens, it is straightforward to identify which item of data contains<br />

<strong>the</strong> token. However, in o<strong>the</strong>r cases this may require some detective work.<br />

1. The <strong>application</strong> may often employ several different items of data collectively<br />

as a token, including cookies, URL parameters, and hidden form<br />

fields. Some of <strong>the</strong>se items may be used to maintain session state on different<br />

back-end components. Do not assume that a particular parameter<br />

is <strong>the</strong> session token without proving it, or that sessions are being tracked<br />

using only one item.<br />

2. Sometimes, items that appear to be <strong>the</strong> <strong>application</strong>’s session token may<br />

not be. In particular, <strong>the</strong> standard session cookie generated by <strong>the</strong> <strong>web</strong><br />

server or <strong>application</strong> platform may be present but not actually used by <strong>the</strong><br />

<strong>application</strong>.<br />

3. Observe which new items are passed to <strong>the</strong> browser after au<strong>the</strong>ntication.<br />

Often, new session tokens are created after a user au<strong>the</strong>nticates herself.<br />

4. To verify which items are actually being employed as tokens, find a page<br />

that is definitely session-dependent (such as a user-specific “my details”<br />

page). Make several requests for it, systematically removing each item<br />

that you suspect is being used as a token. If removing an item causes<br />

<strong>the</strong> session-dependent page not to be returned, this may confirm that <strong>the</strong><br />

item is a session token. Burp Repeater is a useful tool for performing<br />

<strong>the</strong>se tests.<br />

Alternatives to Sessions<br />

Not every <strong>web</strong> <strong>application</strong> employs sessions, and some security-critical <strong>application</strong>s<br />

containing au<strong>the</strong>ntication mechanisms and complex functionality opt to<br />

use o<strong>the</strong>r techniques to manage state. You are likely to encounter two possible<br />

alternatives:<br />

n HTTP au<strong>the</strong>ntication — Applications using <strong>the</strong> various HTTP-based<br />

au<strong>the</strong>ntication technologies (basic, digest, NTLM) sometimes avoid <strong>the</strong><br />

need to use sessions. With HTTP au<strong>the</strong>ntication, <strong>the</strong> client component<br />

interacts with <strong>the</strong> au<strong>the</strong>ntication mechanism directly via <strong>the</strong> browser,<br />

using HTTP headers, and not via <strong>application</strong>-specific code contained<br />

within any individual page. After <strong>the</strong> user enters his credentials into a<br />

browser dialog, <strong>the</strong> browser effectively resubmits <strong>the</strong>se credentials (or<br />

reperforms any required handshake) with every subsequent request to<br />

<strong>the</strong> same server. This is equivalent to an <strong>application</strong> that uses HTML<br />

forms-based au<strong>the</strong>ntication and places a login form on every <strong>application</strong><br />

page, requiring users to reau<strong>the</strong>nticate <strong>the</strong>mselves with every action <strong>the</strong>y<br />

perform. Hence, when HTTP-based au<strong>the</strong>ntication is used, it is possible

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

Saved successfully!

Ooh no, something went wrong!