Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 SQL injection vulerability
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 14 February 2005 :  14:57:28  Show Profile  Visit MarcelG's Homepage
I'm working on a link-shrinker (http://ls.oxle.com) but I guess I'm creating a problem (possibly vulnerability).
On the first page anyone (and I mean everybody) can enter url, that's added to the db with this code:
sqlstr = "INSERT INTO links (title, description, url, catid, datein, active, hits) SELECT '"_
& strTheTitle & "' AS title,'nix' AS description,'" _
& Request.Form("url") & "' AS url,1 AS catid, #"&date&"# AS datein, "& active &" AS active, 0 AS hits;"
	objConn.Execute (sqlstr)

I guess, that since the request.form isn't checked, it can be abused by sql injection methods.
So, I'm looking for a method that prevents abuse, but that still enables any URL to be inserted (and retrieved correctly later on).

Any hints?

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 14 February 2005 14:58:25

Doug G
Support Moderator

USA
6493 Posts

Posted - 14 February 2005 :  15:28:29  Show Profile
I'd copy request.form("url") to a local variable, then run it through a sql safe function that replaces single ' with double ones and does any other checking necessary. Then concatenate the sanitized variable into your sql string rather than the raw form data.

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 14 February 2005 :  15:32:21  Show Profile  Visit MarcelG's Homepage
Doug, am I right to say that this means that not all URLs can be stored ?
In other words, an url like for instance: http://www.blah.com/test.asp?ID=adis'hjdjs&hhhdk@--1

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 14 February 2005 15:33:24
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 15 February 2005 :  16:04:39  Show Profile

safeurl = Replace("http://www.blah.com/test.asp?ID=adis'hjdjs&hhhdk@--1", "'", "''")
sql = "INSERT INTO table (urlCol) VALUES ('" & safeurl & "')"


======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000 Version 3.4.07