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.

210 Chapter 7 n Attacking Session Management<br />

Weaknesses in Token Generation<br />

Session management mechanisms are often vulnerable to attack because tokens<br />

are generated in an unsafe manner that enables an attacker to identify <strong>the</strong> values<br />

of tokens that have been issued to o<strong>the</strong>r users.<br />

NOTE There are numerous locations where an <strong>application</strong>’s security<br />

depends on <strong>the</strong> unpredictability of tokens it generates. Here are some<br />

examples:<br />

n Password recovery tokens sent to <strong>the</strong> user’s registered e-mail address<br />

n Tokens placed in hidden form fields to prevent cross-site request forgery<br />

attacks (see Chapter 13)<br />

n Tokens used to give one-time access to protected resources<br />

n Persistent tokens used in “remember me” functions<br />

n Tokens allowing customers of a shopping <strong>application</strong> that does not use<br />

au<strong>the</strong>ntication to retrieve <strong>the</strong> current status of an existing order<br />

The considerations in this chapter relating to weaknesses in token generation<br />

apply to all <strong>the</strong>se cases. In fact, because many of today’s <strong>application</strong>s rely on<br />

mature platform mechanisms to generate session tokens, it is often in <strong>the</strong>se<br />

o<strong>the</strong>r areas of functionality that exploitable weaknesses in token generation<br />

are found.<br />

Meaningful Tokens<br />

Some session tokens are created using a transformation of <strong>the</strong> user’s username<br />

or e-mail address, or o<strong>the</strong>r information associated with that person. This information<br />

may be encoded or obfuscated in some way and may be combined with<br />

o<strong>the</strong>r data.<br />

For example, <strong>the</strong> following token may initially appear to be a long random<br />

string:<br />

757365723d6461663b6170703d61646d696e3b646174653d30312f31322f3131<br />

However, on closer inspection, you can see that it contains only hexadecimal<br />

characters. Guessing that <strong>the</strong> string may actually be a hex encoding of a string<br />

of ASCII characters, you can run it through a decoder to reveal <strong>the</strong> following:<br />

user=daf;app=admin;date=10/09/11

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

Saved successfully!

Ooh no, something went wrong!