maxi
2008-02-16 17:05:43 UTC
Hi,
I'm using TIBSQL 6.08, and I've a sql injection problem.
Let me expose an example:
I've a sql text in a string const,
const
SQL = 'SELECT USER_ID FROM USERS WHERE USER = ? AND PSWD = ?';
by other side, I do a params replace by change ? to PARAM_% (where % is
equal to 1, 2,...n, then a get
'SELECT USER_ID FROM USERS WHERE USER = :PARAM_1 AND PSWD = :PARAM_2';
After, I do a params assignement. Params are retrive in a variant array.
I create a TIBSQL on fly and do,
if VarIsArray(vParams) then
begin
for i := 0 to VarArrayHighBound(vParams, 1) do
ibSQL.Params[i].Value := vParams[i];
end;
Well, this params assignement allow sql injection.
If in the first param (PARAM_1) which is user name, I set,
'admin' or '1'='1'
the result SQL is
SELECT USER_ID FROM USERS WHERE USER = 'admin' or '1'='1' AND PSWD = ''
This is a several security issue.
How can I solve this?
Thanks in advance.
I'm using TIBSQL 6.08, and I've a sql injection problem.
Let me expose an example:
I've a sql text in a string const,
const
SQL = 'SELECT USER_ID FROM USERS WHERE USER = ? AND PSWD = ?';
by other side, I do a params replace by change ? to PARAM_% (where % is
equal to 1, 2,...n, then a get
'SELECT USER_ID FROM USERS WHERE USER = :PARAM_1 AND PSWD = :PARAM_2';
After, I do a params assignement. Params are retrive in a variant array.
I create a TIBSQL on fly and do,
if VarIsArray(vParams) then
begin
for i := 0 to VarArrayHighBound(vParams, 1) do
ibSQL.Params[i].Value := vParams[i];
end;
Well, this params assignement allow sql injection.
If in the first param (PARAM_1) which is user name, I set,
'admin' or '1'='1'
the result SQL is
SELECT USER_ID FROM USERS WHERE USER = 'admin' or '1'='1' AND PSWD = ''
This is a several security issue.
How can I solve this?
Thanks in advance.