Skip to content
OpenAdvisories

Weakness (CWE)

CWE-94: Improper Control of Generation of Code

Base Draft

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.

How to prevent it (7 mitigations)
  1. Architecture and Design

    Refactor your program so that you do not have to dynamically generate code.

  2. Architecture and Design

    Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which code can be executed by your product.

    Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection.

    This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise.

    Be careful to avoid CWE-243 and other weaknesses related to jails.

  3. Implementation

    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.

    To reduce the likelihood of code injection, use stringent allowlists that limit which constructs are allowed. If you are dynamically constructing code that invokes a function, then verifying that the input is alphanumeric might be insufficient. An attacker might still be able to reference a dangerous function that you did not intend to allow, such as system(), exec(), or exit().

  4. Testing

    Use dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product's operation may slow down, but it should not become unstable, crash, or generate incorrect results.

  5. Operation

    Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

  6. Operation

    Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

  7. Implementation

    For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures [REF-1372], so the python documentation discourages use of ast.literal_eval() on untrusted data [REF-1373].

Source: MITRE CWE-94

19 results · Clear filters · Feed

  • High 8.5
    CVE-2026-0322 Exploited Public exploit

    PAN-OS: Authenticated Remote Code Execution (RCE) in the Management Interface

    A remote code execution (RCE) vulnerability in the management interface of Palo Alto Networks PAN-OS® software enables an authenticated attacker with network access to execute arbitrary code with root privileges on the firewall. The security risk posed by thi…

    KEV Oct 14, 2026
  • High 8.8
    CVE-2026-65660 Exploited Public exploit

    Microsoft SharePoint Server Remote Code Execution Vulnerability

    Improper control of generation of code ('code injection') in Microsoft Office SharePoint allows an authorized attacker to execute code over a network.

    KEV Sep 25, 2026
  • High 7.2
    CVE-2026-15410 Exploited · Ransomware Public exploit EPSS 12%

    Post-authentication improper control of generation of code ('Code Injection') vulnerability has been identified in the …

    KEV Jul 14, 2026
  • High 8.8
    CVE-2026-34197 Exploited Public exploit EPSS 98%

    Apache ActiveMQ Broker, Apache ActiveMQ All, Apache ActiveMQ: Authenticated users could perform RCE via Jolokia MBeans

    Improper Input Validation, Improper Control of Generation of Code ('Code Injection') vulnerability in Apache ActiveMQ Broker, Apache ActiveMQ. Apache ActiveMQ Classic exposes the Jolokia JMX-HTTP bridge at /api/jolokia/ on the web console. The default Jolokia…

    KEV Apr 16, 2026
  • High 8.2
    CVE-2026-20045 Exploited Public exploit

    Cisco Unified Communications Products Remote Code Execution Vulnerability

    A vulnerability in Cisco Unified Communications Manager (Unified CM), Cisco Unified Communications Manager Session Management Edition (Unified CM SME), Cisco Unified Communications Manager IM & Presence Service (Unified CM IM&P), Cisco Unity Connectio…

    KEV Jan 21, 2026
  • High 8.8
    CVE-2025-49704 Exploited · Ransomware Public exploit EPSS 100%

    Microsoft SharePoint Remote Code Execution Vulnerability

    Improper control of generation of code ('code injection') in Microsoft Office SharePoint allows an authorized attacker to execute code over a network.

    KEV Jul 22, 2025
  • High 7.2
    CVE-2025-4428 Exploited Public exploit EPSS 88%

    Remote Code Execution

    Remote Code Execution in API component in Ivanti Endpoint Manager Mobile 12.5.0.0 and prior on unspecified platforms allows authenticated attackers to execute arbitrary code via crafted API requests.

    KEV May 19, 2025
  • High 7.2
    CVE-2023-24955 Exploited · Ransomware Public exploit EPSS 85%

    Microsoft SharePoint Server Remote Code Execution Vulnerability

    Microsoft SharePoint Server Remote Code Execution Vulnerability

    KEV Mar 26, 2024
  • High 8.8
    CVE-2023-22952 Exploited Public exploit EPSS 80%

    In SugarCRM before 12.0. Hotfix 91155, a crafted request can inject custom PHP code through the EmailTemplates because …

    KEV Feb 2, 2023
  • High 8.5
    CVE-2021-39144 Exploited Public exploit EPSS 98%

    XStream is vulnerable to a Remote Command Execution attack

    XStream is a simple library to serialize objects to XML and back again. In affected versions this vulnerability may allow a remote attacker has sufficient rights to execute commands of the host only by manipulating the processed input stream. No user is affec…

    KEV Mar 10, 2023
  • High 7.2
    CVE-2020-8218 Exploited Public exploit EPSS 32%

    A code injection vulnerability exists in Pulse Connect Secure <9.1R8 that allows an attacker to crafted a URI to perfor…

    KEV Mar 7, 2022
  • High 7.5
    CVE-2019-17558 Exploited Public exploit EPSS 99%

    Improper Input Validation in Apache Solr

    Apache Solr 5.0.0 to Apache Solr 8.3.1 are vulnerable to a Remote Code Execution through the VelocityResponseWriter. A Velocity template can be provided through Velocity templates in a configset `velocity/` directory or as a parameter. A user defined configse…

    KEV Nov 3, 2021
  • High 7.2
    CVE-2019-0193 Exploited Public exploit EPSS 84%

    XML External Entity (XXE) Injection in Apache Solr

    In Apache Solr, the DataImportHandler, an optional but popular module to pull in data from databases and other sources, has a feature in which the whole DIH configuration can come from a request's "dataConfig" parameter. The debug mode of the DIH admin screen…

    KEV Dec 10, 2021
  • High 8.1
    CVE-2018-7602 Exploited · Ransomware Public exploit EPSS 99%

    Drupal core - Highly critical - Remote Code Execution - SA-CORE-2018-004

    A remote code execution vulnerability exists within multiple subsystems of Drupal 7.x and 8.x. This potentially allows attackers to exploit multiple attack vectors on a Drupal site, which could result in the site being compromised. This vulnerability is relat…

    KEV Apr 13, 2022
  • High 7.8
    CVE-2017-8759 Exploited Public exploit EPSS 89%

    Microsoft .NET Framework 2.0, 3.5, 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2 and 4.7 allow an attacker to execute code remotely v…

    KEV Nov 3, 2021
  • High 8.8
    CVE-2017-9822 Exploited · Ransomware Public exploit EPSS 95%

    DNN (aka DotNetNuke) has Remote Code Execution via a cookie

    DNN (aka DotNetNuke) before 9.1.1 has Remote Code Execution via a cookie, aka "2017-08 (Critical) Possible remote code execution on DNN sites."

    KEV Nov 3, 2021
  • High 7.8
    CVE-2013-3906 Exploited Public exploit EPSS 85%

    GDI+ in Microsoft Windows Vista SP2 and Server 2008 SP2; Office 2003 SP3, 2007 SP3, and 2010 SP1 and SP2; Office Compat…

    KEV Feb 15, 2022
  • High 7.8
    CVE-2012-1535 Exploited Public exploit EPSS 70%

    Unspecified vulnerability in Adobe Flash Player before 11.3.300.271 on Windows and Mac OS X and before 11.2.202.238 on …

    KEV Mar 3, 2022
  • High 8.8
    CVE-2012-0158 Exploited · Ransomware Public exploit EPSS 100%

    The (1) ListView, (2) ListView2, (3) TreeView, and (4) TreeView2 ActiveX controls in MSCOMCTL.OCX in the Common Control…

    KEV Nov 3, 2021