Solved

Escaping characters to stop SQL injection, ASP

Posted on 2010-11-14
9
592 Views
Last Modified: 2012-06-27
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
Comment
Question by:Slim81
9 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
Comment Utility
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
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
Comment Utility
See if this will give you what you are wanting.

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


Good Luck
Carrzkiss
0
 
LVL 6

Expert Comment

by:YohanF
Comment Utility
I am not sure how to do this, but if you use prepared statements, or as they call parameterised queries.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 30

Expert Comment

by:Wayne Barron
Comment Utility
@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
 
LVL 6

Expert Comment

by:YohanF
Comment Utility
@carrzkiss, good one.. I havent done ASP my self, its just the prepared statements is whats called in java.. ;)
0
 
LVL 7

Expert Comment

by:rmm2001
Comment Utility
One thing that you need to add too is to stop "1=1" / n=n requests in your query statement.
0
 
LVL 4

Author Closing Comment

by:Slim81
Comment Utility
Thanks for pointing me to the article you have written carrzkiss.   That information is going to help me greatly....
0
 
LVL 30

Expert Comment

by:Wayne Barron
Comment Utility
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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
A brand new malware strain was recently discovered by security researchers at Palo Alto Networks dubbed “AceDeceiver.” This new strain of iOS malware can successfully infect non-jailbroken devices and jailbroken devices alike.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now