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

303 results · Clear filters · Feed

  • Critical 9.8
    CVE-2023-24538 Public exploit

    Backticks not treated as string delimiters in html/template

    Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected. Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, th…

  • Critical 9.8
    CVE-2021-36394 Public exploit

    Moodle Session Fixation vulnerability

    In Moodle, a remote code execution risk was identified in the Shibboleth authentication plugin.

  • Critical 9.8
    CVE-2022-36231 Public exploit

    Code injection in pdf_info

    pdf_info 0.5.3 is vulnerable to Command Execution because the Ruby code uses backticks instead of Open3.

  • Critical 9.8
    CVE-2023-22855 Public exploit EPSS 15%

    Kardex Mlog MCC 5.7.12+0-a203c2a213-master allows remote code execution. It spawns a web interface listening on port 80…

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

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

  • 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…

  • 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…

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

  • 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
  • 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…

  • 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
  • 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.…

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

  • 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
  • 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…

  • Critical 9.8
    CVE-2021-30180 Public exploit EPSS 60%

    Apache Dubbo RCE on customers via Condition route poisoning (Unsafe YAML unmarshaling)

    Apache Dubbo prior to 2.7.9 support Tag routing which will enable a customer to route the request to the right server. These rules are used by the customers when making a request in order to find the right endpoint. When parsing these YAML rules, Dubbo custom…

  • Critical 9.8
    CVE-2021-33564 Public exploit Scanner template EPSS 72%

    Dragonfly contains remote code execution vulnerability

    An argument injection vulnerability in the Dragonfly gem before 1.4.0 for Ruby allows remote attackers to read and write to arbitrary files via a crafted URL when the verify_url option is disabled. This may lead to code execution. The problem occurs because t…

  • Critical 9.8
    CVE-2021-30181 Public exploit EPSS 61%

    Apache Dubbo RCE on customers via Script route poisoning (Nashorn script injection)

    Apache Dubbo prior to 2.6.9 and 2.7.9 supports Script routing which will enable a customer to route the request to the right server. These rules are used by the customers when making a request in order to find the right endpoint. When parsing these rules, Dub…

  • Critical 10.0
    CVE-2021-22205 Exploited · Ransomware Public exploit Scanner template EPSS 100%

    An issue has been discovered in GitLab CE/EE affecting all versions starting from 11.9. GitLab was not properly validat…

    KEV Nov 3, 2021
  • Critical 9.8
    CVE-2021-3129 Exploited · Ransomware Public exploit Scanner template EPSS 100%

    Unauthenticated remote code execution in Ignition

    Ignition before 2.5.2, as used in Laravel and other products, allows unauthenticated remote attackers to execute arbitrary code because of insecure usage of file_get_contents() and file_put_contents(). This is exploitable on sites using debug mode with Larave…

    KEV Sep 18, 2023
  • Critical 9.8
    CVE-2020-17530 Exploited Public exploit Scanner template EPSS 96%

    Remote code execution in Apache Struts

    Forced OGNL evaluation, when evaluated on raw user input in tag attributes, may lead to remote code execution. Affected software : Apache Struts 2.0.0 - Struts 2.5.25.

    KEV Nov 3, 2021
  • Critical 9.8
    CVE-2020-11998 Public exploit EPSS 49%

    Remote code execution in Apache ActiveMQ

    A regression has been introduced in the commit preventing JMX re-bind. By passing an empty environment map to RMIConnectorServer, instead of the map that contains the authentication credentials, it leaves ActiveMQ open to the following attack: https://docs.or…

  • Critical 9.8
    CVE-2020-13756 Public exploit EPSS 50%

    Sabberworm PHP CSS Parser Code injection vulnerability in allSelectors()

    Sabberworm PHP CSS Parser before 8.3.1 calls eval on uncontrolled data, possibly leading to remote code execution if the function allSelectors() or getSelectorsBySpecificity() is called with input from an attacker.

  • Critical 9.8
    CVE-2019-19208 Public exploit EPSS 19%

    Code injection in codiad

    Codiad Web IDE through 2.8.4 allows PHP Code injection.

  • Critical 9.8
    CVE-2020-8644 Exploited Public exploit Scanner template EPSS 86%

    PlaySMS before 1.4.3 does not sanitize inputs from a malicious string.

    KEV Nov 3, 2021
  • Critical 9.9
    CVE-2019-10758 Exploited Public exploit Scanner template EPSS 85%

    Remote Code Execution Vulnerability in NPM mongo-express

    mongo-express before 0.54.0 is vulnerable to Remote Code Execution via endpoints that uses the `toBSON` method. A misuse of the `vm` dependency to perform `exec` commands in a non-safe environment.

    KEV Dec 10, 2021
  • Critical 10.0
    CVE-2019-4716 Exploited Public exploit Scanner template EPSS 86%

    IBM Planning Analytics 2.0.0 through 2.0.8 is vulnerable to a configuration overwrite that allows an unauthenticated us…

    KEV Nov 3, 2021
  • Critical 9.8
    CVE-2011-3923 Public exploit EPSS 89%

    Struts ParameterInterceptor vulnerability allows remote command execution

    Apache Struts before 2.3.1.2 allows remote attackers to bypass security protections in the ParameterInterceptor class and execute arbitrary commands.

  • Critical 9.9
    CVE-2019-10760 Public exploit

    Sandbox Breakout / Arbitrary Code Execution in safer-eval

    safer-eval before 1.3.2 are vulnerable to Arbitrary Code Execution. A payload using constructor properties can escape the sandbox and execute arbitrary code.

  • Critical 9.8
    CVE-2019-16759 Exploited Public exploit Scanner template EPSS 100%

    vBulletin 5.x through 5.5.4 allows remote command execution via the widgetConfig[code] parameter in an ajax/render/widg…

    KEV Nov 3, 2021
  • Critical 9.8
    CVE-2019-15224 Public exploit

    rest-client Gem Contains Malicious Code

    The rest-client gem 1.6.10 through 1.6.13 for Ruby, as distributed on RubyGems.org, included a code-execution backdoor inserted by a third party. Versions <=1.6.9 and >=1.6.14 are unaffected.

  • Critical 9.8
    CVE-2019-14271 Public exploit EPSS 19%

    Moby Docker cp broken with debian containers

    In Docker 19.03.x before 19.03.1 linked against the GNU C Library (aka glibc), code injection can occur when the nsswitch facility dynamically loads a library inside a chroot that contains the contents of the container.