CWE-94: Improper Control of Generation of Code ('Code Injection')

low-risk

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.

Abstraction: Base

Common Consequences

Access Control Bypass Protection Mechanism
Access Control Gain Privileges or Assume Identity
Integrity Execute Unauthorized Code or Commands
Non-Repudiation Hide Activities

Detection Methods

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.)

Real-World Examples (10)

CVE CVSS EPSS KEV
CVE-2021-22205 10.0 94.5% Y
CVE-2021-22205 10.0 94.5% Y
CVE-2022-22963 9.8 94.5% Y
CVE-2022-22947 10.0 94.5% Y
CVE-2021-44529 9.8 94.5% Y
CVE-2021-44529 9.8 94.5% Y
CVE-2022-22954 9.8 94.4% Y
CVE-2022-22954 9.8 94.4% Y
CVE-2019-16759 9.8 94.4% Y
CVE-2019-16759 9.8 94.4% Y
21
/ 100
low-risk
Active Threat 18/50 · Low
Exploit Availability 3/50 · Minimal