?
Solved

Escaping characters to stop SQL injection, ASP

Posted on 2010-11-14
9
Medium Priority
?
613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
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
0
 
LVL 79

Expert Comment

by:arnold
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.

http://forums.asp.net/t/1254125.aspx

http://msdn.microsoft.com/en-us/library/ff648339.aspx
0
 
LVL 31

Accepted Solution

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

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


Good Luck
Carrzkiss
0
Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

 
LVL 6

Expert Comment

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

Expert Comment

by:Wayne Barron
ID: 34133580
@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
ID: 34136119
@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
ID: 34140000
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
ID: 34148550
Thanks for pointing me to the article you have written carrzkiss.   That information is going to help me greatly....
0
 
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.
Carrzkiss
0

Featured Post

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SHARE your personal details only on a NEED to basis. Take CHARGE and SECURE your IDENTITY. How do I then PROTECT myself and stay in charge of my own Personal details (and) - MY own WAY...
Read about achieving the basic levels of HRIS security in the workplace.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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