SQL Injection
A major concern when developing database-driven websites is SQL Injection. Poorly written code could result in a malicious user running custom queries from his or her browser! Obviously the effects of that sort of security hole could be devasting for a web application.
Since I deal mostly with PHP/MySQL/Oracle, I’ll just be talking about PHP/MySQL/Oracle.
PHP has a built-in MySQL function called mysql_real_escape_string(). If that’s the injection-prevent method you go with, any time user-provided data from a URL query string is going into a database query it should be passed through that function.
If you’re using Oracle, the best and most elegant bet is to take advantage of the query binding features.
An example from the Wikipedia article on SQL injection (modified to fit the Oracle syntax):
$query = $sql->prepare("select * from users where name = :NAME");
$query->execute($user_name);
The execute member function here takes the value of $user_name and “binds” it to “:NAME” in the query. In other words it replaces the data stored in $user_name with the bind variable “:NAME.” However, before dumping it into the query it makes sure that the data in $user_name is not SQL. Regardless of the contents it treats it as query-safe data. When using native Oracle binds there is no need to use other functions such as mysql_real_escape_string().
March 10th, 2009 at 10:47 am
ohhh nice info
April 30th, 2009 at 8:58 pm
You know, the thing about SQL is, that there is virtually nothing that can replace it.
Does anyone know if a substitute exists for sql? I mean besides MS SQL and Oracle and all that jazz. Thanks.
May 3rd, 2009 at 7:00 am
Продолжение будет?
Были бы признательны
May 10th, 2009 at 12:48 pm
Как этот движок называется, я тоже хочу такой блог!