19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

252 Chapter 7 n Attacking Session Management<br />

is to keep <strong>the</strong> sequence of pages where sensitive data is submitted as short<br />

as possible. Then you can create a new session at <strong>the</strong> first page of this<br />

sequence (where necessary, copying from <strong>the</strong> existing session any required<br />

data, such as <strong>the</strong> contents of a shopping cart). Or you could use per-page<br />

tokens (described in <strong>the</strong> following section) to prevent an attacker who<br />

knows <strong>the</strong> token used in <strong>the</strong> first page from accessing subsequent pages.<br />

Except where strictly necessary, personal data should not be displayed<br />

back to <strong>the</strong> user. Even where this is required (such as a “confirm order”<br />

page showing addresses), sensitive items such as credit card numbers and<br />

passwords should never be displayed back to <strong>the</strong> user and should always<br />

be masked within <strong>the</strong> source of <strong>the</strong> <strong>application</strong>’s response.<br />

Per-Page Tokens<br />

Finer-grained control over sessions can be achieved, and many kinds of session<br />

attacks can be made more difficult or impossible, by using per-page tokens in<br />

addition to session tokens. Here, a new page token is created every time a user<br />

requests an <strong>application</strong> page (as opposed to an image, for example) and is passed<br />

to <strong>the</strong> client in a cookie or a hidden field of an HTML form. Each time <strong>the</strong> user<br />

makes a request, <strong>the</strong> page token is validated against <strong>the</strong> last value issued, in<br />

addition to <strong>the</strong> normal validation of <strong>the</strong> main session token. In <strong>the</strong> case of a<br />

non-match, <strong>the</strong> entire session is terminated. Many of <strong>the</strong> most security-critical<br />

<strong>web</strong> <strong>application</strong>s on <strong>the</strong> Internet, such as online banks, employ per-page tokens<br />

to provide increased protection for <strong>the</strong>ir session management mechanism, as<br />

shown in Figure 7-12.<br />

Figure 7-12: Per-page tokens used in a banking <strong>application</strong><br />

The use of per-page tokens does impose some restrictions on navigation (for<br />

example, on use of <strong>the</strong> back and forward buttons and multiwindow browsing).

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

Saved successfully!

Ooh no, something went wrong!