CWE-96: Improper Neutralization of Directives in Statically Saved Code ('Static Code Injection')
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before inserting the input into an executable resource, such as a library, configuration file, or template.
Last updated
Overview
CWE-96 (Improper Neutralization of Directives in Statically Saved Code ('Static Code Injection')) is a base-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Real-world CVEs
25 recorded CVEs are caused by CWE-96 (Improper Neutralization of Directives in Statically Saved Code ('Static Code Injection')), including 1 in CISA's KEV (Known Exploited Vulnerabilities) catalog. KEVs are shown first. 4 new CWE-96 CVEs have been recorded so far in 2026 (9 in 2025).
- CVE-2026-86218CISA KEV
pre-authentication remote code execution
Critical · CVSS 10.0 · EPSS 97th2026-09-06 - CVE-2024-55877
XWiki allows remote code execution from account through macro descriptions and XWiki.XWikiSyntaxMacrosList
Critical · CVSS 10.0 · EPSS 76th2024-12-12 - CVE-2015-2079Critical · CVSS 9.9 · EPSS 75th2025-04-28
- CVE-2024-13264
Opigno module - Critical - Arbitrary PHP code execution - SA-CONTRIB-2024-028
Critical · CVSS 9.8 · EPSS 41th2025-01-09 - CVE-2023-39726Critical · CVSS 9.8 · EPSS 69th2023-10-26
- CVE-2022-0895
Static Code Injection in microweber/microweber
Critical · CVSS 9.8 · EPSS 78th2022-03-10 - CVE-2020-6144Critical · CVSS 9.8 · EPSS 94th2020-09-01
- CVE-2020-6143Critical · CVSS 9.8 · EPSS 94th2020-09-01
- CVE-2025-30091Critical · CVSS 9.4 · EPSS 56th2025-03-25
- CVE-2024-43400
XWiki Platform allows XSS through XClass name in string properties
Critical · CVSS 9.4 · EPSS 42th2024-08-19 - CVE-2022-43938
Hitachi Vantara Pentaho Business Analytics Server - Improper Neutralization of Directives in Statically Saved Code ('Static Code Injection')
High · CVSS 8.8 · EPSS 98th2023-04-03 - CVE-2026-68489High · CVSS 8.7 · EPSS 52th2026-09-14
Showing 12 of 25 recorded CWE-96 CVEs. Get an alert for each new one, with AI-written analysis and fixes.
Monitor these CVEsCommon consequences
What can happen when CWE-96 is exploited.
Read Files or Directories, Read Application Data
Affects: Confidentiality
The injected code could access restricted data / files.
Bypass Protection Mechanism
Affects: Access Control
In some cases, injectable code controls authentication; this may lead to a remote vulnerability.
Gain Privileges or Assume Identity
Affects: Access Control
Injected code can access resources that the attacker is directly prevented from accessing.
Execute Unauthorized Code or Commands
Affects: Integrity, Confidentiality, Availability, Other
Code injection attacks can lead to loss of data integrity in nearly all cases as the control-plane data injected is always incidental to data recall or writing. Additionally, code injection can often result in the execution of arbitrary code.
Hide Activities
Affects: Non-Repudiation
Often the actions performed by injected control code are unlogged.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-96, grouped by where in the lifecycle they apply.
Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
Perform proper output validation and escaping to neutralize all code syntax from data written to code files.
How to detect it
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Code examples
MITRE examples of the weakness in code.
This example attempts to write user messages to a message file and allow users to view them.
Vulnerable example
$MessageFile = "messages.out";
$name = $_GET["name"];
include($MessageFile);Attack input
name=h4x0rAttack input
<?php system("/bin/ls -l");?>Illustrative examples
Real CVEs that MITRE cites as examples of this weakness.
- CVE-2002-0495 — Perl code directly injected into CGI library file from parameters to another CGI program.
- CVE-2005-1876 — Direct PHP code injection into supporting template file.
- CVE-2005-1894 — Direct code injection into PHP script that can be accessed by attacker.
- CVE-2003-0395 — PHP code from User-Agent HTTP header directly inserted into log file implemented as PHP script.
- CVE-2007-6652 — chain: execution after redirect allows non-administrator to perform static code injection.
Terminology & mappings
Mapped taxonomies
- PLOVER: Direct Static Code Injection
- Software Fault Patterns: Tainted Input to Command (SFP24)
Attack patterns
CAPEC attack patterns that exploit this weakness.
Frequently asked questions
Common questions about CWE-96.
- What is CWE-96?
- The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before inserting the input into an executable resource, such as a library, configuration file, or template.
- What CVEs are caused by CWE-96?
- 25 recorded CVEs are attributed to CWE-96, including CVE-2026-86218, CVE-2024-55877 and CVE-2015-2079. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.
- How do you prevent CWE-96?
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
- How is CWE-96 detected?
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
- What are the consequences of CWE-96?
- Exploiting CWE-96 can lead to: Read Files or Directories, Read Application Data, Bypass Protection Mechanism, Gain Privileges or Assume Identity, Execute Unauthorized Code or Commands, Hide Activities.
- Is CWE-96 actively exploited?
- Yes. 1 CWE-96 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 25 recorded CVEs.
References
- MITRE CWE definition (CWE-96) (opens in a new tab)
- CWE-96 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Track CWE-96 CVEs
Get an alert when a new CWE-96 CVE affects your products, with AI-written analysis and remediation steps.