Stephen_Sbh


Hi,

Just read about SQL injection, and tested it out with sample database, and it does hack my database, the article show to prevent SQL injection by using application code to remove those keywords and change single quote to double quote, is there any method to prevent SQL injection directly using the database system itself, maybe stored procedure or anything

Thanks.




Re: Protect from SQL Injection?

Arnie Rowland


Stored Procedures are a major line of defense against SQL injection attacks.





Re: Protect from SQL Injection?

StephenSaw

Hi,
Do we need to write any codes or statement inside our stored procedure to avoid SQL injection





Re: Protect from SQL Injection?

Arnie Rowland

Under most circumstances, passing in string parameters will cause the parameter value to be handled as a string (enclosed with quotes).

If it is a keyword, then that keyword will most likely be contextually ignored, or cause an error.

If there are embedded quotes or comment indicators, then that parameter is stripped upon entry and the offending part is discarded.

There is still the possiblity for 'cross-site' scripting issues related to causing the storage of embedded html, and then displaying that embedded html on the web page.

You may find a visit to (and do a search for 'sql injection' to be worthwhile:

www.sqlservercentral.com

www.sqlteam.com






Re: Protect from SQL Injection?

StephenSaw

Hi, got some query on SQL Injection. I tried to inject my own database, my user password is encrypted, but when I write the injection script in the login form, it has been hashed and it doesn't run the injection at all, but the script does the injecting when I code it direct to my page. So is that mean hashing password can prevent SQL injection (those inject from the login form)



Re: Protect from SQL Injection?

Raul Garcia - MS

I would recommend to visit the following link:

http://msdn2.microsoft.com/en-us/library/ms161953.aspx

Please let us know if you have further questions.

-Raul Garcia

SDE/T

SQL Server Engine