Is it true that Stored procedure will prevent databases to be injected? I did a little research and I found out that SQL-Server, Oracle and MySQL are not safe against SQL injection if we only use stored procedure. However, this problem does not exist in postgreSQL. Does stored procedure implementation in postgreSQL core prevent it from SQL injection or are there any other reasons/differences? or I can use SQL injection in postgreSQL if we use only stored procedure.
In short - no, stored procedures does not prevent from SQL Injection. It depends on how you do handle dynamic SQL inside stored procedure. For more complete answer, check what is posted here: http://stackoverflow.com/questions/627918/am-i-safe-against-sql-injection |
|||
|
Check these links and the picture will get clearer: http://anubhavg.wordpress.com/2008/02/01/are-stored-procedures-safe-against-sql-injection/ http://www.sqlmag.com/article/sql-server/protecting-against-sql-injection.aspx "...Measures to avoid SQL injection
|
|||
|
IF you use SP correctly, then you are pretty much safe from SQL Injection (assuming you still do proper input validation anyway, of course). IF. Ah, but what does it mean, to use SP correctly? Two of the most common mis-uses of SP that I see often, and can each lead to SQL Injection even with Stored Procedures, are:
|
|||
|
You need variable binding along with named parameters, regardless if the query is a stored procedure or not. Also need to worry about certain SQL statements like LIKE |
|||||
|