Re: Password Protection] -- My solution
| From: | Christophe Chisogne | Date: | Fri, 18 Feb 2005 09:01:53 +0000 |
| Subject: | Re: Password Protection] -- My solution | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-209003@lists.php.net to get a copy of this message | ||
Mailit, LLC a écrit :
$userName = $_POST[userName];Without validating userName in $_POST, that code is vulnerable to SQL injection, by example if userName starts by a single quote... See the PHP Security Guide on 'SQL Injection' http://phpsec.org/projects/guide/3.html#3.2$passw = $_POST[passw]; (...)$cmd = "SELECT * FROM theTable ". "WHERE userName='$userName' ";$res = mysql_query( $cmd ) or die( "Password search failed." );
$passe = crypt( $passw, $rec[ePass] ); if( $passe == $rec[ePass] )I seems that the above vulnerability cant be exploited, but I think it's better to be aware of it. Christophe