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.

820 Chapter 21 n A Web Application Hacker’s Methodology<br />

5.9 Check for CSRF<br />

5.9.1 If <strong>the</strong> <strong>application</strong> relies solely on HTTP cookies as its method of transmitting<br />

session tokens, it may be vulnerable to cross-site request forgery<br />

attacks.<br />

5.9.2 Review <strong>the</strong> <strong>application</strong>’s key functionality, and identify <strong>the</strong> specific<br />

requests that are used to perform sensitive actions. If an attacker can<br />

fully determine in advance parameters for any of <strong>the</strong>se requests (that<br />

is, <strong>the</strong>y do not contain any session tokens, unpredictable data, or o<strong>the</strong>r<br />

secrets), <strong>the</strong> <strong>application</strong> is almost certainly vulnerable.<br />

5.9.3 Create an HTML page that will issue <strong>the</strong> desired request without any<br />

user interaction. For GET requests, you can place an tag with <strong>the</strong><br />

src parameter set to <strong>the</strong> vulnerable URL. For POST requests, you can<br />

create a form that contains hidden fields for all <strong>the</strong> relevant parameters<br />

required for <strong>the</strong> attack and that has its target set to <strong>the</strong> vulnerable<br />

URL. You can use JavaScript to autosubmit <strong>the</strong> form as soon as <strong>the</strong><br />

page loads. While logged in to <strong>the</strong> <strong>application</strong>, use <strong>the</strong> same browser<br />

to load your HTML page. Verify that <strong>the</strong> desired action is carried out<br />

within <strong>the</strong> <strong>application</strong>.<br />

5.9.4 If <strong>the</strong> <strong>application</strong> uses additional tokens within requests in an attempt to<br />

prevent CSRF attacks, test <strong>the</strong> robustness of <strong>the</strong>se in <strong>the</strong> same manner as<br />

for session tokens. Also test whe<strong>the</strong>r <strong>the</strong> <strong>application</strong> is vulnerable to UI<br />

redress attacks, in order to defeat <strong>the</strong> anti-CSRF defenses (see Chapter 13<br />

for more details).<br />

5.10 Check Cookie Scope<br />

5.10.1 If <strong>the</strong> <strong>application</strong> uses HTTP cookies to transmit session tokens (or<br />

any o<strong>the</strong>r sensitive data), review <strong>the</strong> relevant Set-Cookie headers, and<br />

check for any domain or path attributes used to control <strong>the</strong> scope of <strong>the</strong><br />

cookies.<br />

5.10.2 If <strong>the</strong> <strong>application</strong> explicitly liberalizes its cookies’ scope to a parent<br />

domain or parent directory, it may be leaving itself vulnerable to attacks<br />

via o<strong>the</strong>r <strong>web</strong> <strong>application</strong>s that are hosted within <strong>the</strong> parent domain<br />

or directory.<br />

5.10.3 If <strong>the</strong> <strong>application</strong> sets its cookies’ domain scope to its own domain<br />

name (or does not specify a domain attribute), it may still be exposed<br />

to attacks via any <strong>application</strong>s hosted on subdomains. This is a consequence<br />

of how cookie scoping works. It cannot be avoided o<strong>the</strong>r than<br />

by not hosting any o<strong>the</strong>r <strong>application</strong>s on a subdomain of a securitysensitive<br />

<strong>application</strong>.

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

Saved successfully!

Ooh no, something went wrong!