• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

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
0
Slim81
Asked:
Slim81
1 Solution
 
cyberkiwiCommented:
That will stop names like Jean-luc and comments like
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
0
 
arnoldCommented:
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
0
 
Wayne BarronAuthor, Web DeveloperCommented:
See if this will give you what you are wanting.

http://www.experts-exchange.com/A_3626.html


Good Luck
Carrzkiss
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
YohanFCommented:
I am not sure how to do this, but if you use prepared statements, or as they call parameterised queries.
0
 
Wayne BarronAuthor, Web DeveloperCommented:
@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
0
 
YohanFCommented:
@carrzkiss, good one.. I havent done ASP my self, its just the prepared statements is whats called in java.. ;)
0
 
rmm2001Commented:
One thing that you need to add too is to stop "1=1" / n=n requests in your query statement.
0
 
Slim81Author Commented:
Thanks for pointing me to the article you have written carrzkiss.   That information is going to help me greatly....
0
 
Wayne BarronAuthor, Web DeveloperCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now