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.

Chapter 12 n Attacking Users: Cross-Site Scripting 475<br />

In some situations, <strong>the</strong> opposite technique can be useful. Converting an attack that<br />

uses <strong>the</strong> GET method into one that uses <strong>the</strong> POST method may enable you to bypass<br />

certain filters. Many <strong>application</strong>s perform some generic <strong>application</strong>-wide filtering<br />

of requests for known attack strings. If an <strong>application</strong> expects to receive requests<br />

using <strong>the</strong> GET method, it may perform this filtering on <strong>the</strong> URL query string only. By<br />

converting a request to use <strong>the</strong> POST method, you may be able to bypass this filter.<br />

Exploiting XSS Via Cookies<br />

Some <strong>application</strong>s contain reflected XSS vulnerabilities for which <strong>the</strong> entry point<br />

for <strong>the</strong> attack is within a request cookie. In this situation, you may be able to<br />

use various techniques to exploit <strong>the</strong> vulnerability:<br />

n As with modifying <strong>the</strong> request method, <strong>the</strong> <strong>application</strong> may allow you to<br />

use a URL or body parameter with <strong>the</strong> same name as <strong>the</strong> cookie to trigger<br />

<strong>the</strong> vulnerability.<br />

n If <strong>the</strong> <strong>application</strong> contains any functionality that allows <strong>the</strong> cookie’s value<br />

to be set directly (for example, a preferences page that sets cookies based<br />

on submitted parameter values), you may be able to devise a cross-site<br />

request forgery attack that sets <strong>the</strong> required cookie in <strong>the</strong> victim’s browser.<br />

Exploiting <strong>the</strong> vulnerability would <strong>the</strong>n require <strong>the</strong> victim to be induced<br />

into making two requests: to set <strong>the</strong> required cookie containing an XSS<br />

payload, and to request <strong>the</strong> functionality where <strong>the</strong> cookie’s value is<br />

processed in an unsafe way.<br />

n Historically, various vulnerabilities have existed in browser extension<br />

technologies, such as Flash, that have enabled cross-domain requests to be<br />

issued with arbitrary HTTP headers. Currently at least one such vulnerability<br />

is widely known but not yet patched. You could leverage one of<br />

<strong>the</strong>se vulnerabilities in browser plug-ins to make cross-domain requests<br />

containing an arbitrary cookie header designed to trigger <strong>the</strong> vulnerability.<br />

n If none of <strong>the</strong> preceding methods is successful, you can leverage any o<strong>the</strong>r<br />

reflected XSS bug on <strong>the</strong> same (or a related) domain to set a persistent<br />

cookie with <strong>the</strong> required value, <strong>the</strong>reby delivering a permanent compromise<br />

of <strong>the</strong> victim user.<br />

Exploiting XSS in <strong>the</strong> Referer Header<br />

Some <strong>application</strong>s contain reflected XSS vulnerabilities that can only be triggered<br />

via <strong>the</strong> Referer header. These are typically fairly easy to exploit using a<br />

<strong>web</strong> server controlled by <strong>the</strong> attacker. The victim is induced to request a URL<br />

on <strong>the</strong> attacker’s server that contains a suitable XSS payload for <strong>the</strong> vulnerable<br />

<strong>application</strong>. The attacker’s server returns a response that causes a request to <strong>the</strong><br />

vulnerable URL, and <strong>the</strong> attacker’s payload is included in <strong>the</strong> Referer header<br />

that is sent with this request.

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

Saved successfully!

Ooh no, something went wrong!