Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-616:Incomplete Identification of Uploaded File Variables (PHP)
Weakness ID:616
Version:v4.17
Weakness Name:Incomplete Identification of Uploaded File Variables (PHP)
Vulnerability Mapping:Allowed
Abstraction:Variant
Structure:Simple
Status:Incomplete
Likelihood of Exploit:
DetailsContent HistoryObserved CVE ExamplesReports
▼Description

The PHP application uses an old method for processing uploaded files by referencing the four global variables that are set for each file (e.g. $varname, $varname_size, $varname_name, $varname_type). These variables could be overwritten by attackers, causing the application to process unauthorized files.

▼Extended Description

These global variables could be overwritten by POST requests, cookies, or other methods of populating or overwriting these variables. This could be used to read or process arbitrary files by providing values such as "/etc/passwd".

▼Alternate Terms
▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
ChildOfDiscouragedC345Insufficient Verification of Data Authenticity
PeerOfAllowedV473PHP External Variable Modification
Nature: ChildOf
Mapping: Discouraged
Type: Class
ID: 345
Name: Insufficient Verification of Data Authenticity
Nature: PeerOf
Mapping: Allowed
Type: Variant
ID: 473
Name: PHP External Variable Modification
▼Memberships
NatureMappingTypeIDName
MemberOfProhibitedC994SFP Secondary Cluster: Tainted Input to Variable
MemberOfProhibitedC1411Comprehensive Categorization: Insufficient Verification of Data Authenticity
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 994
Name: SFP Secondary Cluster: Tainted Input to Variable
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1411
Name: Comprehensive Categorization: Insufficient Verification of Data Authenticity
▼Tags
NatureMappingTypeIDName
MemberOfProhibitedBSBOSS-319Read Files or Directories (impact)
MemberOfProhibitedBSBOSS-320Modify Files or Directories (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-319
Name: Read Files or Directories (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-320
Name: Modify Files or Directories (impact)
▼Relevant To View
Relevant to the view"Software Fault Pattern (SFP) Clusters - (888)"
NatureMappingTypeIDName
MemberOfProhibitedC994SFP Secondary Cluster: Tainted Input to Variable
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 994
Name: SFP Secondary Cluster: Tainted Input to Variable
▼Background Detail

▼Common Consequences
ScopeLikelihoodImpactNote
ConfidentialityIntegrityN/ARead Files or DirectoriesModify Files or Directories
N/A
Scope: Confidentiality, Integrity
Likelihood: N/A
Impact: Read Files or Directories, Modify Files or Directories
Note:
N/A
▼Potential Mitigations
Phase:Architecture and Design
Mitigation ID:
Strategy:
Effectiveness:
Description:

Use PHP 4 or later.

Note:


Phase:Architecture and Design
Mitigation ID:
Strategy:
Effectiveness:
Description:

If you must support older PHP versions, write your own version of is_uploaded_file() and run it against $HTTP_POST_FILES['userfile']))

Note:


Phase:Implementation
Mitigation ID:
Strategy:
Effectiveness:
Description:

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.

Note:

▼Modes Of Introduction
Phase: Implementation
Note:

N/A

▼Applicable Platforms
Languages
Class: PHP(Undetermined Prevalence)
▼Demonstrative Examples
Example 1

As of 2006, the "four globals" method is probably in sharp decline, but older PHP applications could have this issue.

Language: ( code)
N/A

Language: ( code)
N/A

In the "four globals" method, PHP sets the following 4 global variables (where "varname" is application-dependent):

Language: PHP(Bad code)
$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."

Language: ( code)
N/A

Language: PHP(Bad code)
$_FILES['userfile']['name'] - original filename from client $_FILES['userfile']['tmp_name'] - the temp filename of the file on the server

Language: ( code)
N/A

** note: 'userfile' is the field name from the web form; this can vary.

▼Observed Examples
ReferenceDescription
CVE-2002-1460
Forum does not properly verify whether a file was uploaded or if the associated variables were set by POST, allowing remote attackers to read arbitrary files.
CVE-2002-1759
Product doesn't check if the variables for an upload were set by uploading the file, or other methods such as $_POST.
CVE-2002-1710
Product does not distinguish uploaded file from other files.
Reference: CVE-2002-1460
Description:
Forum does not properly verify whether a file was uploaded or if the associated variables were set by POST, allowing remote attackers to read arbitrary files.
Reference: CVE-2002-1759
Description:
Product doesn't check if the variables for an upload were set by uploading the file, or other methods such as $_POST.
Reference: CVE-2002-1710
Description:
Product does not distinguish uploaded file from other files.
▼Affected Resources
    ▼Functional Areas
      ▼Weakness Ordinalities
      OrdinalityDescription
      Primary
      N/A
      Ordinality: Primary
      Description:
      N/A
      ▼Detection Methods
      ▼Vulnerability Mapping Notes
      Usage:Allowed
      Reason:Acceptable-Use
      Rationale:

      This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.

      Comments:

      Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

      Suggestions:
      ▼Notes
      ▼Taxonomy Mappings
      Taxonomy NameEntry IDFitEntry Name
      PLOVERN/AN/AIncomplete Identification of Uploaded File Variables (PHP)
      Software Fault PatternsSFP25N/ATainted input to variable
      Taxonomy Name: PLOVER
      Entry ID: N/A
      Fit: N/A
      Entry Name: Incomplete Identification of Uploaded File Variables (PHP)
      Taxonomy Name: Software Fault Patterns
      Entry ID: SFP25
      Fit: N/A
      Entry Name: Tainted input to variable
      ▼Related Attack Patterns
      IDName
      ▼References
      Reference ID: REF-502
      Title: A Study in Scarlet - section 5, "File Upload"
      Author: Shaun Clowes
      Section:
      Publication:
      Publisher:
      Edition:
      URL:
      URL Date:
      Day:N/A
      Month:N/A
      Year:N/A
      Details not found