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

    Arbitrary Code Execution in blazar-dashboard

    An issue was discovered in OpenStack blazar-dashboard before 1.3.1, 2.0.0, and 3.0.0. A user allowed to access the Blazar dashboard in Horizon may trigger code execution on the Horizon host as the user the Horizon service runs under (because the Python eval f…

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

    Remote Code Execution in paginator(hex)

    There is a vulnerability in Paginator (Elixir/Hex package) which makes it susceptible to Remote Code Execution (RCE) attacks via input parameters to the paginate() function. This will potentially affect all current users of Paginator prior to version 1.0.0. T…

  • Critical 9.8

    Magento php object injection vulnerability

    Magento versions 1.14.4.5 and earlier, and 1.9.4.5 and earlier have a php object injection vulnerability. Successful exploitation could lead to arbitrary code execution.

  • Critical 9.8

    Code Injection in cd-messenger

    cd-messenger through 2.7.26 is vulnerable to Arbitrary Code Execution. User input provided to the `color` argument executed by the `eval` function resulting in code execution.

  • Critical 9.8

    Improper Input Validation in access-policy

    access-policy through 3.1.0 is vulnerable to Arbitrary Code Execution. User input provided to the `template` function is executed by the `eval` function resulting in code execution.

  • Critical 9.8

    Code Injection in node-extend

    node-extend through 0.2.0 is vulnerable to Arbitrary Code Execution. User input provided to the argument `A` of `extend` function`(A,B,as,isAargs)` located within `lib/extend.js` is executed by the `eval` function, resulting in code execution.

  • 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

    Arbitrary shell command execution in logkitty

    Lack of output sanitization allowed an attack to execute arbitrary shell commands via the logkitty npm package before version 0.7.1.

  • Critical 9.9

    Code Injection in XWiki Platform

    In XWiki Platform 7.2 through 11.10.2, registered users without scripting/programming permissions are able to execute python/groovy scripts while editing personal dashboards. This has been fixed 11.3.7 , 11.10.3 and 12.0.

  • Critical 9.8

    Code Injection in node-rules

    node-rules including 3.0.0 and prior to 5.0.0 allows injection of arbitrary commands. The argument rules of function "fromJSON()" can be controlled by users without any sanitization.

  • Critical 9.8

    Code injection in blamer

    Code injection vulnerability in blamer 1.0.0 and earlier may result in remote code execution when the input can be controlled by an attacker.

  • Critical 9.1

    Dell EMC Data Protection Advisor versions 6.3, 6.4, 6.5, 18.2 versions prior to patch 83, and 19.1 versions prior to pa…

  • 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

    Improper Input Validation and Code Injection in pdf-image

    Lack of input validation in pdf-image npm package version <= 2.0.0 may allow an attacker to run arbitrary code if PDF file path is constructed based on untrusted user input.

  • Critical 9.8

    Code Injection in script-manager

    An unintended require vulnerability in script-manager npm package version 0.8.6 and earlier may allow attackers to execute arbitrary code.

  • Critical 9.8

    omniauth-weibo-oauth2 included a code-execution backdoor inserted by a third party

    The omniauth-weibo-oauth2 gem 0.4.6 for Ruby, as distributed on RubyGems.org, included a code-execution backdoor inserted by a third party. Versions through 0.4.5, and 0.5.1 and later, are unaffected.

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

    ImpressPages CMS RCE

    ImpressPages CMS v1.0.12 has Unspecified Remote Code Execution (fixed in v1.0.13)

  • Critical 9.8

    Command Injection in hot-formula-parser

    grammar-parser.jison in the hot-formula-parser package before 3.0.1 for Node.js is vulnerable to arbitrary code injection. The package fails to sanitize values passed to the parse function and concatenates them in an eval call. If a value of the formula is ta…

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

    Command Injection in node-df

    A code injection exists in node-df v0.1.4 that can allow an attacker to remote code execution by unsanitized input.

  • Critical 9.8

    Treekill Enables OS Command Injection

    A Code Injection exists in treekill on Windows which allows a remote code execution when an attacker is able to control the input into the command.

  • 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

    Sandbox Breakout / Arbitrary Code Execution in safer-eval

    safer-eval is a npm package to sandbox the he evaluation of code used within the eval function. Affected versions of this package are vulnerable to Arbitrary Code Execution via generating a RangeError.

  • Critical 9.8
    CVE-2019-18889 EPSS 33%

    Symfony Unsafe Cache Serialization Could Enable RCE

    An issue was discovered in Symfony 3.4.0 through 3.4.34, 4.2.0 through 4.2.11, and 4.3.0 through 4.3.7. Serializing certain cache adapter interfaces could result in remote code injection. This is related to symfony/cache.

  • Critical 9.8

    Eval injection in Supybot/Limnoria

    Eval injection in the Math plugin of Limnoria (before 2019.11.09) and Supybot (through 2018-05-09) allows remote unprivileged attackers to disclose information or possibly have unspecified other impact via the calc and icalc IRC commands.

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

    Sandbox Breakout / Arbitrary Code Execution in safer-eval

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

  • Critical 9.9

    Improper Control of Generation of Code in Jenkins Script Security Plugin

    A sandbox bypass vulnerability in Jenkins Script Security Plugin 1.64 and earlier related to the handling of default parameter expressions in constructors allowed attackers to execute arbitrary code in sandboxed scripts.

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

  • Critical 9.8

    Code backdoor in simple_captcha2

    The simple_captcha2 gem 0.2.3 for Ruby, as distributed on RubyGems.org, included a code-execution backdoor inserted by a third party.

  • Critical 9.8

    datagrid contains code Injection backdoor

    The datagrid gem 1.0.6 for Ruby, as distributed on RubyGems.org, included a code-execution backdoor inserted by a third party.

  • Critical 9.8

    strong_password Ruby gem malicious version causing Remote Code Execution vulnerability

    The strong_password gem 0.0.7 for Ruby, as distributed on RubyGems.org, included a code-execution backdoor inserted by a third party. The current version, without this backdoor, is 0.0.6.

  • Critical 9.8

    Bootstrap-sass contains code execution backdoor

    Arbitrary code execution (via backdoor code) was discovered in bootstrap-sass 3.2.0.3, when downloaded from rubygems.org. An unauthenticated attacker can craft the ___cfduid cookie value with base64 arbitrary code to be executed via eval(), which can be lever…

  • Critical 10.0

    Hospira MedNet Code Injection

    Hospira MedNet software version 5.8 and prior uses vulnerable versions of the JBoss Enterprise Application Platform software that may allow unauthenticated users to execute arbitrary code on the target system. Hospira has developed a new version of the MedNet…

  • Critical 9.8
    CVE-2019-7609 Exploited Public exploit Scanner template EPSS 95%

    Kibana versions before 5.6.15 and 6.6.1 contain an arbitrary code execution flaw in the Timelion visualizer. An attacke…

    KEV Jan 10, 2022