Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old May 29th, 2002, 02:43 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Article Discussion: SQL Injection Attacks: Are You Safe?

SQL Injection Attacks: Are You Safe? If you have any questions or comments about this article, or if you've had any exposure to SQL injection attacks then please feel free to share your stories here.

You can read the article here .

Reply With Quote
  #2  
Old May 31st, 2002, 08:24 AM
nej nej is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Aarhus, Denmark
Posts: 1 nej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
magic_quotes could be a line of defense in PHP

Hey

If magic_quotes is enabled, some of the SQL injection attacks is prevented. It is pretty much equal to the stripQuotes function in the article.

Of course its by no means close to beeing a foolproof protection.

Wheater one likes magic_quotes or not, it's helping PHP to be safer out of the box.

Emil

Reply With Quote
  #3  
Old July 5th, 2002, 03:41 PM
grav grav is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 1 grav User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This article seems to be slightly incomplete in terms of guarding against attacks where an SQL numerical comparison is being used.

The killchars is a bit of a kludge. A comprehensive approach is:

(i) Any numeric comparison must cleanse user input of *everything* other than numbers, _SINGLE_ decimal point and (optionally) single leading minus sign.

(ii) Any string comparison must put user input between single quotes after replacing all single quotes with a pair.

So (i) requires something like this (just an example, this doesn't check for multiple decimal points etc.):


Private Function myVal(strField)

Dim strTemp,strDigits,char,i

strTemp = "" & strField
strDigits = ""

If Len(strTemp) < 20 Then '/* Guard against maliciously long strings */
For i = 1 To Len(strTemp)
char = Mid(strTemp,i,1)
If char >= "0" And char <="9" Or char = "." Then
strDigits = strDigits & char
End If
Next
End If

If strDigits = "" Or strDigits = "." Then
strDigits = "0"
End If

myVal = strDigits

End Function

Reply With Quote
  #4  
Old July 25th, 2002, 09:25 AM
sivenova sivenova is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 2 sivenova User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to sivenova
Exclamation Mistake

Hopefully it would not be offensive if I comment the mistake found on URL

"
select count(*) from users where userName='john' and userPass='' or 1=1 --'

In the example above i've italicised the username and password so they are a bit easier to read, but basically what is happening is that the query now only checks for any user with a username field of john. Instead of checking for a matching password, it now checks for an empty password or the conditional equation of 1=1, meaning that if the password field is empty OR 1 equals 1 (which it does), then a valid row has been found in the users table. Notice how the last quote is commented out with a single-line comment delimiter (--). This stops ASP from spitting an error about any unclosed quotations.

"
This query do not cheks for username field of john: in this condition "1=1" is always true and "or" makes it valid for all usernames and userpass no matter what they are.

Reply With Quote
  #5  
Old July 25th, 2002, 09:51 AM
DavidM DavidM is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 78 DavidM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I think it says that, just isn't obvious. Yes, since it is using an OR operator, if either condition is true, the result will be true. Therefore, username is ignored totally since 1=1 always.

Reply With Quote
  #6  
Old July 25th, 2002, 10:13 AM
sivenova sivenova is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 2 sivenova User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to sivenova
Post Continuation

No, not obvious. It is mistaken because he continues:
"
So with the login.asp script we created above, one row would be returned, and the text "Logged In" would be displayed. "

But "with the login.asp script we created above," all rows would be returned. Anyway, the article is good.

Reply With Quote
  #7  
Old October 23rd, 2002, 03:48 AM
cheffo cheffo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 1 cheffo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink No guarantees?

Hmm, it seems there is a method to be injection safe. And still using sql in asp/jsp and co.
Well, I mean safety limited to the safety of the uderlaying database.

Reply With Quote
  #8  
Old March 5th, 2003, 06:49 AM
fral fral is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 1 fral User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PreparedStatement

Using PreparedStatement (JDBC) or the ADO equivalent of parameterized queries would limit the vulnerability, wouldn't it`?

For example,
select count(*) from users where userName=? and userPass=?

In JDBC, any single quotes would be converted to double quotes and you cannot specify a column in the parameter.

/Fredrik

Reply With Quote
  #9  
Old March 6th, 2003, 05:41 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Some good doc's on SQL attacks and injection, and how to avoid them:

http://www.groar.org/expl/beginner/appt.txt

http://www.sensepost.com/misc/SQLinsertion.htm

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: SQL Injection Attacks: Are You Safe?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway