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.

246 Chapter 7 n Attacking Session Management<br />

real-world blog <strong>application</strong>s), a malicious blogger can steal <strong>the</strong> session tokens<br />

of o<strong>the</strong>r users in <strong>the</strong> same way as is done in a stored cross-site scripting attack<br />

(see Chapter 12).<br />

The problem arises because user-authored blogs are created as subdomains<br />

of <strong>the</strong> main <strong>application</strong> that handles au<strong>the</strong>ntication and session management.<br />

There is no facility within HTTP cookies for <strong>the</strong> <strong>application</strong> to prevent cookies<br />

issued by <strong>the</strong> main domain from being resubmitted to its subdomains.<br />

The solution is to use a different domain name for <strong>the</strong> main <strong>application</strong> (for<br />

example, www.wahh-blogs.com) and to scope <strong>the</strong> domain of its session token<br />

cookies to this fully qualified name. The session cookie will not <strong>the</strong>n be submitted<br />

when a logged-in user browses <strong>the</strong> blogs of o<strong>the</strong>r users.<br />

A different version of this vulnerability arises when an <strong>application</strong> explicitly<br />

sets <strong>the</strong> domain scope of its cookies to a parent domain. For example, suppose<br />

that a security-critical <strong>application</strong> is located at <strong>the</strong> domain sensitiveapp<br />

.wahh-organization.com. When it sets cookies, it explicitly liberalizes <strong>the</strong>ir<br />

domain scope, as follows:<br />

Set-cookie: sessionId=12df098ad809a5219; domain=wahh-organization.com<br />

The consequence of this is that <strong>the</strong> sensitive <strong>application</strong>’s session token cookies<br />

will be submitted when a user visits every subdomain used by wahh-organization<br />

.com, including:<br />

www.wahh-organization.com<br />

testapp.wahh-organization.com<br />

Although <strong>the</strong>se o<strong>the</strong>r <strong>application</strong>s may all belong to <strong>the</strong> same organization as<br />

<strong>the</strong> sensitive <strong>application</strong>, it is undesirable for <strong>the</strong> sensitive <strong>application</strong>’s cookies<br />

to be submitted to o<strong>the</strong>r <strong>application</strong>s, for several reasons:<br />

n The personnel responsible for <strong>the</strong> o<strong>the</strong>r <strong>application</strong>s may have a different<br />

level of trust than those responsible for <strong>the</strong> sensitive <strong>application</strong>.<br />

n The o<strong>the</strong>r <strong>application</strong>s may contain functionality that enables third parties<br />

to obtain <strong>the</strong> value of cookies submitted to <strong>the</strong> <strong>application</strong>, as in <strong>the</strong><br />

previous blogging example.<br />

n The o<strong>the</strong>r <strong>application</strong>s may not have been subjected to <strong>the</strong> same security<br />

standards or testing as <strong>the</strong> sensitive <strong>application</strong> (because <strong>the</strong>y are less<br />

important, do not handle sensitive data, or have been created only for test<br />

purposes). Many kinds of vulnerability that may exist in those <strong>application</strong>s<br />

(for example, cross-site scripting vulnerabilities) may be irrelevant<br />

to <strong>the</strong> security posture of those <strong>application</strong>s. But <strong>the</strong>y could enable an<br />

external attacker to leverage an insecure <strong>application</strong> to capture session<br />

tokens created by <strong>the</strong> sensitive <strong>application</strong>.

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

Saved successfully!

Ooh no, something went wrong!