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

  • Critical 9.8
    CVE-2019-5413 Public exploit

    Code Injection in morgan

    An attacker can use the format parameter to inject arbitrary commands in the npm package morgan < 1.9.1.

  • Critical 9.8
    CVE-2018-14667 Exploited Public exploit EPSS 74%

    Richfaces vulnerable to arbitrary code execution

    The RichFaces Framework 3.X through 3.3.4 is vulnerable to Expression Language (EL) injection via the UserResource resource. A remote, unauthenticated attacker could exploit this to execute arbitrary code using a chain of java serialized objects via org.ajax4…

    KEV Sep 28, 2023
  • High 7.5
    CVE-2018-14716 Public exploit EPSS 33%

    SEOmatic plugin for Craft CMS SSTI Vulnerability

    A Server Side Template Injection (SSTI) was discovered in the SEOmatic plugin before 3.1.4 for Craft CMS, because requests that don't match any elements incorrectly generate the canonicalUrl, and can lead to execution of Twig code.

  • High 8.1
    CVE-2018-7602 Exploited · Ransomware Public exploit Scanner template EPSS 99%

    Drupal core - Highly critical - Remote Code Execution - SA-CORE-2018-004

    A remote code execution vulnerability exists within multiple subsystems of Drupal 7.x and 8.x. This potentially allows attackers to exploit multiple attack vectors on a Drupal site, which could result in the site being compromised. This vulnerability is relat…

    KEV Apr 13, 2022
  • High 8.8
    CVE-2018-5158 Public exploit EPSS 10%

    Malicious PDF can inject JavaScript into PDF Viewer

    The PDF viewer does not sufficiently sanitize PostScript calculator functions, allowing malicious JavaScript to be injected through a crafted PDF file. This JavaScript can then be run with the permissions of the PDF viewer by its worker. This vulnerability af…

  • Critical 9.8
    CVE-2017-16082 Public exploit EPSS 10%

    Remote Code Execution in pg

    A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql whic…

  • High 8.8
    CVE-2018-1133 Public exploit EPSS 31%

    Moodle calculated question type allows remote code execution by Question authors

    An issue was discovered in Moodle 3.x. A Teacher creating a Calculated question can intentionally cause remote code execution on the server, aka eval injection.

  • Critical 9.8
    CVE-2018-1260 Public exploit EPSS 11%

    Spring Security OAuth vulnerable to remote code execution (RCE)

    Spring Security OAuth, versions 2.3 prior to 2.3.3, 2.2 prior to 2.2.2, 2.1 prior to 2.1.2, 2.0 prior to 2.0.15 and older unsupported versions contains a remote code execution vulnerability. A malicious user or attacker can craft an authorization request to t…

  • Critical 9.8
    CVE-2018-1273 Exploited · Ransomware Public exploit Scanner template EPSS 97%

    Spring Data Commons remote code injection vulnerability

    Spring Data Commons, versions prior to 1.13 to 1.13.10, 2.0 to 2.0.5, and older unsupported versions, contain a property binder vulnerability caused by improper neutralization of special elements. An unauthenticated remote malicious user (or attacker) can sup…

    KEV Mar 25, 2022
  • Critical 9.8
    CVE-2018-1270 Public exploit EPSS 78%

    Spring Framework allows applications to expose STOMP over WebSocket endpoints

    Spring Framework, versions 5.0 prior to 5.0.5 and versions 4.3 prior to 4.3.15 and older unsupported versions, allow applications to expose STOMP over WebSocket endpoints with a simple, in-memory STOMP broker through the spring-messaging module. A malicious u…

  • Critical 9.8
    CVE-2018-8097 Public exploit

    Eve allows execution of arbitrary code

    io/mongo/parser.py in Eve (aka pyeve) before 0.7.5 allows remote attackers to execute arbitrary code via Code Injection in the where parameter.

  • High 8.1
    CVE-2017-15806 Public exploit EPSS 11%

    Zeta Components Mail Arbitrary code execution via a crafted email address

    The send function in the ezcMailMtaTransport class in Zeta Components Mail before 1.8.2 does not properly restrict the set of characters used in the ezcMail returnPath property, which might allow remote attackers to execute arbitrary code via a crafted email …

  • High 7.8
    CVE-2017-8759 Exploited Public exploit EPSS 89%

    Microsoft .NET Framework 2.0, 3.5, 3.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2 and 4.7 allow an attacker to execute code remotely v…

    KEV Nov 3, 2021
  • High 8.8
    CVE-2017-9822 Exploited · Ransomware Public exploit Scanner template EPSS 95%

    DNN (aka DotNetNuke) has Remote Code Execution via a cookie

    DNN (aka DotNetNuke) before 9.1.1 has Remote Code Execution via a cookie, aka "2017-08 (Critical) Possible remote code execution on DNN sites."

    KEV Nov 3, 2021
  • Critical 9.8
    CVE-2017-9841 Exploited Public exploit Scanner template EPSS 100%

    Code Injection in PHPUnit

    Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP code via HTTP POST data beginning with a "<?php " substring, as demonstrated by an attack on a site with an exposed /vendor folder, i.e., ex…

    KEV Feb 15, 2022
  • Critical 9.8
    CVE-2017-7494 Exploited · Ransomware Public exploit EPSS 99%

    Samba since version 3.5.0 and before 4.6.4, 4.5.10 and 4.4.14 is vulnerable to remote code execution vulnerability, all…

    KEV Mar 30, 2023
  • High 7.2
    CVE-2017-8912 Public exploit

    CMS Made Simple (CMSMS) 2.1.6 allows remote authenticated administrators to execute arbitrary PHP code via the code par…

  • Critical 9.8
    CVE-2016-5734 Public exploit EPSS 81%

    phpMyAdmin Code Injection vulnerability

    phpMyAdmin 4.0.x before 4.0.10.16, 4.4.x before 4.4.15.7, and 4.6.x before 4.6.3 does not properly choose delimiters to prevent use of the preg_replace e (aka eval) modifier, which might allow remote attackers to execute arbitrary PHP code via a crafted strin…

  • Critical 9.8
    CVE-2015-1635 Exploited Public exploit Scanner template EPSS 100%

    HTTP.sys in Microsoft Windows 7 SP1, Windows Server 2008 R2 SP1, Windows 8, Windows 8.1, and Windows Server 2012 Gold a…

    KEV Feb 10, 2022
  • High —
    CVE-2014-7192 Public exploit EPSS 13%

    Potential for Script Injection in syntax-error

    Eval injection vulnerability in index.js in the syntax-error package before 1.1.1 for Node.js 0.10.x, as used in IBM Rational Application Developer and other products, allows remote attackers to execute arbitrary code via a crafted file.

  • High —
    CVE-2014-8770 Public exploit

    MAGMI plugin for Magento Unsafe File Upload

    Unrestricted file upload vulnerability in magmi/web/magmi.php in the MAGMI (aka Magento Mass Importer) plugin 0.7.17a and earlier for Magento Community Edition (CE) allows remote authenticated users to execute arbitrary code by uploading a ZIP file that conta…

  • Critical —
    CVE-2014-7205 Public exploit EPSS 79%

    Arbitrary JavaScript Execution in bassmaster

    Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for the hapi server framework for Node.js allows remote attackers to execute arbitrary Javascript code via unspecified vectors.

  • Critical 9.8
    CVE-2014-6287 Exploited Public exploit Scanner template EPSS 99%

    The findMacroMarker function in parserLib.pas in Rejetto HTTP File Server (aks HFS or HttpFileServer) 2.3x before 2.3c …

    KEV Mar 25, 2022
  • Critical 9.8
    CVE-2014-0472 Public exploit

    Code Injection in Django

    The django.core.urlresolvers.reverse function in Django before 1.4.11, 1.5.x before 1.5.6, 1.6.x before 1.6.3, and 1.7.x before 1.7 beta 2 allows remote attackers to import and execute arbitrary Python modules by leveraging a view that constructs URLs using u…

  • High —
    CVE-2014-2921 Public exploit

    Pimcore Vulnerable to PHP Object Injection Attacks

    The getObjectByToken function in Newsletter.php in the Pimcore_Tool_Newsletter module in pimcore 1.4.9 through 2.0.0 does not properly handle an object obtained by unserializing Lucene search data, which allows remote attackers to conduct PHP object injection…

  • High —
    CVE-2014-1202 Public exploit

    Code injection via property expansion in SoapUI

    The WSDL/WADL import functionality in SoapUI before 4.6.4 allows remote attackers to execute arbitrary Java code via a crafted request parameter in a WSDL file.

  • High 7.8
    CVE-2013-3906 Exploited Public exploit EPSS 85%

    GDI+ in Microsoft Windows Vista SP2 and Server 2008 SP2; Office 2003 SP3, 2007 SP3, and 2010 SP1 and SP2; Office Compat…

    KEV Feb 15, 2022
  • Medium —
    CVE-2013-3630 Public exploit EPSS 42%

    Moodle Authenticated Spelling Binary Remote Code Execution

    Moodle through 2.5.2 allows remote authenticated administrators to execute arbitrary programs by configuring the aspell pathname and then triggering a spell-check operation within the TinyMCE editor.

  • Critical 9.0
    CVE-2013-5093 Public exploit EPSS 39%

    graphite-web is vulnerable to Remote Code Execution via renderLocalView function

    The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python module unsafely, which allows remote attackers to execute arbitrary code via a crafted serialized object.

  • Critical 9.8
    CVE-2013-4810 Exploited Public exploit EPSS 79%

    HP ProCurve Manager (PCM) 3.20 and 4.0, PCM+ 3.20 and 4.0, Identity Driven Manager (IDM) 4.0, and Application Lifecycle…

    KEV Mar 25, 2022
  • High 8.1
    CVE-2013-0810 Public exploit EPSS 60%

    Microsoft Windows XP SP2 and SP3, Windows Server 2003 SP2, Windows Vista SP2, and Windows Server 2008 SP2 allow remote …

  • High —
    CVE-2013-2134 Public exploit EPSS 70%

    Arbitrary code execution in Apache Struts 2

    Apache Struts 2 before 2.3.14.3 allows remote attackers to execute arbitrary OGNL code via a request with a crafted action name that is not properly handled during wildcard matching, a different vulnerability than CVE-2013-2135.

  • High —
    CVE-2013-1966 Public exploit EPSS 74%

    Arbitrary code execution in Apache Struts

    Apache Struts 2 before 2.3.14.2 allows remote attackers to execute arbitrary OGNL code via a crafted request that is not properly handled when using the includeParams attribute in the (1) URL or (2) A tag.

  • High —
    CVE-2013-1965 Public exploit Scanner template EPSS 94%

    Improper Control of Generation of Code in Apache Struts

    Apache Struts Showcase App 2.0.0 through 2.3.13, as used in Struts 2 before 2.3.14.3, allows remote attackers to execute arbitrary OGNL code via a crafted parameter name that is not properly handled when invoking a redirect.

  • High 8.1
    CVE-2013-2115 Public exploit EPSS 75%

    Code injection in Apache Struts

    Apache Struts 2 before 2.3.14.2 allows remote attackers to execute arbitrary OGNL code via a crafted request that is not properly handled when using the includeParams attribute in the (1) URL or (2) A tag. NOTE: this issue is due to an incomplete fix for CVE-…

  • High 8.5
    CVE-2013-3239 Public exploit

    phpMyAdmin Remote Code Execution

    phpMyAdmin 3.5.x before 3.5.8 and 4.x before 4.0.0-rc3, when a SaveDir directory is configured, allows remote authenticated users to execute arbitrary code by using a double extension in the filename of an export file, leading to interpretation of this file a…

  • Medium —
    CVE-2011-2732 Public exploit

    Improper Control of Generation of Code in Spring Security

    CRLF injection vulnerability in the logout functionality in VMware SpringSource Spring Security before 2.0.7 and 3.0.x before 3.0.6 allows remote attackers to inject arbitrary HTTP headers and conduct HTTP response splitting attacks via the spring-security-re…

  • High 7.8
    CVE-2012-1535 Exploited Public exploit EPSS 70%

    Unspecified vulnerability in Adobe Flash Player before 11.3.300.271 on Windows and Mac OS X and before 11.2.202.238 on …

    KEV Mar 3, 2022
  • High 8.8
    CVE-2012-0158 Exploited · Ransomware Public exploit EPSS 100%

    The (1) ListView, (2) ListView2, (3) TreeView, and (4) TreeView2 ActiveX controls in MSCOMCTL.OCX in the Common Control…

    KEV Nov 3, 2021
  • Medium —
    CVE-2012-0394 Public exploit Scanner template EPSS 73%

    Apache Struts's DebuggingInterceptor component allows remote code execution in developer mode

    The DebuggingInterceptor component in Apache Struts before 2.3.1.1, when developer mode is used, allows remote attackers to execute arbitrary commands via unspecified vectors. NOTE: the vendor characterizes this behavior as not "a security vulnerability itsel…