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.

516 Chapter 13 n Attacking Users: O<strong>the</strong>r Techniques<br />

one domain may cause requests to a different domain, it may not easily read<br />

<strong>the</strong> responses from those requests to steal <strong>the</strong> user’s data from a different<br />

domain.<br />

In fact, various techniques can be used in some situations to capture all or<br />

part of a response from a different domain. These attacks typically exploit some<br />

aspect of <strong>the</strong> target <strong>application</strong>’s functionality toge<strong>the</strong>r with some feature of<br />

popular browsers to allow cross-domain data capture in a way that <strong>the</strong> sameorigin<br />

policy is intended to prevent.<br />

Capturing Data by Injecting HTML<br />

Many <strong>application</strong>s contain functionality that allows an attacker to inject some<br />

limited HTML into a response that is received by a different user in a way that<br />

falls short of a full XSS vulnerability. For example, a <strong>web</strong> mail <strong>application</strong> may<br />

display e-mails containing some HTML markup but block any tags and attributes<br />

that can be used to execute script code. Or a dynamically generated error message<br />

may filter a range of expressions but still allow some limited use of HTML.<br />

In <strong>the</strong>se situations, it may be possible to leverage <strong>the</strong> HTML-injection condition<br />

to cause sensitive data within <strong>the</strong> page to be sent to <strong>the</strong> attacker’s domain.<br />

For example, in a <strong>web</strong> mail <strong>application</strong>, <strong>the</strong> attacker may be able to capture <strong>the</strong><br />

contents of a private e-mail message. Alternatively, <strong>the</strong> attacker may be able to<br />

read an anti-CSRF token being used within <strong>the</strong> page, allowing him to deliver<br />

a CSRF attack to forward <strong>the</strong> user’s e-mail messages to an arbitrary address.<br />

Suppose <strong>the</strong> <strong>web</strong> mail <strong>application</strong> allows injection of limited HTML into <strong>the</strong><br />

following response:<br />

[ limited HTML injection here ]<br />

<br />

<br />

<br />

...<br />

<br />

...<br />

<br />

var _StatsTrackerId=’AAE78F27CB3210D’;<br />

...<br />

<br />

Following <strong>the</strong> injection point, <strong>the</strong> page contains an HTML form that includes<br />

a CSRF token. In this situation, an attacker could inject <strong>the</strong> following text into<br />

<strong>the</strong> response:<br />

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

Saved successfully!

Ooh no, something went wrong!