Solved

Escaping characters to stop SQL injection, ASP

Posted on 2010-11-14
9
604 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 78

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 500 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
When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you thought ransomware was bad, think again! Doxware has the potential to be even more damaging.
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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