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.

224 Chapter 7 n Attacking Session Management<br />

However, in some situations, depending on <strong>the</strong> encryption algorithm used and<br />

<strong>the</strong> manner in which <strong>the</strong> <strong>application</strong> processes <strong>the</strong> tokens, it may none<strong>the</strong>less be<br />

possible for users to tamper with <strong>the</strong> tokens’ meaningful contents without actually<br />

decrypting <strong>the</strong>m. Bizarre as it may sound, <strong>the</strong>se are actually viable attacks<br />

that are sometimes easy to deliver, and numerous real-world <strong>application</strong>s have<br />

proven vulnerable to <strong>the</strong>m. The kinds of attacks that are applicable depend on<br />

<strong>the</strong> exact cryptographic algorithm that is being used.<br />

ECB Ciphers<br />

Applications that employ encrypted tokens use a symmetric encryption algorithm<br />

so that tokens received from users can be decrypted to recover <strong>the</strong>ir meaningful<br />

contents. Some symmetric encryption algorithms use an “electronic codebook”<br />

(ECB) cipher. This type of cipher divides plaintext into equal-sized blocks (such<br />

as 8 bytes each) and encrypts each block using <strong>the</strong> secret key. During decryption,<br />

each block of ciphertext is decrypted using <strong>the</strong> same key to recover <strong>the</strong><br />

original block of plaintext. One feature of this method is that patterns within <strong>the</strong><br />

plaintext can result in patterns within <strong>the</strong> ciphertext, because identical blocks of<br />

plaintext will be encrypted into identical blocks of ciphertext. For some types<br />

of data, such as bitmap images, this means that meaningful information from<br />

<strong>the</strong> plaintext can be discerned within <strong>the</strong> ciphertext, as illustrated in Figure 7-4.<br />

Figure 7-4: Patterns within plaintext that<br />

is encrypted using an ECB cipher may be<br />

visible within <strong>the</strong> resulting ciphertext.<br />

In spite of this shortcoming with ECB, <strong>the</strong>se ciphers are often used for encrypting<br />

information within <strong>web</strong> <strong>application</strong>s. Even in situations where <strong>the</strong> problem<br />

of patterns within plaintext does not arise, vulnerabilities can still exist. This<br />

is because of <strong>the</strong> cipher’s behavior of encrypting identical plaintext blocks into<br />

identical ciphertext blocks.<br />

Consider an <strong>application</strong> whose tokens contain several different meaningful<br />

components, including a numeric user identifier:<br />

rnd=2458992;app=iTradeEUR_1;uid=218;username=dafydd;time=634430423694715<br />

000;

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

Saved successfully!

Ooh no, something went wrong!