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

Attackers can exploit <strong>the</strong> meaning within this session token to attempt to<br />

guess <strong>the</strong> current sessions of o<strong>the</strong>r <strong>application</strong> users. Using a list of enumerated<br />

or common usernames, <strong>the</strong>y can quickly generate large numbers of potentially<br />

valid tokens and test <strong>the</strong>se to confirm which are valid.<br />

Tokens that contain meaningful data often exhibit a structure. In o<strong>the</strong>r words,<br />

<strong>the</strong>y contain several components, often separated by a delimiter, that can be<br />

extracted and analyzed separately to allow an attacker to understand <strong>the</strong>ir<br />

function and means of generation. Here are some components that may be<br />

encountered within structured tokens:<br />

n The account username<br />

n The numeric identifier that <strong>the</strong> <strong>application</strong> uses to distinguish between<br />

accounts<br />

n The user’s first and last names<br />

n The user’s e-mail address<br />

n The user’s group or role within <strong>the</strong> <strong>application</strong><br />

n A date/time stamp<br />

n An incrementing or predictable number<br />

n The client IP address<br />

Each different component within a structured token, or indeed <strong>the</strong> entire<br />

token, may be encoded in different ways. This can be a deliberate measure to<br />

obfuscate <strong>the</strong>ir content, or it can simply ensure safe transport of binary data via<br />

HTTP. Encoding schemes that are commonly encountered include XOR, Base64,<br />

and hexadecimal representation using ASCII characters (see Chapter 3). It may<br />

be necessary to test various decodings on each component of a structured token<br />

to unpack it to its original form.<br />

NOTE When an <strong>application</strong> handles a request containing a structured token,<br />

it may not actually process every component with <strong>the</strong> token or all <strong>the</strong> data<br />

contained in each component. In <strong>the</strong> previous example, <strong>the</strong> <strong>application</strong> may<br />

Base64-decode <strong>the</strong> token and <strong>the</strong>n process only <strong>the</strong> “user” and “date” components.<br />

In cases where a token contains a blob of binary data, much of this<br />

data may be padding. Only a small part of it may actually be relevant to <strong>the</strong><br />

validation that <strong>the</strong> server performs on <strong>the</strong> token. Narrowing down <strong>the</strong> subparts<br />

of a token that are actually required can often considerably reduce <strong>the</strong><br />

amount of apparent entropy and complexity that <strong>the</strong> token contains.

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

Saved successfully!

Ooh no, something went wrong!