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 7 n Attacking Session Management 209<br />

for an <strong>application</strong> to reidentify <strong>the</strong> user across multiple requests without<br />

using sessions. However, HTTP au<strong>the</strong>ntication is rarely used on Internetbased<br />

<strong>application</strong>s of any complexity, and <strong>the</strong> o<strong>the</strong>r versatile benefits<br />

that fully fledged session mechanisms offer mean that virtually all <strong>web</strong><br />

<strong>application</strong>s do in fact employ <strong>the</strong>se mechanisms.<br />

n Sessionless state mechanisms — Some <strong>application</strong>s do not issue session<br />

tokens to manage <strong>the</strong> state of a user’s interaction with <strong>the</strong> <strong>application</strong>.<br />

Instead, <strong>the</strong>y transmit all data required to manage that state via <strong>the</strong> client,<br />

usually in a cookie or a hidden form field. In effect, this mechanism uses<br />

sessionless state much like <strong>the</strong> ASP.NET ViewState does. For this type<br />

of mechanism to be secure, <strong>the</strong> data transmitted via <strong>the</strong> client must be<br />

properly protected. This usually involves constructing a binary blob<br />

containing all <strong>the</strong> state information and encrypting or signing this using<br />

a recognized algorithm. Sufficient context must be included within <strong>the</strong><br />

data to prevent an attacker from collecting a state object at one location<br />

within <strong>the</strong> <strong>application</strong> and submitting it to ano<strong>the</strong>r location to cause some<br />

undesirable behavior. The <strong>application</strong> may also include an expiration time<br />

within <strong>the</strong> object’s data to perform <strong>the</strong> equivalent of session timeouts.<br />

Chapter 5 describes in more detail secure mechanisms for transmitting<br />

data via <strong>the</strong> client.<br />

HACK STEPS<br />

1. If HTTP au<strong>the</strong>ntication is being used, it is possible that no session management<br />

mechanism is implemented. Use <strong>the</strong> methods described previously to<br />

examine <strong>the</strong> role played by any token-like items of data.<br />

2. If <strong>the</strong> <strong>application</strong> uses a sessionless state mechanism, transmitting all<br />

data required to maintain state via <strong>the</strong> client, this may sometimes be<br />

difficult to detect with certainty, but <strong>the</strong> following are strong indicators<br />

that this kind of mechanism is being used:<br />

n Token-like data items issued to <strong>the</strong> client are fairly long (100 or more bytes).<br />

n The <strong>application</strong> issues a new token-like item in response to every request.<br />

n The data in <strong>the</strong> item appears to be encrypted (and <strong>the</strong>refore has no<br />

discernible structure) or signed (and <strong>the</strong>refore has a meaningful structure<br />

accompanied by a few bytes of meaningless binary data).<br />

n The <strong>application</strong> may reject attempts to submit <strong>the</strong> same item with more<br />

than one request.<br />

3. If <strong>the</strong> evidence suggests strongly that <strong>the</strong> <strong>application</strong> is not using session<br />

tokens to manage state, it is unlikely that any of <strong>the</strong> attacks described in<br />

this chapter will achieve anything. Your time probably would be better<br />

spent looking for o<strong>the</strong>r serious issues such as broken access controls or<br />

code injection.

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

Saved successfully!

Ooh no, something went wrong!