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 435<br />

Sure enough, when <strong>the</strong> page is rendered within <strong>the</strong> user’s browser, <strong>the</strong> popup<br />

message appears, as shown in Figure 12-2.<br />

Figure 12-2: A proof-of-concept XSS exploit<br />

Performing this simple test serves verifies two important things. First, <strong>the</strong><br />

contents of <strong>the</strong> message parameter can be replaced with arbitrary data that gets<br />

returned to <strong>the</strong> browser. Second, whatever processing <strong>the</strong> server-side <strong>application</strong><br />

is performing on this data (if any), it is insufficient to prevent us from supplying<br />

JavaScript code that is executed when <strong>the</strong> page is displayed in <strong>the</strong> browser.<br />

TRY IT!<br />

http://mdsec.net/error/5/<br />

NOTE If you try examples like this in Internet Explorer, <strong>the</strong> pop-up may fail to<br />

appear, and <strong>the</strong> browser may show <strong>the</strong> message “Internet Explorer has modified<br />

this page to help prevent cross-site scripting.” This is because recent versions<br />

of Internet Explorer contain a built-in mechanism designed to protect<br />

users against reflected XSS vulnerabilities. If you want to test <strong>the</strong>se examples,<br />

you can try a different browser that does not use this protection, or you can disable<br />

<strong>the</strong> XSS filter by going to Tools ÿ Internet Options ÿ Security ÿ Custom<br />

Level. Under Enable XSS filter, select Disable. We will describe how <strong>the</strong> XSS filter<br />

works, and ways in which it can be circumvented, later in this chapter.<br />

This type of simple XSS bug accounts for approximately 75% of <strong>the</strong> XSS<br />

vulnerabilities that exist in real-world <strong>web</strong> <strong>application</strong>s. It is called reflected<br />

XSS because exploiting <strong>the</strong> vulnerability involves crafting a request containing<br />

embedded JavaScript that is reflected to any user who makes <strong>the</strong> request. The<br />

attack payload is delivered and executed via a single request and response. For<br />

this reason, it is also sometimes called first-order XSS.

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

Saved successfully!

Ooh no, something went wrong!