{"@ID": "616", "@Name": "Incomplete Identification of Uploaded File Variables (PHP)", "@Abstraction": "Variant", "@Structure": "Simple", "@Status": "Incomplete", "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).", "Dimensions": {"Dimension": [{"@Type": "Behavior-Property", "#text": "Incomplete"}, {"@Type": "Behavior-Type", "#text": "Identification"}, {"@Type": "Resource-Property", "#text": "Uploaded"}, {"@Type": "Resource-Type", "#text": "File Variables"}, {"@Type": "Language-Type", "#text": "PHP"}]}, "Related_Weaknesses": {"Related_Weakness": [{"@Nature": "ChildOf", "@CWE_ID": "345", "@View_ID": "1000", "@Ordinal": "Primary"}, {"@Nature": "PeerOf", "@CWE_ID": "473", "@View_ID": "1000"}]}, "Weakness_Ordinalities": {"Weakness_Ordinality": {"Ordinality": "Primary"}}, "Applicable_Platforms": {"Language": {"@Name": "PHP", "@Prevalence": "Undetermined"}}, "Modes_Of_Introduction": {"Introduction": {"Phase": "Implementation"}}, "Common_Consequences": {"Consequence": {"Scope": ["Confidentiality", "Integrity"], "Impact": ["Read Files or Directories", "Modify Files or Directories"], "Note": "These variables could be overwritten by attackers via POST requests, cookies, or other methods, causing the application to read or process unauthorized files."}}, "Potential_Mitigations": {"Mitigation": [{"Phase": "Architecture and Design", "Description": "Use PHP 4 or later."}, {"Phase": "Architecture and Design", "Description": "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", "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."}]}, "Demonstrative_Examples": {"Demonstrative_Example": [{"Intro_Text": "As of 2006, the \"four globals\" method is probably in sharp decline, but older PHP applications could have this issue.", "Body_Text": "In the \"four globals\" method, PHP sets the following 4 global variables (where \"varname\" is application-dependent):", "Example_Code": {"@Nature": "Bad", "@Language": "PHP", "xhtml:div": {"xhtml:br": [null, null, null], "#text": "$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"}, "#text_blocks": ["$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"]}}, {"Intro_Text": "\"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_Code": {"@Nature": "Bad", "@Language": "PHP", "xhtml:div": {"xhtml:br": null, "#text": "$_FILES['userfile']['name'] - original filename from client$_FILES['userfile']['tmp_name'] - the temp filename of the file on the server"}, "#text_blocks": ["$_FILES['userfile']['name'] - original filename from client", "$_FILES['userfile']['tmp_name'] - the temp filename of the file on the server"]}, "Body_Text": "** note: 'userfile' is the field name from the web form; this can vary."}]}, "Observed_Examples": {"Observed_Example": [{"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.", "Link": "https://www.cve.org/CVERecord?id=CVE-2002-1460"}, {"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.", "Link": "https://www.cve.org/CVERecord?id=CVE-2002-1759"}, {"Reference": "CVE-2002-1710", "Description": "Product does not distinguish uploaded file from other files.", "Link": "https://www.cve.org/CVERecord?id=CVE-2002-1710"}]}, "Taxonomy_Mappings": {"Taxonomy_Mapping": [{"@Taxonomy_Name": "PLOVER", "Entry_Name": "Incomplete Identification of Uploaded File Variables (PHP)"}, {"@Taxonomy_Name": "Software Fault Patterns", "Entry_ID": "SFP25", "Entry_Name": "Tainted input to variable"}]}, "References": {"Reference": {"@External_Reference_ID": "REF-502"}}, "Mapping_Notes": {"Usage": "Allowed", "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.", "Reasons": {"Reason": {"@Type": "Acceptable-Use"}}}, "Content_History": {"Submission": {"Submission_Name": "PLOVER", "Submission_Date": "2007-05-07", "Submission_Version": "Draft 6", "Submission_ReleaseDate": "2007-05-07"}, "Modification": [{"Modification_Name": "Eric Dalci", "Modification_Organization": "Cigital", "Modification_Date": "2008-07-01", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Time_of_Introduction"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2008-09-08", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Relationships, Observed_Example, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2008-10-14", "Modification_Version": "1.0.1", "Modification_ReleaseDate": "2008-10-14", "Modification_Comment": "updated Description, Other_Notes, Potential_Mitigations"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-03-29", "Modification_Version": "1.12", "Modification_ReleaseDate": "2011-03-30", "Modification_Comment": "updated Other_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-06-01", "Modification_Version": "1.13", "Modification_ReleaseDate": "2011-06-01", "Modification_Comment": "updated Common_Consequences"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-05-11", "Modification_Version": "2.2", "Modification_ReleaseDate": "2012-05-15", "Modification_Comment": "updated Observed_Examples, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-10-30", "Modification_Version": "2.3", "Modification_ReleaseDate": "2012-10-30", "Modification_Comment": "updated Potential_Mitigations"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2014-07-30", "Modification_Version": "2.8", "Modification_ReleaseDate": "2014-07-31", "Modification_Comment": "updated Relationships, Taxonomy_Mappings"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2020-02-24", "Modification_Version": "4.0", "Modification_ReleaseDate": "2020-02-24", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-04-27", "Modification_Version": "4.11", "Modification_ReleaseDate": "2023-04-27", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-06-29", "Modification_Version": "4.12", "Modification_ReleaseDate": "2023-06-29", "Modification_Comment": "updated Mapping_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2026-10-28", "Modification_Version": "5.0", "Modification_ReleaseDate": "2026-10-28", "Modification_Comment": "updated Common_Consequences, Description, Dimensions"}]}, "entry_type": "Weakness"}
