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.

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

HACK STEPS<br />

1. Having submitted a unique string to every possible location within <strong>the</strong><br />

<strong>application</strong>, you must review all of <strong>the</strong> <strong>application</strong>’s content and functionality<br />

once more to identify any instances where this string is displayed<br />

back to <strong>the</strong> browser. User-controllable data entered in one location (for<br />

example, a name field on a personal information page) may be displayed<br />

in numerous places throughout <strong>the</strong> <strong>application</strong>. (For example, it could<br />

be on <strong>the</strong> user’s home page, in a listing of registered users, in work flow<br />

items such as tasks, on o<strong>the</strong>r users’ contact lists, in messages or questions<br />

posted by <strong>the</strong> user, or in <strong>application</strong> logs.) Each appearance of <strong>the</strong><br />

string may be subject to different protective filters and <strong>the</strong>refore needs to<br />

be investigated separately.<br />

2. If possible, all areas of <strong>the</strong> <strong>application</strong> accessible by administrators<br />

should be reviewed to identify <strong>the</strong> appearance of any data controllable by<br />

non-administrative users. For example, <strong>the</strong> <strong>application</strong> may allow administrators<br />

to review log files in-browser. It is extremely common for this<br />

type of functionality to contain XSS vulnerabilities that an attacker can<br />

exploit by generating log entries containing malicious HTML.<br />

3. When submitting a test string to each location within <strong>the</strong> <strong>application</strong>, it is<br />

sometimes insufficient simply to post it as each parameter to each page.<br />

Many <strong>application</strong> functions need to be followed through several stages<br />

before <strong>the</strong> submitted data is actually stored. For example, actions such<br />

as registering a new user, placing a shopping order, and making a funds<br />

transfer often involve submitting several different requests in a defined<br />

sequence. To avoid missing any vulnerabilities, it is necessary to see each<br />

test case through to completion.<br />

4. When probing for reflected XSS, you are interested in every aspect of a<br />

victim’s request that you can control. This includes all parameters to <strong>the</strong><br />

request, every HTTP header, and so on. In <strong>the</strong> case of stored XSS, you<br />

should also investigate any out-of-band channels through which <strong>the</strong><br />

<strong>application</strong> receives and processes input you can control. Any such channels<br />

are suitable attack vectors for introducing stored XSS attacks. Review<br />

<strong>the</strong> results of your <strong>application</strong> mapping exercises (see Chapter 4) to identify<br />

every possible area of attack surface.<br />

5. If <strong>the</strong> <strong>application</strong> allows files to be uploaded and downloaded, always<br />

probe this functionality for stored XSS attacks. Detailed techniques for<br />

testing this type of functionality are discussed later in this chapter.<br />

6. Think imaginatively about any o<strong>the</strong>r possible means by which data you<br />

control may be stored by <strong>the</strong> <strong>application</strong> and displayed to o<strong>the</strong>r users. For<br />

example, if <strong>the</strong> <strong>application</strong> search function shows a list of popular search<br />

items, you may be able to introduce a stored XSS payload by searching<br />

for it numerous times, even though <strong>the</strong> primary search functionality itself<br />

handles your input safely.

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

Saved successfully!

Ooh no, something went wrong!