views:

92

answers:

2

I am using ASP.NET and on ASP.NET page has validate attribute which checks for the XSS validations. However i would like to know that is it really sufficient ?

I have visited some of the related post on stackoverflow and that helped me but i am looking to understand how to plan for XSS when developing web sites ?

Do we have to check XSS on client side, AJAX also ? How to do that ? Are there any tools which can help testing the XSS ?

Thanks,

+4  A: 

These are the basics:

  • Do not allow HTML input
  • Always html encode input when displaying it
  • Use the AntiXSSLibrary from Microsoft, or a similar library
Oded
Although people always say "do not modify user input when inserting it to the DB" which may contain HTML...
Dor
@Dor - Where did I say anything about inserting to DB?
Oded
You didn't, but when you receive input from the user, you usually insert that to the database.
Dor
Then how to deal with situation where we have to insert data into the database ? should we restrict the user while entering the data on client side ?
Anil Namde
You insert into the DB what the client entered. When you display the data, html encode it (or use the AntiXSS Library).
Oded
@Anil Namde: Never trust the client-side limitations that you reflect on the user! Those limitations are for user convenience only!
Dor
+2  A: 

Check it out: Allowing HTML and Preventing XSS @ shiflett.org

Dor