General ANti SQL Injection measures? - Posted (1377 Views)
New Member
kyodai
Posts: 74
74
Hi folks,

just working on an online RPG that is integrated into my forums.
I noticed the usual method to grasp strings or integers like this

Code:
if Request.QueryString("moveloc") <> "" then
myMoveloc = Request.QueryString("moveloc")
end if
strSql = "SELECT K

is terribly vulnerable for SQL injection if you add like
Code:
1';DROP TABLE users; SELECT * FROM data WHERE 't' = 't
to the plece where there is usual the location number in the url(Yeah i know that isnt syntactically correct, but you get what i mean).
So i filter for that with like



Code:
if instr(myMoveloc, "'") then
myMoveloc = ""
end if


But i think that ' isn't the only character that can be used for sql injection (prolly some URL escape characters or so should be filtered as well). How can i filter out all of them?




Edit: OK i now filter out ' ; = " and * as i feel these should not appear normally in a value that can only hold integers. Should i also add SQL commands like "SELECT", "DROP", "UPDATE" and so on to be sure???

Code:

if Request.QueryString("moveloc") <> "" then
'pipe it into myMoveloc
'we move
myMoveloc = Request.QueryString("moveloc")
if instr(myMoveloc, "'") then
myMoveloc = ""
end if
if instr(myMoveloc, ";") then
myMoveloc = ""
end if
if instr(myMoveloc, """") then
myMoveloc = ""
end if
if instr(myMoveloc, "*") then
myMoveloc = ""
end if
if instr(myMoveloc, "=") then
myMoveloc = ""
end if

strSql = "SELECT
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Forum Admin
HuwR
Posts: 20611
20611
http://blogs.iis.net/nazim/archive/2008/04/28/filtering-sql-injection-from-classic-asp.aspx
Posted
New Member
kyodai
Posts: 74
74
Whoa, thanks for posting, this is the best solution ever. =)
 
You Must enter a message