CWE-98 / WEAKNESS
Improper Control of Filename for Include/Require Statement in PHP Program
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.
- Category
- CWE weaknesses
- Version / scope
- CWE 5.0; release 2026-10-28; publisher status Draft
- Affected / relevant technologies
- Web Based / Web Server / PHP
- Evidence
- Documentation: pinned-source excerpt checked. Execution: not tested. Editorial: curated reference.
Defensive analysis and explicitly authorized assessment only. This website performs no scans, exploitation, model calls or infrastructure changes. Indicators below are investigation opportunities, not proof of compromise or guaranteed detectors.
Mechanism and prerequisites
Review publisher context and local applicability; this reference is not execution evidence.
Potential impact
Integrity Confidentiality Availability Execute Unauthorized Code or Commands In certain versions and configurations of PHP with the allow_url_include setting enabled, an attacker could specify a URL to a remote location from which the product 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. In some cases, the attacker might be able to insert PHP specifiers into a data file, then cause that data file to be included, causing it to be parsed by PHP.
Versioned source scope
This record contains normalized, sometimes shortened source excerpts with editorial safety context. Markup and executable example blocks are omitted. Source-field verification does not establish device testing, a working detector or local applicability.
Publisher: MITRE. Release: CWE 5.0. Source checked: 2026-11-26.
Source object: CWE-98. Object modified: 2026-10-28.
Attribution and source terms (© The MITRE Corporation; reproduced with permission)Detection and investigation
- Manual Analysis Manual white-box analysis can be very effective for finding this issue, since there is typically a relatively small number of include or require statements in each program. High
- Automated Static Analysis The external control or influence of filenames can often be detected using automated static analysis that models data flow within the product. Automated static analysis might not be able to recognize when proper input validation is being performed, leading to false positives - i.e., warnings that do not have any security consequences or require any code changes. If the program uses a customized input validation library, then some tools may allow the analyst to create custom signatures to detect usage of those routines.
Preserve source timestamps, asset identity and collection context. Correlate independent evidence before attributing malicious intent. In OT, review passive evidence with the process owner; do not induce failures, replay commands or write to controllers to test a hypothesis.
Mitigation and response
- Architecture and Design Libraries or Frameworks Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- Architecture and Design Enforcement by Conversion When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.
- Architecture and Design For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Architecture and Design Operation Sandbox or Jail Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails. Limited The effectiveness of this mitigation depends on the prevention capabilities of the specific sandbox or jail being used and might only help to reduce the scope of an attack, such as restricting the attacker to certain system calls or limiting the portion of the file system that can be accessed.
Apply changes through the asset owner's approved change and recovery process. Documentation review is separate from successful testing or verified production protection.
Related technical context
No protocol-specific mapping is asserted for this entry.
Publisher weakness and attack-pattern relationships
These relationships retain the publisher's source attributes and view context; they do not establish that an attack or weakness applies to a particular system.
- CAPEC-193 → Related_Weakness → CWE-98 Open related reference
- CWE-184 → CanPrecede → CWE-98 Open related reference
- CWE-425 → CanPrecede → CWE-98 Open related reference
- CWE-456 → CanPrecede → CWE-98 Open related reference
- CWE-473 → CanPrecede → CWE-98 Open related reference
- CWE-73 → CanPrecede → CWE-98 Open related reference
- CWE-98 → Related_Attack_Pattern → CAPEC-193 Open related reference
- CWE-98 → CanAlsoBe → CWE-426 Open related reference
- CWE-98 → ChildOf → CWE-706 Open related reference
- CWE-98 → ChildOf → CWE-829 Open related reference
- CWE-98 → CanPrecede → CWE-94 Open related reference
Authoritative sources and attribution
Identifiers and source titles belong to OWASP, MITRE, the CVE Program, CISA, NIST or the cited vendor. Source excerpts are attributed and adapted under the linked publisher license; editorial context is separate. This is not an official framework mirror. Review baseline: 2026-11-18. Live documents can change; check exact current applicability.
- https://cwe.mitre.org/data/definitions/98.html — Publisher link; not separately HTTP-checked
- MITRE CWE 5.0 source snapshot — source accessed 2026-11-26
Source review supports bounded reference text. It is not execution evidence, a completeness claim, a CVSS assessment, a compliance certification or verification of production security.
