Slim81
asked on
Escaping characters to stop SQL injection, ASP
Hi Guys and Gals,
I have an ASP site in which users are adding items to the DB (login, password, and a little bit of other info). I am looking for a way to stop the chance of SQL injections from happening.
I also use Dreamweaver to build the site and to make the majority of the DB connections and inserts/updates, etc.
My idea is to remove possible characters from the user generated form data before it hit the sql string. Here is a list of character I was thinking of removing or not allowing: =, <, >, /-+*, ', "
My idea was to build a function that would remove all of the characters listed above.
Would that stop SQL injection attacks?
Thanks,
Slim
I have an ASP site in which users are adding items to the DB (login, password, and a little bit of other info). I am looking for a way to stop the chance of SQL injections from happening.
I also use Dreamweaver to build the site and to make the majority of the DB connections and inserts/updates, etc.
My idea is to remove possible characters from the user generated form data before it hit the sql string. Here is a list of character I was thinking of removing or not allowing: =, <, >, /-+*, ', "
My idea was to build a function that would remove all of the characters listed above.
Would that stop SQL injection attacks?
Thanks,
Slim
The best way is to validate the data being provided to match the input being expected and not passing the input data directly to the sql.
http://forums.asp.net/t/1254125.aspx
http://msdn.microsoft.com/en-us/library/ff648339.aspx
http://forums.asp.net/t/1254125.aspx
http://msdn.microsoft.com/en-us/library/ff648339.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am not sure how to do this, but if you use prepared statements, or as they call parameterised queries.
@YohanF
Yes, it is called that, and it listed in the article that I wrote of which I provided the link for.
Which gives you everything that you need to learn how to do it.
Have a good one.
Carrzkiss
Yes, it is called that, and it listed in the article that I wrote of which I provided the link for.
Which gives you everything that you need to learn how to do it.
Have a good one.
Carrzkiss
@carrzkiss, good one.. I havent done ASP my self, its just the prepared statements is whats called in java.. ;)
One thing that you need to add too is to stop "1=1" / n=n requests in your query statement.
ASKER
Thanks for pointing me to the article you have written carrzkiss. That information is going to help me greatly....
You are most welcome Slim.
I learned how to do the Parameterized queries the beginning of 2009
And would not change the way I code today for nothing in this world.
If you jump over and do any VB.NET programming, then it is changed up slightly
But not much, I am still learning it, but is not at the top of my priority list at the moment.
Take care and have a good one.
Carrzkiss
I learned how to do the Parameterized queries the beginning of 2009
And would not change the way I code today for nothing in this world.
If you jump over and do any VB.NET programming, then it is changed up slightly
But not much, I am still learning it, but is not at the top of my priority list at the moment.
Take care and have a good one.
Carrzkiss
O'brian said, "30+ only please"
It makes sense in some limited uses, but generally you should look at using parameters to state exactly what input matches what parts of the query, letting parameterization take care of protection