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.

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

}<br />

var d = document.createElement(‘div’);<br />

d.appendChild(document.createTextNode(str));<br />

return d.innerHTML;<br />

Summary<br />

This chapter has examined <strong>the</strong> various ways in which XSS vulnerabilities can<br />

arise and ways in which common filter-based defenses can be circumvented.<br />

Because XSS vulnerabilities are so prevalent, it is often straightforward to find<br />

several bugs within an <strong>application</strong> that are easy to exploit. XSS becomes more<br />

interesting, from a research perspective at least, when various defenses are in<br />

place that force you to devise some highly crafted input, or leverage some littleknown<br />

feature of HTML, JavaScript, or VBScript, to deliver a working exploit.<br />

The next chapter builds on this foundation and examines a wide variety of<br />

fur<strong>the</strong>r ways in which defects in <strong>the</strong> server-side <strong>web</strong> <strong>application</strong> may leave its<br />

users exposed to malicious attacks.<br />

Questions<br />

Answers can be found at http://mdsec.net/wahh.<br />

1. What standard “signature” in an <strong>application</strong>’s behavior can be used to<br />

identify most instances of XSS vulnerabilities?<br />

2. You discover a reflected XSS vulnerability within <strong>the</strong> unau<strong>the</strong>nticated<br />

area of an <strong>application</strong>’s functionality. State two different ways in which<br />

<strong>the</strong> vulnerability could be used to compromise an au<strong>the</strong>nticated session<br />

within <strong>the</strong> <strong>application</strong>.<br />

3. You discover that <strong>the</strong> contents of a cookie parameter are copied without<br />

any filters or sanitization into <strong>the</strong> <strong>application</strong>’s response. Can this behavior<br />

be used to inject arbitrary JavaScript into <strong>the</strong> returned page? Can it be<br />

exploited to perform an XSS attack against ano<strong>the</strong>r user?<br />

4. You discover stored XSS behavior within data that is only ever displayed<br />

back to yourself. Does this behavior have any security significance?<br />

5. You are attacking a <strong>web</strong> mail <strong>application</strong> that handles file attachments<br />

and displays <strong>the</strong>se in-browser. What common vulnerability should you<br />

immediately check for?<br />

6. How does <strong>the</strong> same-origin policy impinge upon <strong>the</strong> use of <strong>the</strong> Ajax technology<br />

XMLHttpRequest?

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

Saved successfully!

Ooh no, something went wrong!