KrisSiegel
Perch
That link has a ton of information on it, not all of it useful.
If you're using ASP.Net then you really only need to do two things when dealing with Sql Injections and XSS attacks:
1. Parametrized SQL queries (stored procs would be the best)
2. Html Encoding. For example, transforming <html> into <html>.
#1 prevents SQL injections (better protection, again, is using stored procs and never using inline SQL. Stored procs are more efficient anyway).
#2 prevents XSS (i.e. JavaScript injections).
All of these black lists, quote replacements, etc will drive you mad. What if another developer has to work on your site and they forget (or don't know) to run Request.Form["Text"] into a sanitizing method? Well, then you're screwed unless you use stored procs, parameters, and a good DAL architecture that automatically encodes Html (I can post up an example if necessary).
If you're using ASP.Net then you really only need to do two things when dealing with Sql Injections and XSS attacks:
1. Parametrized SQL queries (stored procs would be the best)
2. Html Encoding. For example, transforming <html> into <html>.
#1 prevents SQL injections (better protection, again, is using stored procs and never using inline SQL. Stored procs are more efficient anyway).
#2 prevents XSS (i.e. JavaScript injections).
All of these black lists, quote replacements, etc will drive you mad. What if another developer has to work on your site and they forget (or don't know) to run Request.Form["Text"] into a sanitizing method? Well, then you're screwed unless you use stored procs, parameters, and a good DAL architecture that automatically encodes Html (I can post up an example if necessary).
I would like to think there are better database designs that can prevent this. Is there an instance in which you need to dynamically specify a DB Object outside of a stored proc? I would like to think a good Data Access Layer would abstract any database fields and stored procs would abstract any database objects.In that example, you not only have to escape any quotes, you have to escape square brackets [] as well, because your SQL is dynamically specifying a db object (the field name).