Cross Site Scripting (XSS)   Leave a comment

What is cross site scripting? 

Cross site scripting “XSS” in short is a way using that hacker can inject the JavaScript into your web page.

Cross site scripting used to trick users into running JavaScript code and also used to steal the cookies data.

Let’s take a simple example to understand this, lets say you have the below URL and you are submitting the request to server using the GET method

URL:  Register.aspx?

and after submitting this request your web site storing the same into database and also executing the same request server side as well as client side.

What hackers do, they change the URL like shown below and submit the same


So, when you take this data from database or read it from query string then system will show the alert message with “Gotcha!” as the text.

This is the simple example, hackers can do many major activities and harm your web site and they succeed because “Cross Site Scripting” is done via another web site and since it is done using JavaScript browser allow it as browser trusts JavaScript.

Browsers also allow the JavaScript to access the cookies data, so whatever information you are storing into the cookies related to user hacker can hack the same, change the value and submit it back.

Solution to XSS:

Sanitize the dynamic data coming as input or that gets output to the browsers. This data can be in the form of HTML, XML, JSON, JavaScript, etc.

Sanitize the data while storing the same into database or retrieving it from database.

Sometimes HTML must allowed (Content Management System), use the concept of Black listing and White listing in order to allow / prevent the tags to be used along with content being displayed on the site.

Recommended solution is to use the White Listing solution for CMS tags. Apart from these tags sanitize everything else.


Posted October 5, 2014 by Izharuddin Shaikh in Web

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: