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 13 n Attacking Users: O<strong>the</strong>r Techniques 539<br />

users to browse a catalog of products, place items into a shopping cart, check<br />

out by submitting personal data and payment details, and <strong>the</strong>n review all this<br />

information on a Confirm Order page. In this situation, an attacker may fix an<br />

anonymous session token with a victim’s browser, wait for that user to place<br />

an order and submit sensitive information, and <strong>the</strong>n access <strong>the</strong> Confirm Order<br />

page using <strong>the</strong> token to capture <strong>the</strong> user’s details.<br />

Some <strong>web</strong> <strong>application</strong>s and <strong>web</strong> servers accept arbitrary tokens submitted<br />

by users, even if <strong>the</strong>se were not previously issued by <strong>the</strong> server itself. When<br />

an unrecognized token is received, <strong>the</strong> server simply creates a new session<br />

for it and handles it exactly as if it were a new token generated by <strong>the</strong> server.<br />

Microsoft IIS and Allaire ColdFusion servers have been vulnerable to this<br />

weakness in <strong>the</strong> past.<br />

When an <strong>application</strong> or server behaves in this way, attacks based on session<br />

fixation are made considerably easier because <strong>the</strong> attacker does not need<br />

to take any steps to ensure that <strong>the</strong> tokens fixed in target users’ browsers are<br />

currently valid. The attacker can simply choose an arbitrary token and distribute<br />

it as widely as possible (for example, by e-mailing a URL containing<br />

<strong>the</strong> token to individual users, mailing lists, and so on). Then <strong>the</strong> attacker can<br />

periodically poll a protected page within <strong>the</strong> <strong>application</strong> (such as My Details)<br />

to detect when a victim has used <strong>the</strong> token to log in. Even if a targeted user<br />

does not follow <strong>the</strong> URL for several months, a determined attacker may still<br />

be able hijack her session.<br />

Finding and Exploiting Session Fixation Vulnerabilities<br />

If <strong>the</strong> <strong>application</strong> supports au<strong>the</strong>ntication, you should review how it handles session<br />

tokens in relation to <strong>the</strong> login. The <strong>application</strong> may be vulnerable in two ways:<br />

n The <strong>application</strong> issues an anonymous session token to each unau<strong>the</strong>nticated<br />

user. When <strong>the</strong> user logs in, no new token is issued. Instead, her<br />

existing session is upgraded to an au<strong>the</strong>nticated session. This behavior<br />

is common when <strong>the</strong> <strong>application</strong> uses <strong>the</strong> <strong>application</strong> server’s default<br />

session-handling mechanism.<br />

n The <strong>application</strong> does not issue tokens to anonymous users, and a token<br />

is issued only following a successful login. However, if a user accesses<br />

<strong>the</strong> login function using an au<strong>the</strong>nticated token and logs in using different<br />

credentials, no new token is issued. Instead, <strong>the</strong> user associated<br />

with <strong>the</strong> previously au<strong>the</strong>nticated session is changed to <strong>the</strong> identity of<br />

<strong>the</strong> second user.<br />

In both of <strong>the</strong>se cases, an attacker can obtain a valid session token (ei<strong>the</strong>r by<br />

simply requesting <strong>the</strong> login page or by performing a login with his own credentials)<br />

and feed this to a target user. When that user logs in using <strong>the</strong> token,<br />

<strong>the</strong> attacker can hijack <strong>the</strong> user’s session.

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

Saved successfully!

Ooh no, something went wrong!