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.

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

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

some limited text into <strong>the</strong> response of a target user via <strong>the</strong> subject line of an<br />

e-mail. In this situation, <strong>the</strong> attacker may be able to capture sensitive data crossdomain<br />

by injecting CSS code into <strong>the</strong> <strong>application</strong>.<br />

In <strong>the</strong> example already discussed, suppose <strong>the</strong> attacker sends an e-mail with<br />

this subject line:<br />

{}*{font-family:’<br />

Since this does not contain any HTML metacharacters, it will be accepted<br />

by most <strong>application</strong>s and displayed unmodified in responses to <strong>the</strong> recipient<br />

user. When this happens, <strong>the</strong> response returned to <strong>the</strong> user might look<br />

like this:<br />

<br />

<br />

WahhMail Inbox<br />

<br />

<br />

...<br />

{}*{font-family:’<br />

...<br />

<br />

<br />

<br />

...<br />

<br />

...<br />

<br />

var _StatsTrackerId=’AAE78F27CB3210D’;<br />

...<br />

<br />

<br />

<br />

This response obviously contains HTML. Surprisingly, however, some browsers<br />

allow this response to be loaded as a CSS stylesheet and happily process any<br />

CSS definitions it contains. In <strong>the</strong> present case, <strong>the</strong> injected response defines <strong>the</strong><br />

CSS font-family property and starts a quoted string as <strong>the</strong> property definition.<br />

The attacker’s injected text does not close <strong>the</strong> string, so it continues through <strong>the</strong><br />

rest of <strong>the</strong> response, including <strong>the</strong> hidden form field containing <strong>the</strong> sensitive<br />

anti-CSRF token. (Note that it is not necessary for CSS definitions to be quoted.<br />

However, if <strong>the</strong>y are not, <strong>the</strong>y terminate at <strong>the</strong> next semicolon character, which<br />

may occur before <strong>the</strong> sensitive data that <strong>the</strong> attacker wants to capture.)<br />

To exploit this behavior, an attacker needs to host a page on his own domain<br />

that includes <strong>the</strong> injected response as a CSS stylesheet. This causes any embedded<br />

CSS definitions to be applied within <strong>the</strong> attacker’s own page. These can

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

Saved successfully!

Ooh no, something went wrong!