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.8
    CVE-2023-37582 Public exploit Scanner template EPSS 90%

    Apache RocketMQ: Possible remote code execution when using the update configuration function

    The RocketMQ NameServer component still has a remote command execution vulnerability as the CVE-2023-33246 issue was not completely fixed in version 5.1.1. When NameServer address are leaked on the extranet and lack permission verification, an attacker can ex…

  • Critical 9.6

    A vulnerability has been discovered in the Citrix Secure Access client for Ubuntu which, if exploited, could allow an a…

  • Critical 9.8

    xalpha vulnerable to Remote Code Execution

    xalpha v0.11.4 is vulnerable to Remote Command Execution (RCE).

  • Critical 9.1

    Code Injection in nilsteampassnet/teampass

    Code Injection in GitHub repository nilsteampassnet/teampass prior to 3.0.10.

  • Critical 9.8

    langchain arbitrary code execution vulnerability

    An issue in LangChain before 0.0.236 allows an attacker to execute arbitrary code because Python code with os.system, exec, or eval can be used.

  • Critical 9.8

    jFinal Server-Side Template Injection vulnerability

    Server-Side Template Injection (SSTI) vulnerability in jFinal v.4.9.08 allows a remote attacker to execute arbitrary code via the template function.

  • Critical 10.0

    XWiki Platform vulnerable to privilege escalation (PR) from account through like LiveTableResults

    XWiki Platform is a generic wiki platform. Starting in version 12.9-rc-1 and prior to versions 14.4.8, 14.10.6, and 15.1, any logged in user can add dangerous content in their first name field and see it executed with programming rights. Leading to rights esc…

  • Critical 9.9
    CVE-2023-35150 EPSS 78%

    XWiki Platform vulnerable to privilege escalation (PR) from view right via Invitation application

    XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. Starting in version 2.40m-2 and prior to versions 14.4.8, 14.10.4, and 15.0, any user with view rights on any document can execute code with programming r…

  • Critical 10.0

    Grav Server Side Template Injection vulnerability

    Grav is a flat-file content management system. Versions prior to 1.7.42 are vulnerable to server side template injection. Remote code execution is possible by embedding malicious PHP code on the administrator screen by a user with page editing privileges. Ver…

  • Critical 10.0

    A vulnerability has been identified in SIMATIC PCS 7 (All versions < V9.1 SP2 UC04), SIMATIC S7-PM (All versions < V5.7…

  • Critical 9.8
    CVE-2020-36708 Public exploit Scanner template EPSS 65%

    Epsilon Framework Themes (Various Versions) - Function Injection

    The following themes for WordPress are vulnerable to Function Injections in versions up to and including Shapely <= 1.2.7, NewsMag <= 2.4.1, Activello <= 1.4.0, Illdy <= 2.1.4, Allegiant <= 1.2.2, Newspaper X <= 1.3.1, Pixova Lite <= 2.0.5, Brilliance <= 1.2.…

  • Critical 9.8
    CVE-2023-32692 Public exploit

    Remote Code Execution Vulnerability in Validation Placeholders

    CodeIgniter is a PHP full-stack web framework. This vulnerability allows attackers to execute arbitrary code when you use Validation Placeholders. The vulnerability exists in the Validation library, and validation methods in the controller and in-model valida…

  • Critical 9.8
    CVE-2023-30145 Public exploit EPSS 46%

    Server-Side Template Injection in Camaleon CMS

    Camaleon CMS v2.7.0 was discovered to contain a Server-Side Template Injection (SSTI) vulnerability via the formats parameter.

  • Critical 9.8
    CVE-2023-33246 Exploited Public exploit Scanner template EPSS 97%

    Apache RocketMQ: Possible remote code execution vulnerability when using the update configuration function

    For RocketMQ versions 5.1.0 and below, under certain conditions, there is a risk of remote command execution.  Several components of RocketMQ, including NameServer, Broker, and Controller, are leaked on the extranet and lack permission verification, an attack…

    KEV Sep 6, 2023
  • Critical 9.0

    Code injection vulnerability in Drive Explorer for macOS versions 3.5.4 and earlier allows an attacker who can login to…

  • Critical 9.8

    An issue found in Agasio-Camera device version not specified allows a remote attacker to execute arbitrary code via the…

  • Critical 9.8

    An issue found in FLIR-DVTEL version not specified allows a remote attacker to execute arbitrary code via a crafted req…

  • Critical 9.8

    PHPOK v6.3 was discovered to contain a remote code execution (RCE) vulnerability.

  • Critical 10.0

    Code Injection in jsreport/jsreport

    Code Injection in GitHub repository jsreport/jsreport prior to 3.11.3.

  • Critical 9.9

    Kibana version 8.7.0 contains an arbitrary code execution flaw. An attacker with All privileges to the Uptime/Synthetic…

  • Critical 9.8

    Remote code execution in JFinal CMS

    JFinal CMS v5.1.0 was discovered to contain a remote code execution (RCE) vulnerability via the ActionEnter function.

  • Critical 9.8

    Aigital Wireless-N Repeater Mini_Router v0.131229 was discovered to contain a remote code execution (RCE) vulnerability…

  • Critical 9.8

    Remote code execution in dawnsparks-node-tesseract

    huedawn-tesseract 0.3.3 and dawnsparks-node-tesseract 0.4.0 to 0.4.1 was discovered to contain a remote code execution (RCE) vulnerability via the child_process function.

  • Critical 9.9

    org.xwiki.platform:xwiki-platform-flamingo-theme-ui vulnerable to privilege escalation

    XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. Any user with the right to add an object on a page can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki inst…

  • Critical 10.0
    CVE-2023-29509 EPSS 76%

    org.xwiki.platform:xwiki-platform-flamingo-theme-ui Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with view rights on commonly accessible documents can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation.…

  • Critical 10.0

    org.xwiki.platform:xwiki-platform-panels-ui Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with edit rights can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation. The root cause is improper escap…

  • Critical 10.0

    xwiki.platform:xwiki-platform-panels-ui Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with edit rights can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation. The root cause is improper escap…

  • Critical 10.0

    org.xwiki.platform:xwiki-platform-wiki-ui-mainwiki Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with view rights `WikiManager.DeleteWiki` can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation. The roo…

  • Critical 10.0

    org.xwiki.platform:xwiki-platform-notifications-ui Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with view rights on commonly accessible documents including the notification preferences macros can execute arbitrary Groovy, Python or Velocity code in XWiki lea…

  • Critical 10.0

    org.xwiki.platform:xwiki-platform-legacy-notification-activitymacro Eval Injection vulnerability

    XWiki Commons are technical libraries common to several other top level XWiki projects. Any user with view rights on commonly accessible documents including the legacy notification activity macro can execute arbitrary Groovy, Python or Velocity code in XWiki …

  • Critical 9.8
    CVE-2020-29007 Public exploit

    The Score extension through 0.3.0 for MediaWiki has a remote code execution vulnerability due to improper sandboxing of…

  • Critical 9.8
    CVE-2023-29492 Exploited

    Novi Survey before 8.9.43676 allows remote attackers to execute arbitrary code on the server in the context of the serv…

    KEV Apr 13, 2023
  • Critical 9.8

    An issue found in APUS Group Launcher v.3.10.73 and v.3.10.88 allows a remote attacker to execute arbitrary code via th…

  • Critical 9.8

    Apache Airflow Hive Provider Beeline Remote Command Execution

    Improper Control of Generation of Code ('Code Injection') vulnerability in Apache Software Foundation Apache Airflow Hive Provider.This issue affects Apache Airflow Hive Provider: before 6.0.0.

  • 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-2023-29374 EPSS 40%

    LangChain vulnerable to code injection

    In LangChain through 0.0.131, the LLMMathChain chain allows prompt injection attacks that can execute arbitrary code via the Python exec method.

  • Critical 9.8

    HtmlUnit Code Injection vulnerability

    Versions of the package net.sourceforge.htmlunit:htmlunit from 0 and before 3.0.0 are vulnerable to Remote Code Execution (RCE) via XSTL, when browsing the attacker’s webpage.

  • Critical 9.8

    Moodle: pix helper potential mustache code injection risk

    The Mustache pix helper contained a potential Mustache injection risk if combined with user input (note: This did not appear to be implemented/exploitable anywhere in the core Moodle LMS).

  • Critical 10.0

    Code Injection in builderio/qwik

    Code Injection in GitHub repository builderio/qwik prior to 0.21.0.

  • Critical 9.8

    SmartBear Zephyr Enterprise through 7.15.0 mishandles user-defined input during report generation. This could lead to r…