Phil Sando

  Home  |   Contact  |   Syndication    |   Login
  13 Posts | 0 Stories | 3 Comments | 0 Trackbacks

News

Twitter












Archives

Image Galleries

make sure all queries are parameterised like this:

sql = ("select * from contacts where contactid = @id")
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
cmd.Parameters.Add("@id", SqlDbType.VarChar)
cmd.Parameters("@id").Value = id

I also include a usercontrol which checks the querystring for bad terms:

The list is long but this snippet should give you the gist of it:

Dim querystringvar As String = Request.QueryString.ToString
If InStr(querystringvar, "drop") Then
Response.Redirect("/errors/504.aspx)
ElseIf InStr(querystringvar, "select") Then
Response.Redirect("/errors/504.aspx)

 

posted on Friday, January 29, 2010 12:39 PM

Feedback

# re: Stopping SQL Injection Attacks (my best efforts, comments pls) 1/29/2010 6:05 PM Sanjay Uttam
I think you're fine just doing the built in parametrization or using stored procs [without dynamic sql]. BTW, I hope you aren't taking the error querystring parameter and displaying it on the 504.aspx page....(of HTML encoding it, if you are)

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: