// extract the variable array into plain variables
extract($_POST);
// code added to insure against form injection exploits
$username = preg_replace("/[^\w\.@-]/", "", $username);
$password = preg_replace("/[^\w\.@-]/", "", $password);
$captcha = preg_replace("/[^\w\.@-]/", "", $captcha);
The problem is, that by tampering with the posted data you could easily manipulate any variable that has been defined before, like $use_captcha, etc. So the captcha is useless as any hacker would pay attention to submit use_captcha=0...
the solution is to advise a prefix for the extracted variables:
// extract the variable array into plain variables
extract($_POST, EXTR_PREFIX_ALL, "auth");
// code added to insure against form injection exploits
$username = preg_replace("/[^\w\.@-]/", "", $auth_username);
$password = preg_replace("/[^\w\.@-]/", "", $auth_password);
$captcha = preg_replace("/[^\w\.@-]/", "", $auth_captcha);
and any variable not beginning with $auth_ cannot be tampered with anymore...
What do you think - am I becoming paranoid? :-)












