1377
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 345 Insufficient Verification of Data Authenticity 851
PeerOf 473 PHP External Variable Modification 1127
Weakness Ordinalities
Primary :
Applicable Platforms
Language : PHP (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Confidentiality
Integrity
Read Files or Directories
Modify Files or Directories
Potential Mitigations
Phase: Architecture and Design
Use PHP 4 or later.
Phase: Architecture and Design
If you must support older PHP versions, write your own version of is_uploaded_file() and run it
against $HTTP_POST_FILES['userfile']))
Phase: Implementation
For later PHP versions, reference uploaded files using the $HTTP_POST_FILES or $_FILES
variables, and use is_uploaded_file() or move_uploaded_file() to ensure that you are dealing with
an uploaded file.
Demonstrative Examples
Example 1:
As of 2006, the "four globals" method is probably in sharp decline, but older PHP applications could
have this issue.
In the "four globals" method, PHP sets the following 4 global variables (where "varname" is
application-dependent):
Example Language: PHP (Bad)
$varname = name of the temporary file on local machine
$varname_size = size of file
$varname_name = original name of file provided by client
$varname_type = MIME type of the file
Example 2:
"The global $_FILES exists as of PHP 4.1.0 (Use $HTTP_POST_FILES instead if using an earlier
version). These arrays will contain all the uploaded file information."
Example Language: PHP (Bad)
$_FILES['userfile']['name'] - original filename from client
$_FILES['userfile']['tmp_name'] - the temp filename of the file on the server
** note: 'userfile' is the field name from the web form; this can vary.
CWE Version 4.14
CWE-617: Reachable Assertion
CWE-617: Reachable Assertion