Click here to Skip to main content
15,909,498 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Injection Pin
Expert Coming14-Nov-07 20:15
Expert Coming14-Nov-07 20:15 
GeneralRe: SQL Injection Pin
Shajeel14-Nov-07 21:19
Shajeel14-Nov-07 21:19 
AnswerRe: SQL Injection Pin
N a v a n e e t h14-Nov-07 21:46
N a v a n e e t h14-Nov-07 21:46 
GeneralRe: SQL Injection Pin
Shajeel14-Nov-07 21:56
Shajeel14-Nov-07 21:56 
GeneralRe: SQL Injection Pin
Pete O'Hanlon15-Nov-07 0:00
mvePete O'Hanlon15-Nov-07 0:00 
GeneralRe: SQL Injection Pin
Colin Angus Mackay15-Nov-07 0:01
Colin Angus Mackay15-Nov-07 0:01 
GeneralRe: SQL Injection Pin
Vasudevan Deepak Kumar15-Nov-07 4:50
Vasudevan Deepak Kumar15-Nov-07 4:50 
GeneralRe: SQL Injection Pin
DQNOK15-Nov-07 9:56
professionalDQNOK15-Nov-07 9:56 
Shajeel wrote:
all examples in the article starts with '


No, one of the examples began with a number, not a quote:

string sql = "SELECT * FROM Orders WHERE DATEPART(YEAR, OrderDate) = "+
this.orderYearTb.Text);

and the attacker began his string with a zero.

Does seem to me that all the examples I've seen had statement delimiters embedded within them. Therefore, I have two functions I run against the input. The first effectively converts ' to '', but also checks for a maximum length of the argument. If I know the maximum length of the field my user wants to compare against, a string longer than this is rejected outright as a possible attack. The next function removes any unquoted semicolons. This will cause attacking SQL to be ill-formed and rejected for syntax. But DON'T respond to the user with the ill-formed string. They may be able to see thru the protection scheme.

While this two-prong approach defeates every injection example I have ever seen, it does not guarantee, as Colin suggested, that someone clever won't come up with a way to defeat it. Plus, as Pete inferred, the SQL validation (in my case, converting ' to '' and removing unquoted semicolons) must be done immediately before submitting the SQL string to the db for processing. You must not rely on external validation.


David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------

QuestionCompressing an MS SQL Server 2005 database Pin
Steven J Jowett14-Nov-07 6:39
Steven J Jowett14-Nov-07 6:39 
AnswerRe: Compressing an MS SQL Server 2005 database Pin
Hesham Amin14-Nov-07 8:22
Hesham Amin14-Nov-07 8:22 
AnswerRe: Compressing an MS SQL Server 2005 database Pin
pmarfleet14-Nov-07 8:38
pmarfleet14-Nov-07 8:38 
QuestionIndexing Keys Pin
Brendan Vogt14-Nov-07 6:35
Brendan Vogt14-Nov-07 6:35 
AnswerRe: Indexing Keys Pin
Hesham Amin14-Nov-07 8:31
Hesham Amin14-Nov-07 8:31 
AnswerRe: Indexing Keys Pin
Pete O'Hanlon14-Nov-07 9:26
mvePete O'Hanlon14-Nov-07 9:26 
QuestionDifferent Services Pin
Brendan Vogt14-Nov-07 6:33
Brendan Vogt14-Nov-07 6:33 
AnswerRe: Different Services Pin
Expert Coming14-Nov-07 20:21
Expert Coming14-Nov-07 20:21 
Questionhow to read from idx file Pin
SABhatti14-Nov-07 5:47
SABhatti14-Nov-07 5:47 
AnswerRe: how to read from idx file Pin
Colin Angus Mackay14-Nov-07 5:48
Colin Angus Mackay14-Nov-07 5:48 
GeneralRe: how to read from idx file Pin
SABhatti14-Nov-07 5:57
SABhatti14-Nov-07 5:57 
GeneralRe: how to read from idx file Pin
DQNOK16-Nov-07 4:28
professionalDQNOK16-Nov-07 4:28 
AnswerCross post. Please ignore this thread. Pin
Pete O'Hanlon14-Nov-07 9:21
mvePete O'Hanlon14-Nov-07 9:21 
GeneralRe: Cross post. Please ignore this thread. Pin
SABhatti14-Nov-07 9:47
SABhatti14-Nov-07 9:47 
Questioncan one use dt_validateloginparams for login promts Pin
jchalfant14-Nov-07 4:35
jchalfant14-Nov-07 4:35 
QuestionSQL 2005 vs SQL 6.5 Pin
Malcolm Smart14-Nov-07 1:46
Malcolm Smart14-Nov-07 1:46 
AnswerRe: SQL 2005 vs SQL 6.5 Pin
Rob Philpott14-Nov-07 2:24
Rob Philpott14-Nov-07 2:24 

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.