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

1,385 results · Clear filters · Feed

  • Critical 9.2

    Code Injection in BG-TEK's CoslatV3

    Improper Control of Generation of Code ('Code Injection'), Improper Neutralization of Special Elements used in a Command ('Command Injection'), Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') vulnerability in BG-TEK …

  • Critical 9.8

    AgentScope uses `eval`

    In agentscope <=v0.0.4, the file agentscope\web\workstation\workflow_utils.py has the function is_callable_expression. Within this function, the line result = eval(s) poses a security risk as it can directly execute user-provided commands.

  • Critical 9.8
    CVE-2024-48061 Public exploit

    Langflow vulnerable to remote code execution

    langflow <=1.0.18 is vulnerable to Remote Code Execution (RCE) as any component provided the code functionality and the components run on the local machine rather than in a sandbox.

  • Critical 9.8
    CVE-2024-48359 Public exploit

    Qualitor v8.24 was discovered to contain a remote code execution (RCE) vulnerability via the gridValoresPopHidden param…

  • Critical 9.8

    An issue in the PepeGxng smart contract (which can be run on the Ethereum blockchain) allows remote attackers to have a…

  • Critical 9.8

    In Draytek Vigor3900 1.5.1.3, attackers can inject malicious commands into mainfunction.cgi and execute arbitrary comma…

  • Critical 9.8

    An issue in the PepeGxng smart contract (which can be run on the Ethereum blockchain) allows remote attackers to have a…

  • Critical 9.8

    Sandbox Escape in Now Platform

    ServiceNow has addressed an input validation vulnerability that was identified in the Now Platform. This vulnerability could enable an unauthenticated user to remotely execute code within the context of the Now Platform. ServiceNow deployed an update to hoste…

  • Critical 9.8

    A remote code execution (RCE) vulnerability in the component /PluXml/core/admin/parametres_edittpl.php of PluXml v5.8.1…

  • Critical 10.0
    CVE-2024-50498 Public exploit Scanner template EPSS 53%

    WordPress WP Query Console plugin <= 1.0 - Remote Code Execution (RCE) vulnerability

    Improper Control of Generation of Code ('Code Injection') vulnerability in Ajit Bohra WP Query Console wp-query-console allows Code Injection.This issue affects WP Query Console: from n/a through <= 1.0.

  • Critical 9.8
    CVE-2024-39205 Public exploit EPSS 17%

    pyload-ng vulnerable to RCE with js2py sandbox escape

    An issue in pyload-ng v0.5.0b3.dev85 running under python3.11 or below allows attackers to execute arbitrary code via a crafted HTTP request.

  • Critical 9.8

    SQL Injection vulnerability in Best House rental management system project in php v.1.0 allows a remote attacker to exe…

  • Critical 9.8

    SQL injection vulnerability in Hanzhou Haobo network management system 1.0 allows a remote attacker to execute arbitrar…

  • Critical 9.8

    File Upload vulnerability in Best courier management system in php v.1.0 allows a remote attacker to execute arbitrary …

  • Critical 9.8

    MangoOS before 5.2.0 was discovered to contain a Client-Side Template Injection (CSTI) vulnerability via the Platform M…

  • Critical 9.8

    Remote code execution in php-heic-to-jpg

    php-heic-to-jpg <= 1.0.5 is vulnerable to code injection (fixed in 1.0.6). An attacker who can upload heic images is able to execute code on the remote server via the file name. As a result, the CIA is no longer guaranteed. This affects php-heic-to-jpg 1.0.5 …

  • Critical 9.8

    A vulnerability in the Desktop Client of Mitel MiCollab through 9.7.1.110, and MiVoice Business Solution Virtual Instan…

  • Critical 9.9
    CVE-2024-9264 Public exploit Scanner template EPSS 98%

    Grafana SQL Expressions allow for remote code execution

    The SQL Expressions experimental feature of Grafana allows for the evaluation of `duckdb` queries containing user input. These queries are insufficiently sanitized before being passed to `duckdb`, leading to a command injection and local file inclusion vulner…

  • Critical 9.8

    MariaDB v10.5 was discovered to contain a remote code execution (RCE) vulnerability via UDF Code in a Shared Object Fil…

  • Critical 10.0

    WordPress ajax-extend plugin <= 1.0 - Remote Code Execution (RCE) vulnerability

    Improper Control of Generation of Code ('Code Injection') vulnerability in sunjianle ajax-extend ajax-extend allows Code Injection.This issue affects ajax-extend: from n/a through <= 1.0.

  • Critical 9.8

    A stack overflow vulnerability exists in the sub_402280 function of the HNAP service of D-Link DCS-960L 1.09, allowing …

  • Critical 9.8
    CVE-2024-21534 Public exploit

    JSONPath Plus Remote Code Execution (RCE) Vulnerability

    All versions of the package jsonpath-plus are vulnerable to Remote Code Execution (RCE) due to improper input sanitization. An attacker can execute aribitrary code on the system by exploiting the unsafe default usage of vm in Node. **Note:** There were severa…

  • Critical 9.8

    RuoYi v4.7.9 and before has a security flaw that allows escaping from comments within the code generation feature, enab…

  • Critical 9.8

    A DLL hijacking vulnerability in VegaBird Yaazhini 2.0.2 allows attackers to execute arbitrary code / maintain persiste…

  • Critical 9.8

    A DLL hijacking vulnerability in VegaBird Vooki 5.2.9 allows attackers to execute arbitrary code / maintain persistence…

  • Critical 9.8

    FileSender before 2.49 allows server-side template injection (SSTI) for retrieving credentials.

  • Critical 9.1

    A condition exists in FlashArray Purity whereby an user with array admin role can execute arbitrary commands remotely t…

  • Critical 9.8

    CVE-2024-47219 in github.com/vesoft-inc/nebula

    An issue was discovered in vesoft NebulaGraph through 3.8.0. It allows shell command injection.

  • Critical 9.8

    SEMCMS 4.8 is vulnerable to SQL Injection via SEMCMS_Main.php.

  • Critical 9.8

    SeaCMS 13.2 has a remote code execution vulnerability located in the file sql.class.chp. Although the system has a chec…

  • Critical 9.8

    sqlitedict insecure deserialization vulnerability

    Insecure deserialization in sqlitedict up to v2.1.0 allows attackers to execute arbitrary code.

  • Critical 10.0
    CVE-2024-45798 Public exploit

    Multiple Poisoned Pipeline Execution (PPE) vulnerabilities

    arduino-esp32 is an Arduino core for the ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-H2 microcontrollers. The `arduino-esp32` CI is vulnerable to multiple Poisoned Pipeline Execution (PPE) vulnerabilities. Code injection in `tests_results.yml` wor…

  • Critical 9.2

    Remote Code Execution in SFS Consulting's ww.Winsure

    Improper Control of Generation of Code ('Code Injection') vulnerability in SFS Consulting ww.Winsure allows Code Injection. This issue affects ww.Winsure: before 4.6.2.

  • Critical 9.8

    SQL Injection vulnerability in Best Free Law Office Management Software-v1.0 allows an attacker to execute arbitrary co…

  • Critical 9.0

    A remote code execution (RCE) vulnerability via crafted extension description/changelog could be abused by a malicious extension in Docker Desktop before 4.34.2.

    A remote code execution (RCE) vulnerability via crafted extension description/changelog could be abused by a malicious extension in Docker Desktop before 4.34.2.

  • Critical 9.8
    CVE-2024-44466 EPSS 11%

    COMFAST CF-XR11 V2.7.2 has a command injection vulnerability in function sub_424CB4. Attackers can send POST request me…

  • Critical 9.8

    Endress+Hauser: Multiple products are vulnerable to code injection

    An unauthenticated remote attacker can run malicious c# code included in curve files and execute commands in the users context.

  • Critical 9.8

    D-Link DI-8300 v16.07.26A1 is vulnerable to command injection via the msp_info_htm function.

  • Critical 9.8

    D-Link DI-8300 v16.07.26A1 is vulnerable to command injection via the upgrade_filter_asp function.

  • Critical 9.9

    A code injection vulnerability that permits a low-privileged user to upload arbitrary files to the server, leading to r…