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.

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

When you have identified every instance in which user-controllable data is<br />

stored by <strong>the</strong> <strong>application</strong> and later displayed back to <strong>the</strong> browser, you should<br />

follow <strong>the</strong> same process described previously for investigating potential reflected<br />

XSS vulnerabilities. That is, determine what input needs to be submitted to<br />

embed valid JavaScript within <strong>the</strong> surrounding HTML, and <strong>the</strong>n attempt to<br />

circumvent any filters that interfere with <strong>the</strong> processing of your attack payload.<br />

TIP When probing for reflected XSS, it is easy to identify which request<br />

parameters are potentially vulnerable. You can test one parameter at a time<br />

and review each response for any appearance of your input. With stored XSS,<br />

however, this may be less straightforward. If you submit <strong>the</strong> same test string<br />

as every parameter to every page, you may find this string reappearing at<br />

multiple locations within <strong>the</strong> <strong>application</strong>. It may not be clear from <strong>the</strong> context<br />

precisely which parameter is responsible for <strong>the</strong> appearance. To avoid this<br />

problem, you can submit a different test string as every parameter when probing<br />

for stored XSS flaws. For example, you can concatenate your unique string<br />

with <strong>the</strong> name of <strong>the</strong> field it is being submitted to.<br />

Some specific techniques are applicable when testing for stored XSS vulnerabilities<br />

in particular types of functionality. The following sections examine<br />

some of <strong>the</strong>se in more detail.<br />

Testing for XSS in Web Mail Applications<br />

As we have discussed, <strong>web</strong> mail <strong>application</strong>s are inherently at risk of containing<br />

stored XSS vulnerabilities, because <strong>the</strong>y include HTML content received<br />

directly from third parties within <strong>application</strong> pages that are displayed to users.<br />

To test this functionality, ideally you should obtain your own e-mail account<br />

on <strong>the</strong> <strong>application</strong>, send various XSS exploits in e-mail messages to yourself,<br />

and view each message within <strong>the</strong> <strong>application</strong> to determine whe<strong>the</strong>r any of <strong>the</strong><br />

exploits are successful.<br />

To perform this task in a thorough manner, you need to send all kinds of<br />

unusual HTML content within e-mails, as we described to test for bypasses in<br />

input filters. If you restrict yourself to using a standard e-mail client, you will<br />

likely find that you have insufficient control over <strong>the</strong> raw message content, or<br />

<strong>the</strong> client may itself sanitize or “clean up” your deliberately malformed syntax.<br />

In this situation, it is generally preferable to use an alternative means of generating<br />

e-mails that gives you direct control over <strong>the</strong> contents of messages. One<br />

method of doing this is using <strong>the</strong> UNIX sendmail command. You need to have<br />

configured your computer with <strong>the</strong> details of <strong>the</strong> mail server it should use to<br />

send outgoing mail. Then you can create your raw e-mail in a text editor and<br />

send it using this command:<br />

sendmail -t test@example.org < email.txt

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

Saved successfully!

Ooh no, something went wrong!