Re: Password Protection] -- My solution

From: 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];
   $passw    = $_POST[passw]; (...)
$cmd = "SELECT * FROM theTable "
       .  "WHERE userName='$userName' ";
$res = mysql_query( $cmd ) or die( "Password search failed." );
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
$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

« previous php.general (#209003) next »