Escaping characters to stop SQL injection, ASP

Posted on 2010-11-14
Medium Priority
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?

Question by:Slim81
LVL 58

Expert Comment

ID: 34131764
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
LVL 81

Expert Comment

ID: 34131847
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.


LVL 31

Accepted Solution

Wayne Barron earned 2000 total points
ID: 34131951
See if this will give you what you are wanting.


Good Luck
WEBINAR: GDPR Implemented - Tips & Lessons Learned

Join the WatchGuard team on Thursday, March 29th as we recount some valuable lessons learned in weighing the needs of a business against the new regulatory environment, look ahead at the two months left before implementation, and help you understand the steps you can take today!


Expert Comment

ID: 34132144
I am not sure how to do this, but if you use prepared statements, or as they call parameterised queries.
LVL 31

Expert Comment

by:Wayne Barron
ID: 34133580
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.

Expert Comment

ID: 34136119
@carrzkiss, good one.. I havent done ASP my self, its just the prepared statements is whats called in java.. ;)

Expert Comment

ID: 34140000
One thing that you need to add too is to stop "1=1" / n=n requests in your query statement.

Author Closing Comment

ID: 34148550
Thanks for pointing me to the article you have written carrzkiss.   That information is going to help me greatly....
LVL 31

Expert Comment

by:Wayne Barron
ID: 34148707
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.

Featured Post

We Need Your Input!

WatchGuard is currently running a beta program for our new macOS Host Sensor for our Threat Detection and Response service. We're looking for more macOS users to help provide insight and feedback to help us make the product even better. Please sign up for our beta program today!

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

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
An introductory discussion about Oracle Analytic Functions which are used to calculate or compute Aggregate values, based on a group of rows.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

627 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