Re: is_uploaded_file() security

From: Date: Wed, 22 Oct 2003 15:37:44 +0000
Subject: Re: is_uploaded_file() security
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167105@lists.php.net to get a copy of this message
By requesting upload_script.php?userfile=/etc/passwd and upload_sript.php uses global variables to handle uploads. This check should not be necessery if you are using $_FILES superglobal as php will not accept _FILES user input. But keep the check there in case a bug will be introduced. Alexander Mueller wrote:
Hi, I am wondering about the following paragraph at http://at2.php.net/manual/en/function.is-uploaded-file.php.
Returns TRUE if the file named by filename was uploaded via HTTP POST. This is useful to help ensure that a malicious user hasn't tried to trick the script into working on files upon which it should not be working--for instance, /etc/passwd. This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system.
AFAIK the browser only sends the content of the chosen file and cannot specify in any way a local filename which should be worked on. Furthermore PHP creates a temporary file containing the uploaded file content and passes this filename as 'tmp_name' variable. How can then a "malicious user try to trick the script"? Thanks, Alexander


« previous php.general (#167105) next »