Saturday, August 13. 2005
Tobias Schlitt gave me a link to the article
10 Tips That Every PHP Developer Should Know, Part 2 by Jeffery Vaska that recently appeared on
phpbuilder.com. I was kinda shocked when I saw Tip #5, that describes howto deal with
$_GET and
$_POST. It mentions that a developer can use
extract($_POST) to eliminate the need of assigning every single entry manually. It also mentions:
This is a matter of
convenience and is not always a best practice.
It completely fails to mention, that using extract() without using prefixes or the parameter EXTR_SKIP is usually a very big security hole, because it allows an external attacker to overwrite every variable, including the superglobals (unless you use the Hardening-Patch) and this can lead in many cases to SQL injection or even Remote Code Execution Vulnerabilities.
Gulftech has recently released an advisory for Squirrelmail, that describes exactly such an extract($_POST) flaw.
As advertisement for my own project, I have to mention, that the
Hardening-Patch does not only protect against the fact that superglobals can be overwritten with
import_request_variables() or
extract(), but also protects scripts that do this globalising themself, by looping through the arrays. Unfortunately it is not possible to completely forbid
EXTR_OVERWRITE or similiar things, because this will break too many scripts.
Let us just hope, that not too many read the extract() tip.