Click here to Skip to main content
15,891,951 members
Home / Discussions / Database
   

Database

 
GeneralSQL Injection Pin
Ritesh12349-Jan-08 12:48
Ritesh12349-Jan-08 12:48 
GeneralRe: SQL Injection Pin
Mark Churchill9-Jan-08 21:33
Mark Churchill9-Jan-08 21:33 
GeneralRe: SQL Injection Pin
Ritesh123410-Jan-08 4:27
Ritesh123410-Jan-08 4:27 
GeneralRe: SQL Injection Pin
Colin Angus Mackay12-Jan-08 1:32
Colin Angus Mackay12-Jan-08 1:32 
GeneralRe: SQL Injection Pin
Dave-B10-Jan-08 5:31
Dave-B10-Jan-08 5:31 
GeneralRe: SQL Injection Pin
Ritesh123410-Jan-08 9:07
Ritesh123410-Jan-08 9:07 
GeneralRe: SQL Injection Pin
Pete O'Hanlon10-Jan-08 9:55
mvePete O'Hanlon10-Jan-08 9:55 
GeneralRe: SQL Injection Pin
Dave Kreskowiak10-Jan-08 10:04
mveDave Kreskowiak10-Jan-08 10:04 
Ritesh1234 wrote:
Can u pls help me out to find in what way this query can venerable to SQL injection


Yes, it's STILL an injection attack, and a rather successful one if the code that depends on this query doesn't expect to find 0 results comming back. The replacement of ' with '' is NOT a guarantee against injection attacks, and neither is using parameterized queries, though using parameters and the SqlParameter objects does look for other possible problems that you don't normally think of, such as DateTime representation in the SQL statement.

Simply put, there is no reason NOT to use parameterized queries and stored procedures. It makes you code much more robust, easier to debug, and easier to support when it breaks, not if. It's also no excuse for not thoroughly checking user input before you pass it to SQL, which is what you're code snippet is suggesting you're not doing. Consider ALL user input as evil. It MUST go through validation testing before you try to use it.

What if the user typed in 1000+ characters into that textbox?? What happens when you pass that to your SQL, which is only expecting, maybe, 14 characters??

What you have is a lazy way of attempting to secure your SQL code without understanding what an SQL Injection attack really is. Make no mistake, your "solution" is not secure, not in the least.

Read this[^] or Colin will make you read it.



A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007




GeneralRe: SQL Injection Pin
Ritesh123411-Jan-08 3:14
Ritesh123411-Jan-08 3:14 
GeneralRe: SQL Injection Pin
Dave Kreskowiak11-Jan-08 6:42
mveDave Kreskowiak11-Jan-08 6:42 
GeneralMySql C# Stored Function Problem Pin
js800859-Jan-08 6:34
js800859-Jan-08 6:34 
GeneralHelp in query design Pin
www.Developerof.NET9-Jan-08 5:35
www.Developerof.NET9-Jan-08 5:35 
GeneralRe: Help in query design Pin
DotNetXenon9-Jan-08 7:58
DotNetXenon9-Jan-08 7:58 
GeneralRe: Help in query design Pin
GuyThiebaut9-Jan-08 10:06
professionalGuyThiebaut9-Jan-08 10:06 
GeneralRe: Help in query design Pin
veereshIndia13-Jan-08 19:46
veereshIndia13-Jan-08 19:46 
GeneralASP.Net: Custom control problem with XML file data source Pin
Emma Burrows9-Jan-08 5:35
Emma Burrows9-Jan-08 5:35 
Generalda.Fill(second datatable) Pin
CandyMe9-Jan-08 5:20
CandyMe9-Jan-08 5:20 
GeneralRe: da.Fill(second datatable) Pin
Tom Deketelaere9-Jan-08 5:25
professionalTom Deketelaere9-Jan-08 5:25 
GeneralRe: da.Fill(second datatable) Pin
CandyMe9-Jan-08 5:32
CandyMe9-Jan-08 5:32 
GeneralRe: da.Fill(second datatable) Pin
Tom Deketelaere9-Jan-08 7:34
professionalTom Deketelaere9-Jan-08 7:34 
Questioninsert special characters into sql database Pin
swissmiss869-Jan-08 5:02
swissmiss869-Jan-08 5:02 
GeneralRe: insert special characters into sql database Pin
Ritesh12349-Jan-08 12:54
Ritesh12349-Jan-08 12:54 
Generalforce table names [modified] admin please move post to vb.net forum (thank you) Pin
Tom Deketelaere9-Jan-08 3:47
professionalTom Deketelaere9-Jan-08 3:47 
GeneralCalculation not done in SubQuery :( Pin
ha_haseebahmad9-Jan-08 0:20
ha_haseebahmad9-Jan-08 0:20 
Questionhow to define a result a in a sp Pin
jagan1238-Jan-08 23:21
jagan1238-Jan-08 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.