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

575 results · Clear filters · Feed

  • High 7.3
    CVE-2023-24059 Public exploit

    Grand Theft Auto V for PC allows attackers to achieve partial remote code execution or modify files on a PC, as exploit…

  • Critical 9.8
    CVE-2023-0297 Public exploit Scanner template EPSS 96%

    Code Injection in pyload/pyload

    Code Injection in GitHub repository pyload/pyload prior to 0.5.0b3.dev31.

  • High 8.8
    CVE-2023-22952 Exploited Public exploit Scanner template 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.1
    CVE-2022-24439 Public exploit

    Remote Code Execution (RCE)

    All versions of package gitpython are vulnerable to Remote Code Execution (RCE) due to improper user input validation, which makes it possible to inject a maliciously crafted remote URL into the clone command. Exploiting this vulnerability is possible because…

  • High 8.1
    CVE-2022-46166 Public exploit

    Spring Boot Admins integrated notifier support allows arbitrary code execution

    Spring boot admins is an open source administrative user interface for management of spring boot applications. All users who run Spring Boot Admin Server, having enabled Notifiers (e.g. Teams-Notifier) and write access to environment variables via UI are affe…

  • Critical 9.8
    CVE-2022-44262 Public exploit

    ff4j is vulnerable to Remote Code Execution (RCE)

    ff4j 1.8.1 is vulnerable to Remote Code Execution (RCE).

  • Critical 9.8
    CVE-2022-44136 Public exploit

    Zenario CMS is vulnerable to Remote Code Execution (RCE).

    Zenario CMS 9.3.57186 is vulnerable to Remote Code Excution (RCE).

  • High 8.8
    CVE-2022-40127 Public exploit Scanner template EPSS 86%

    Apache Airflow <2.4.0 has an RCE in a bash example

    A vulnerability in Example Dags of Apache Airflow allows an attacker with UI access who can trigger DAGs, to execute arbitrary commands via manually provided run_id parameter. This issue affects Apache Airflow Apache Airflow versions prior to 2.4.0.

  • Critical 9.8
    CVE-2022-31691 Public exploit

    Spring Tools 4 for Eclipse version 4.16.0 and below as well as VSCode extensions such as Spring Boot Tools, Concourse C…

  • High 8.8
    CVE-2022-43571 Public exploit EPSS 19%

    Remote Code Execution through dashboard PDF generation component in Splunk Enterprise

    In Splunk Enterprise versions below 8.2.9, 8.1.12, and 9.0.2, an authenticated user can execute arbitrary code through the dashboard PDF generation component.

  • High 8.8
    CVE-2022-41544 Public exploit EPSS 14%

    GetSimple CMS v3.3.16 was discovered to contain a remote code execution (RCE) vulnerability via the edited_file paramet…

  • Critical 9.8
    CVE-2022-42889 Public exploit EPSS 100%

    Apache Commons Text prior to 1.10.0 allows RCE when applied to untrusted input due to insecure interpolation defaults

    Apache Commons Text performs variable interpolation, allowing properties to be dynamically evaluated and expanded. The standard format for interpolation is "${prefix:name}", where "prefix" is used to locate an instance of org.apache.commons.text.lookup.String…

  • Medium 6.7
    CVE-2021-4178 Public exploit

    fabric8 kubernetes-client vulnerable

    A arbitrary code execution flaw was found in the Fabric 8 Kubernetes client affecting versions 5.0.0-beta-1 and above. Due to an improperly configured YAML parsing, this will allow a local and privileged attacker to supply malicious YAML.

  • Critical 9.8
    CVE-2022-34715 Public exploit EPSS 80%

    Windows Network File System Remote Code Execution Vulnerability

    Windows Network File System Remote Code Execution Vulnerability

  • Critical 9.8
    CVE-2022-35649 Public exploit

    Moodle PostScript Code Injection

    The vulnerability was found in Moodle, occurs due to improper input validation when parsing PostScript code. An omitted execution parameter results in a remote code execution risk for sites running GhostScript versions older than 9.50. Successful exploitation…

  • Critical 10.0
    CVE-2022-31161 Public exploit Scanner template EPSS 29%

    Roxy-WI Vulnerable to Unauthenticated Remote Code Execution via ssl_cert Upload

    Roxy-WI is a Web interface for managing HAProxy, Nginx and Keepalived servers. Prior to version 6.1.1.0, the system command can be run remotely via the subprocess_execute function without processing the inputs received from the user in the /app/options.py fil…

  • Critical 9.8
    CVE-2022-21831 Public exploit

    Possible code injection vulnerability in Rails / Active Storage

    A code injection vulnerability exists in the Active Storage >= v5.2.0 that could allow an attacker to execute code via image_processing arguments.

  • High 8.8
    CVE-2022-29221 Public exploit

    PHP Code Injection by malicious block or filename in Smarty

    Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.45 and 4.1.1, template authors could inject php code by choosing a malicious {block} name or {include} file name. Sites t…

  • Critical 10.0
    CVE-2022-24816 Exploited Public exploit Scanner template EPSS 100%

    Improper Control of Generation of Code in jai-ext

    JAI-EXT is an open-source project which aims to extend the Java Advanced Imaging (JAI) API. Programs allowing Jiffle script to be provided via network request can lead to a Remote Code Execution as the Jiffle script is compiled into Java code via Janino, and …

    KEV Jun 26, 2024
  • Critical 9.8
    CVE-2022-22954 Exploited · Ransomware Public exploit Scanner template EPSS 100%

    VMware Workspace ONE Access and Identity Manager contain a remote code execution vulnerability due to server-side templ…

    KEV Apr 14, 2022
  • High 8.8
    CVE-2022-24780 Public exploit

    Code Injection in Combodo iTop

    Combodo iTop is a web based IT Service Management tool. In versions prior to 2.7.6 and 3.0.0, users of the iTop user portal can send TWIG code to the server by forging specific http queries, and execute arbitrary code on the server using http server user priv…

  • Critical 9.8
    CVE-2022-22965 Exploited Public exploit Scanner template EPSS 100%

    Remote Code Execution in Spring Framework

    A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires the application to run on Tomcat as a WAR deployment. If the application is deployed as a Spring Boot…

    KEV Apr 4, 2022
  • Critical 9.8
    CVE-2022-22963 Exploited Public exploit Scanner template EPSS 100%

    Spring Cloud Function Code Injection with a specially crafted SpEL as a routing expression

    In Spring Cloud Function versions 3.1.6, 3.2.2 and older unsupported versions, when using routing functionality it is possible for a user to provide a specially crafted SpEL as a routing-expression that may result in remote code execution and access to local …

    KEV Aug 25, 2022
  • Critical 9.8
    CVE-2022-23812 Public exploit

    Malicious Package

    This affects the package node-ipc from 10.1.1 and before 10.1.3. This package contains malicious code, that targets users with IP located in Russia or Belarus, and overwrites their files with a heart emoji. **Note**: from versions 11.0.0 onwards, instead of h…

  • High 8.8
    CVE-2022-0811 Public exploit EPSS 19%

    Code Injection in CRI-O

    A flaw was found in CRI-O in the way it set kernel options for a pod. This issue allows anyone with rights to deploy a pod on a Kubernetes cluster that uses the CRI-O runtime to achieve a container escape and arbitrary code execution as root on the cluster no…

  • Unscored —
    CVE-2021-25003 Public exploit Scanner template EPSS 56%

    WPCargo < 6.9.0 - Unauthenticated RCE

    The WPCargo Track & Trace WordPress plugin before 6.9.0 contains a file which could allow unauthenticated attackers to write a PHP file anywhere on the web server, leading to RCE

  • High 7.2
    CVE-2022-24734 Public exploit EPSS 78%

    Remote code execution in mybb

    MyBB is a free and open source forum software. In affected versions the Admin CP's Settings management module does not validate setting types correctly on insertion and update, making it possible to add settings of supported type `php` with PHP code, executed…

  • Critical 10.0
    CVE-2022-22947 Exploited Public exploit Scanner template EPSS 98%

    Spring Cloud Gateway vulnerable to Code Injection when Gateway Actuator endpoint enabled, exposed, unsecured

    In spring cloud gateway versions prior to 3.1.1+ and 3.0.7+ , applications are vulnerable to a code injection attack when the Gateway Actuator endpoint is enabled, exposed and unsecured. A remote attacker could make a maliciously crafted request that could al…

    KEV May 16, 2022
  • High 8.8
    CVE-2022-23642 Public exploit EPSS 74%

    Code Injection in Sourcegraph

    Sourcegraph is a code search and navigation engine. Sourcegraph prior to version 3.37 is vulnerable to remote code execution in the `gitserver` service. The service acts as a git exec proxy, and fails to properly restrict calling `git config`. This allows an …

  • Critical 9.1
    CVE-2021-44521 Public exploit Scanner template EPSS 59%

    Remote code execution for scripted UDFs

    When running Apache Cassandra with the following configuration: enable_user_defined_functions: true enable_scripted_user_defined_functions: true enable_user_defined_functions_threads: false it is possible for an attacker to execute arbitrary code on the host.…

  • High 8.8
    CVE-2022-23614 Public exploit

    Code injection in Twig

    Twig is an open source template language for PHP. When in a sandbox mode, the `arrow` parameter of the `sort` filter must be a closure to avoid attackers being able to run arbitrary PHP functions. In affected versions this constraint was not properly enforced…

  • Critical 9.8
    CVE-2021-23639 Public exploit

    Remote Code Execution (RCE)

    The package md-to-pdf before 5.0.0 are vulnerable to Remote Code Execution (RCE) due to utilizing the library gray-matter to parse front matter content, without disabling the JS engine.

  • High 7.8
    CVE-2021-43811 Public exploit

    Code injection via unsafe YAML loading

    Sockeye is an open-source sequence-to-sequence framework for Neural Machine Translation built on PyTorch. Sockeye uses YAML to store model and data configurations on disk. Versions below 2.3.24 use unsafe YAML loading, which can be made to execute arbitrary c…

  • Critical 9.8
    CVE-2021-44529 Exploited · Ransomware Public exploit Scanner template EPSS 99%

    A code injection vulnerability in the Ivanti EPM Cloud Services Appliance (CSA) allows an unauthenticated user to execu…

    KEV Mar 25, 2024
  • High 7.6
    CVE-2021-22053 Public exploit Scanner template EPSS 13%

    Code injection in spring-cloud-netflix-hystrix-dashboard

    Applications using both `spring-cloud-netflix-hystrix-dashboard` and `spring-boot-starter-thymeleaf` expose a way to execute code submitted within the request URI path during the resolution of view templates. When a request is made at `/hystrix/monitor;[user-…

  • Critical 10.0
    CVE-2021-41269 Public exploit

    Unauthenticated remote code injection in cron-utils

    cron-utils is a Java library to define, parse, validate, migrate crons as well as get human readable descriptions for them. In affected versions A template Injection was identified in cron-utils enabling attackers to inject arbitrary Java EL expressions, lead…

  • High 8.3
    CVE-2021-42694 Public exploit

    An issue was discovered in the character definitions of the Unicode Specification through 14.0. The specification allow…

  • Medium 5.3
    CVE-2021-22557 Public exploit

    Code execution in SLO Generator via YAML Payload

    SLO generator allows for loading of YAML files that if crafted in a specific format can allow for code execution within the context of the SLO Generator. We recommend upgrading SLO Generator past https://github.com/google/slo-generator/pull/173

  • High 8.5
    CVE-2021-39144 Exploited Public exploit Scanner template 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.6
    CVE-2021-32706 Public exploit EPSS 60%

    (Authenticated) Remote Code Execution Possible in Web Interface 5.5

    Pi-hole's Web interface provides a central location to manage a Pi-hole instance and review performance statistics. Prior to Pi-hole Web interface version 5.5.1, the `validDomainWildcard` preg_match filter allows a malicious character through that can be used…