prevent against SQL injection
I need to protect an application from SQL injection. Application is connecting to Oracle, using ADO, and search for the username and password to make the authentication.
From what I've read until now, the best approach is by using parameters, not assigning the entire SQL as string. Something like this:
query.SQL.Text := 'select * from table_name where name=:Name and id=:ID';
query.Prepare;
query.ParamByName( 'Name' ).AsString := name;
query.ParamByName( 'ID' ).AsInteger := id;
query.Open;
Also, I'm thinking to verify the input from user, and to delete SQL keywords like delete,insert,select,etc...Any input character different than normal ASCII letters and numbers will be deleted.
This will assure me a minimum of security level?
I do not want to use any other components than Delphi 7 standard and Jedi.
This will assure me a minimum of security level?
Yes parametrized queries should protect you from SQL injection which would be easy to test. Simply input some dangerous string in the name
variable and see what happens. Normally you should get 0 rows returned and not an error.
上一篇: 基于SQL注入的反锯齿效果?
下一篇: 防止SQL注入