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,026 results · Clear filters · Feed

  • Medium 6.0

    Server-Side Template Injection (SSTI) vulnerability in inducer relate before v.2024.1, allows remote attackers to execu…

  • Medium 6.0
    CVE-2024-20359 Exploited EPSS 19%

    A vulnerability in a legacy capability that allowed for the preloading of VPN clients and plug-ins and that has been av…

    KEV Apr 24, 2024
  • Medium 5.0

    Microsoft Edge (Chromium-based) Security Feature Bypass Vulnerability

    Microsoft Edge (Chromium-based) Security Feature Bypass Vulnerability

  • Medium 6.7

    Buffer Overflow vulnerability in Ffmpeg v.N113007-g8d24a28d06 allows a local attacker to execute arbitrary code via the…

  • Medium 6.6

    Improper Neutralization of Server-Side Includes (SSI) vulnerability in WBSAirback

    Vulnerability in WBSAirback 21.02.04, which involves improper neutralisation of Server-Side Includes (SSI), through License (/admin/CDPUsers). Exploitation of this vulnerability could allow a remote user to execute arbitrary code.

  • Medium 6.6

    Improper Neutralization of Server-Side Includes (SSI) vulnerability in WBSAirback

    Vulnerability in WBSAirback 21.02.04, which involves improper neutralisation of Server-Side Includes (SSI), through S3 disks (/admin/DeviceS3). Exploitation of this vulnerability could allow a remote user to execute arbitrary code.

  • Medium 6.6

    Improper Neutralization of Server-Side Includes (SSI) vulnerability in WBSAirback

    Vulnerability in WBSAirback 21.02.04, which involves improper neutralisation of Server-Side Includes (SSI), through Device Synchronizations (/admin/DeviceReplication). Exploitation of this vulnerability could allow a remote user to execute arbitrary code.

  • Medium 6.6

    Improper Neutralization of Server-Side Includes (SSI) vulnerability in WBSAirback

    Vulnerability in WBSAirback 21.02.04, which involves improper neutralisation of Server-Side Includes (SSI), through Device NAS shared section (/admin/DeviceNAS). Exploitation of this vulnerability could allow a remote user to execute arbitrary code.

  • Medium 6.1

    Cross Site Scripting (XSS) in Insurance Management System v1.0, allows remote attackers to execute arbitrary web script…

  • Medium 6.3

    An issue in JNT Telecom JNT Liftcom UMS V1.J Core Version JM-V15 allows a remote attacker to execute arbitrary code via…

  • Medium 4.4

    WPC Smart Quick View for WooCommerce <= 4.0.2 - Authenticated (Administrator+) Stored Cross-Site Scripting

    The WPC Smart Quick View for WooCommerce plugin for WordPress is vulnerable to Stored Cross-Site Scripting via admin settings in all versions up to, and including, 4.0.2 due to insufficient input sanitization and output escaping. This makes it possible for au…

  • Medium 4.8

    \An issue was discovered in Cobham SAILOR VSAT Ku v.164B019, allows a remote attacker to execute arbitrary code via a c…

  • Medium 6.1

    Cross Site Scripting vulnerability in Rainbow external link network disk v.5.5 allows a remote attacker to execute arbi…

  • Medium 6.1

    A cross-site scripting (XSS) vulnerability in RageFrame2 v2.6.43, allows remote attackers to execute arbitrary web scri…

  • Medium 4.7

    Leantime 3.0.6 is vulnerable to HTML Injection via /dashboard/show#/tickets/newTicket.

  • Medium 6.1

    HTMLi at createFolder Content Injection

    There is an HTML injection vulnerability in Esri Portal for ArcGIS 11.0 and below that may allow a remote, unauthenticated attacker to craft a URL which, when clicked, could potentially generate a message that may entice an unsuspecting victim to visit an arb…

  • Medium 4.7

    Aterm WG1800HP4, WG1200HS3, WG1900HP2, WG1200HP3, WG1800HP3, WG1200HS2, WG1900HP, WG1200HP2, W1200EX(-MS), WG1200HS, WG…

  • Medium 6.3

    HP Printer Firmware Update Utility for Certain HP DeskJet Printers - Potential Execution of Arbitrary Code

    A user with administrative privileges can create a compromised dll file of the same name as the original dll within the HP printer’s Firmware Update Utility (FUU) bundle and place it in the Microsoft Windows default downloads directory which can lead to poten…

  • Medium 5.4

    Cross-site Scripting in Moodle Chat

    The Chat activity in Moodle 4.3.3 allows students to insert a potentially unwanted HTML A element or IMG element, or HTML content that leads to a performance degradation. NOTE: the vendor's Using_Chat page says "If you know some HTML code, you can use it in y…

  • Medium 6.6

    An issue was discovered in osCommerce v4, allows local attackers to bypass file upload restrictions and execute arbitra…

  • Medium 6.1

    Using a markup injection an attacker could have stolen nonce values. This could have been used to bypass strict content…

  • Medium 4.7

    RaspAP raspap-webgui HTTP POST Request provider.php code injection

    A vulnerability was found in RaspAP raspap-webgui 3.0.9 and classified as critical. This issue affects some unknown processing of the file includes/provider.php of the component HTTP POST Request Handler. The manipulation of the argument country leads to code…

  • Medium 6.6

    An issue in zuoxingdong lagom v.0.1.2 allows a local attacker to execute arbitrary code via the pickle_load function of…

  • Medium 6.1

    A reflected cross-site scripting (XSS) vulnerability exists in SuperCali version 1.1.0, allowing remote attackers to ex…

  • Medium 6.3

    ZhiCms setcontroller.php index code injection

    A vulnerability, which was classified as critical, was found in ZhiCms 4.0. Affected is the function index of the file app/manage/controller/setcontroller.php. The manipulation of the argument sitename leads to code injection. It is possible to launch the att…

  • Medium 6.1
    CVE-2024-25202 Public exploit

    Cross Site Scripting vulnerability in Phpgurukul User Registration & Login and User Management System 1.0 allows attack…

  • Medium 6.3

    Remote Code Execution attack on LG Signage

    This vulnerability allows remote attackers to execute arbitrary code on the affected webOS of LG Signage.

  • Medium 5.6

    Shopwind Installation DefaultController.php actionCreate code injection

    A vulnerability was found in Shopwind up to 4.6. It has been rated as critical. This issue affects the function actionCreate of the file /public/install/controllers/DefaultController.php of the component Installation. The manipulation leads to code injection.…

  • Medium 6.1
    CVE-2024-24396 Public exploit

    Stimulsoft Dashboard.JS Cross Site Scripting vulnerability

    Cross Site Scripting vulnerability in Stimulsoft GmbH Stimulsoft Dashboard.JS before v.2024.1.2 allows a remote attacker to execute arbitrary code via a crafted payload to the search bar component.

  • Medium 6.8

    An issue in Blurams Lumi Security Camera (A31C) v.2.3.38.12558 allows a physically proximate attackers to execute arbit…

  • Medium 6.4

    A code injection vulnerability affects HCL BigFix ServiceNow Data Flow

    HCL BigFix ServiceNow is vulnerable to arbitrary code injection. A malicious authorized attacker could inject arbitrary code and execute within the context of the running user.

  • Medium 6.3

    个人开源 mldong DecisionModel.java ExpressionEngine code injection

    A vulnerability, which was classified as critical, has been found in 个人开源 mldong 1.0. This issue affects the function ExpressionEngine of the file com/mldong/modules/wf/engine/model/DecisionModel.java. The manipulation leads to code injection. The attack may …

  • Medium 5.5
    CVE-2023-6548 Exploited

    Improper Control of Generation of Code ('Code Injection') in NetScaler ADC and NetScaler Gateway allows an attacker wit…

    KEV Jan 17, 2024
  • Medium 6.7

    Mock: privilege escalation for users that can access mock configuration

    The Mock software contains a vulnerability wherein an attacker could potentially exploit privilege escalation, enabling the execution of arbitrary code with root user privileges. This weakness stems from the absence of proper sandboxing during the expansion a…

  • Medium 6.5

    A vulnerability was reported in the Lenovo Browser Mobile and Lenovo Browser HD Apps for Android that could allow an at…

  • Medium 4.3

    Command Injection Vulnerability of ZTE's ZXCLOUD iRAI

    There is a command injection vulnerability of ZTE's ZXCLOUD iRAI. Due to the  program  failed to adequately validate the user's input, an attacker could exploit this vulnerability  to escalate local privileges.

  • Medium 6.3

    Magic-Api code injection

    A vulnerability has been found in Magic-Api up to 2.0.1 and classified as critical. Affected by this vulnerability is an unknown functionality of the file /resource/file/api/save?auto=1. The manipulation leads to code injection. The attack can be launched rem…

  • Medium 6.3
    CVE-2024-0195 Public exploit Scanner template EPSS 19%

    spider-flow FunctionController.java FunctionService.saveFunction code injection

    A vulnerability, which was classified as critical, was found in spider-flow 0.4.3. Affected is the function FunctionService.saveFunction of the file src/main/java/org/spiderflow/controller/FunctionController.java. The manipulation leads to code injection. It …

  • Medium 5.0

    ShifuML shifu Java Expression Language DataPurifier.java code injection

    A vulnerability has been found in ShifuML shifu 0.12.0 and classified as critical. Affected by this vulnerability is an unknown functionality of the file src/main/java/ml/shifu/shifu/core/DataPurifier.java of the component Java Expression Language Handler. Th…

  • Medium 5.3

    CSV Injection vulnerability in Sesami Cash Point & Transport Optimizer (CPTO) version 6.3.8.6 (#718), allows attackers …