note 102535 deleted from security.database.sql-injection by googleguy

From: Date: Tue, 15 Jan 2013 04:44:31 +0000
Subject: note 102535 deleted from security.database.sql-injection by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193053@lists.php.net to get a copy of this message
Note Submitter: kirby4 at live dot ca ---- A good way to counter SQL injection for queries of type SELECT is use hash function on data by PHP and the database server. For example, it is possible to use the MySQL function MD5 () to produce a hash of data-server side , and the equivalent function in php web-server side. <?php $login = mysql_query("select f_uname, f_passwd from t_user where MD5(f_uname) = '".md5($uname)."' and MD5(f_passwd)='".md5($passwd)."'"); ?> Thus, the injected requests will be crushed and it will become much more difficult to obtain data in the database. Use both sides of the hash result in a comparison of hash, not the execution of the injected queries. Unfortunately, it probably does not work with other types of queries.

« previous php.notes (#193053) next »