tags:

views:

84

answers:

3

Wikipedia provides information about one of the most common scenarios for exploiting a reflected cross site scripting attack - using some degree of social engineering to induce unsuspecting users to click a malicious link:

  1. Alice often visits a particular website, which is hosted by Bob. Bob's website allows Alice to log in with a username/password pair and stores sensitive data, such as billing information.
  2. Mallory observes that Bob's website contains a reflected XSS vulnerability.
  3. Mallory crafts a URL to exploit the vulnerability, and sends Alice an email, enticing her to click on a link for the URL under false pretenses. This URL will point to Bob's website, but will contain Mallory's malicious code, which the website will reflect.
  4. Alice visits the URL provided by Mallory while logged into Bob's website.
  5. The malicious script embedded in the URL executes in Alice's browser, as if it came directly from Bob's server (this is the actual XSS vulnerability). The script can be used to send Alice's session cookie to Mallory. Mallory can then use the session cookie to steal sensitive information available to Alice (authentication credentials, billing info, etc.) without Alice's knowledge.

Now, this is usually tends to be very good example when the website happens to be a page-driven application - the vulnerability is exploited by getting the user to submit a malicious payload to the application (more importantly, by issuing a GET request when logged in) which is reflected back in the response.

Are there any more interesting attack vectors, especially ones to consider when the application utilizes a lot of AJAX with most of the requests being made over HTTP POST?

EDIT

In case I wasn't clear, I'd like to know the various types of attacks vectors applicable to reflected XSS attacks, especially when the client-side tier of the application is implemented differently. Page-based applications would have an attack vector involving HTTP GET requests issued from a user, but it would be interesting to know how this plays out for thick client applications especially the ones using XMLHttpRequest objects that issue HTTP POST requests. Different mechanisms used in client-side rendering will obviously warrant study of different attack vectors. In some cases, there might not be any applicable attack vectors; the question is expressed to elicit such a response.

+1  A: 

Yes, in fact there are a few variations on the reflective XSS attack. Mostly notibly is the Samy Worm. In short Samy used XSS to fire off an XHR to MySpace.com to read the CSRF token and forge POST request. In fact this is a general attack pattern that is useful for attacking sites that are using httponly cookies. As the use of httponly cookies becomes more popular, so will this attack pattern.

Another xss payload is the XSS Shell. This provides the attacker an interactive channel to the browser.

XSS is used to deliver a "Drive-By-Download" attack.

Xss can also be used to fake the news. With xss against news sources regularly being found, this is a rather serious problem.

Edit: You might also be interested how the Apache foundation got owned using xss and tinyurl. Here is an exploit that I wrote which uses a Samy style attack in order to obtain CSRF.

Rook
Thanks for the response; some of the links are interesting. I've just finished reading the paper on XSS Shell. To clarify what I'm looking for, I was actually interested in knowing more about the initial "infection" process more than what can be achieved after infection. Crudely put, the question is "How do I exploit the reflected XSS vulnerability in an app, with some amount of social engineering involved?". Given that not all apps are built alike, pulling off an attack against GMail would different compared to CNN; this is example might be too narrow, but I hope you get the idea.
Vineet Reynolds
@Vineet Reynolds To be honest this is for programming questions, and I'm more interested in writing exploit code than tricking people to click on links. If you are interested in social engineering you should look elsewhere. However you maybe interested in my edit.
Rook
@The Rook, just in case I haven't been misunderstood, I'm not interested in the social engineering aspect as well. As far as exploit preparation is concerned, I haven't seen anything beyond the simple link-in-an-email kind of attacks. That is why I'm interested in knowing how exploits are be written if HTTP form submits or XHR has to be used. I believe the second link contains answer to what I'm looking for.
Vineet Reynolds
@Vineet Reynolds aah, then yes, I would refer to my pligg exploit. If you would like to learn more about csrf, you should read the google browsersec handbook in its entirety.
Rook
+1  A: 

Reflected XSS occurs when a page displays malicious user input. The question "what attack vectors are there?" is therefore synonymous to "what user input can a page receive?"

Some sources are:

  • The query string of a GET request which can come from:
    • a URL in an email
    • a redirect (via js, 301 response, or meta tag) from a hacked or malicious site
  • The body of a POST request which can come from:
    • an AJAX POST request from any domain (Same Origin Policy doesn't stop the request, just parsing the response)
    • Any form with method="POST" and action="XSSed_site.com". Forms can be posted via js, or by clicking on a button which could be done using click-jacking.
  • Other forms of input such as:
    • external js files like table sorters or libraries that the attacked page is using
    • server-to-server communication that is displayed on the attacked page
    • any other data displayed on the page being attacked that can be altered by the attacker

I realize that the "Other forms of input" section looks more like a stored XSS vulnerability, but each application is unique, and some may translate user input into how external pieces are composed into the page (hence reflected).

A query string in a GET request from a phished email is certainly not the only vector for reflected XSS (good question though).

Ben Broussard
+2  A: 

Hey Vineet,

benlbroussard touched on this already, but I want to reiterate it because of the importance. Fat client, thin client, POST, GET, PUT; none of these things matter. An XSS hole is based on a site incorrectly rendering some input back to somebody.

If you're looking for a strictly reflected attack then the payload shouldn't be stored anywhere in the target app. In that case I think you're right that a fat client will trend towards being more resistant because a GET is the easiest ways to initiate a reflected XSS attack.

Regarding more attack vectors, one interesting thing about fat client architecture is entity encoding. A thin client can entity encode everything and be done with it, with great benefit. A fat client should entity encode the response to an initial GET, but asynchronous requests with replies headed for JavaScript can't be (entirely) encoded and be valid JS. This back and forth increases the chance of not encoding something that should be, which is a big step towards creating an XSS vector.

Make sense?

Carl

Carl
@Carl, everything makes sense except for entity encoding of requests by the client. I believe that clients should utilize the encoding rules as stipulated in the underlying protocol (HTTP), for having multiple encodings in place could lead to attacks employing multiple levels of encoding. That aside, most of the other things make sense - AJAX (with XML in the response) is better than AJAH (with HTML) if one needs to protect against XSS is something that I've derived.
Vineet Reynolds
@Vineet, good deal. I'm afraid my post is poorly written, I was actually referring to entity encoding responses from the server, not requests from the client. Big difference right?I don't understand how XML is better than HTML. My thought is all that matters is how you use the response in JS, and that informs how it needs to be protected. Evaluating it as JS introduces some vectors, inserting it into the DOM introduces others. What am I missing?
Carl
@Carl, DOM injection is an interesting topic. Again deriving an idea here - JavaScript that is present (in a CDATA section perhaps) in the server's response (which is an XML document), can be interpreted if the developer has implemented the presentation logic in that manner. Certainly not a good practice, that won't stop people from coding such a monstrosity, which lends itself as an avenue for attack. I didn't think of this earlier, and therefore assumed that AJAX is safer than AJAH.
Vineet Reynolds