CWE
Home > CWE List > COMPOSITE LIST: CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP File Inclusion') (1.6)  

CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP File Inclusion')

 
Improper Control of Filename for Include/Require Statement in PHP Program ('PHP File Inclusion')
Definition in a New Window Definition in a New Window
Compound Element ID: 98 (Compound Element Base: Composite)Status: Draft
+ Description

Description Summary

The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions.

Extended Description

In certain versions and configurations of PHP, this can allow an attacker to specify a URL to a remote location from which the software will obtain the code to execute. In other cases in association with path traversal, the attacker can specify a local file that may contain executable statements that can be parsed by PHP.

+ Alternate Terms
PHP remote file inclusion
+ Time of Introduction
  • Implementation
+ Applicable Platforms

Languages

PHP

+ Observed Examples
ReferenceDescription
CVE-2004-0285Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2004-0030Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2004-0068Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2005-2157Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2005-2162Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2005-2198Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
CVE-2004-0128Modification of assumed-immutable variable in configuration script leads to file inclusion.
CVE-2005-1864PHP file inclusion.
CVE-2005-1869PHP file inclusion.
CVE-2005-1870PHP file inclusion.
CVE-2005-2154PHP local file inclusion.
CVE-2002-1704PHP remote file include.
CVE-2002-1707PHP remote file include.
CVE-2005-1964PHP remote file include.
CVE-2005-1681PHP remote file include.
CVE-2005-2086PHP remote file include.
CVE-2004-0127Directory traversal vulnerability in PHP include statement.
CVE-2005-1971Directory traversal vulnerability in PHP include statement.
CVE-2005-3335PHP file inclusion issue, both remote and local; local include uses ".." and "%00" characters as a manipulation, but many remote file inclusion issues probably have this vector.
+ Potential Mitigations
PhaseDescription

Assume all input is malicious. Use an appropriate combination of black lists and white lists to ensure only valid and expected input is processed by the system.

+ Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
CanPrecedeWeakness ClassWeakness Class94Failure to Control Generation of Code ('Code Injection')
Development Concepts (primary)699
Research Concepts1000
RequiresWeakness ClassWeakness Class216Containment Errors (Container Errors)
Research Concepts1000
RequiresWeakness BaseWeakness Base425Direct Request ('Forced Browsing')
Research Concepts1000
CanAlsoBeCompound Element: CompositeCompound Element: Composite426Untrusted Search Path
Research Concepts1000
RequiresWeakness BaseWeakness Base456Missing Initialization
Research Concepts1000
RequiresWeakness VariantWeakness Variant473PHP External Variable Modification
Research Concepts1000
ChildOfCategoryCategory632Weaknesses that Affect Files or Directories
Resource-specific Weaknesses (primary)631
ChildOfWeakness ClassWeakness Class706Use of Incorrectly-Resolved Name or Reference
Research Concepts (primary)1000
ChildOfCategoryCategory714OWASP Top Ten 2007 Category A3 - Malicious File Execution
Weaknesses in OWASP Top Ten (2007) (primary)629
ChildOfCategoryCategory727OWASP Top Ten 2004 Category A6 - Injection Flaws
Weaknesses in OWASP Top Ten (2004) (primary)711
CanFollowWeakness ClassWeakness Class73External Control of File Name or Path
Research Concepts1000
CanFollowWeakness BaseWeakness Base184Incomplete Blacklist
Research Concepts1000
+ Relationship Notes

This is frequently a functional consequence of other weaknesses. It is usually multi-factor with other factors (e.g. MAID), although not all inclusion bugs involve assumed-immutable data. Direct request weaknesses frequently play a role.

Can overlap directory traversal in local inclusion problems.

+ Research Gaps

Under-researched and under-reported. Other interpreted languages with "require" and "include" functionality could also product vulnerable applications, but as of 2007, PHP has been the focus. Any web-accessible language that uses executable file extensions is likely to have this type of issue, such as ASP, since .asp extensions are typically executable. Languages such as Perl are less likely to exhibit these problems because the .pl extension isn't always configured to be executable by the web server.

+ Affected Resources
  • File/Directory
+ Taxonomy Mappings
Mapped Taxonomy NameNode IDFitMapped Node Name
PLOVERPHP File Include
OWASP Top Ten 2007A3CWE More SpecificMalicious File Execution
+ References
Shaun Clowes. "A Study in Scarlet". <http://www.cgisecurity.com/lib/studyinscarlet.txt>.
+ Content History
Submissions
Submission DateSubmitterOrganizationSource
PLOVERExternally Mined
Modifications
Modification DateModifierOrganizationSource
2008-07-01Eric DalciCigitalExternal
updated Time of Introduction
2008-09-08CWE Content TeamMITREInternal
updated Relationships, Relationship Notes, Research Gaps, Taxonomy Mappings
2009-01-12CWE Content TeamMITREInternal
updated Relationships
2009-03-10CWE Content TeamMITREInternal
updated Relationships
2009-05-27CWE Content TeamMITREInternal
updated Description, Name
Weakness ClassWeakness Class Containment Errors (Container Errors) - (216)
Weakness BaseWeakness Base Direct Request ('Forced Browsing') - (425)
Weakness BaseWeakness Base Missing Initialization - (456)
Weakness VariantWeakness Variant PHP External Variable Modification - (473)
Page Last Updated: October 29, 2009