Skip to content
OpenAdvisories

Weakness (CWE)

CWE-78: OS Command Injection

Base Improper Neutralization of Special Elements used in an OS Command

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command before it is sent to a downstream component.

How to prevent it (8 mitigations)
  1. Architecture and Design

    If at all possible, use library calls rather than external processes to recreate the desired functionality.

  2. Architecture and Design, Operation

    Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.

    OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.

    This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.

    Be careful to avoid CWE-243 and other weaknesses related to jails.

  3. Architecture and Design

    For any data that will be used to generate a command to be executed, keep as much of that data out of external control as possible. For example, in web applications, this may require storing the data locally in the session's state instead of sending it out to the client in a hidden form field.

  4. Architecture and Design

    For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

  5. Architecture and Design

    Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

    For example, consider using the ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help the programmer encode outputs in a manner less prone to error.

  6. Implementation

    While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).

  7. Implementation

    If the program to be executed allows arguments to be specified within an input file or from standard input, then consider using that mode to pass arguments instead of the command line.

  8. Architecture and Design

    If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.

    Some languages offer multiple functions that can be used to invoke commands. Where possible, identify any function that invokes a command shell using a single string, and replace it with a function that requires individual arguments. These functions typically perform appropriate quoting and filtering of arguments. For example, in C, the system() function accepts a string that contains the entire command to be executed, whereas execl(), execve(), and others require an array of strings, one for each argument. In Windows, CreateProcess() only accepts one command at a time. In Perl, if system() is provided with an array of arguments, then it will quote each of the arguments.

Source: MITRE CWE-78

1,588 results · Clear filters · Feed

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.8

    This vulnerability allows remote attackers to execute arbitrary code on affected installations of CentOS Web Panel cwp-…

  • Critical 9.3

    Command injection in codecov (npm package)

    In codecov (npm package) before version 3.7.1 the upload method has a command injection vulnerability. Clients of the codecov-node library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability. A similar CVE (CVE…

  • Critical 9.8
    CVE-2020-11981 Public exploit Scanner template EPSS 37%

    Command injection via Celery broker in Apache Airflow

    An issue was found in Apache Airflow versions 1.10.10 and below. When using CeleryExecutor, if an attacker can connect to the broker (Redis, RabbitMQ) directly, it is possible to inject commands, resulting in the celery worker running arbitrary commands.

  • Critical 9.8
    CVE-2020-13925 Public exploit EPSS 20%

    Command Injection in Kylin

    Similar to CVE-2020-1956, Kylin has one more restful API which concatenates the API inputs into OS commands and then executes them on the server; while the reported API misses necessary input validation, which causes the hackers to have the possibility to exe…

  • Critical 9.8
    CVE-2020-10987 Exploited Public exploit Scanner template EPSS 80%

    The goform/setUsbUnload endpoint of Tenda AC15 AC1900 version 15.03.05.19 allows remote attackers to execute arbitrary …

    KEV Nov 3, 2021
  • Critical 9.8

    Injection and Command Injection in devcert

    A command injection vulnerability in the `devcert` module may lead to remote code execution when users of the module pass untrusted input to the `certificateFor` function.

  • Critical 9.8

    OS Command Injection in Locutus

    php/exec/escapeshellarg in Locutus PHP through 2.0.11 allows an attacker to achieve code execution.

  • Critical 9.8
    CVE-2020-15415 Exploited Scanner template EPSS 84%

    On DrayTek Vigor3900, Vigor2960, and Vigor300B devices before 1.5.1, cgi-bin/mainfunction.cgi/cvmcfgupload allows remot…

    KEV Sep 30, 2024
  • Critical 9.8

    OS Command Injection in wifiscanner

    wifiscanner.js in thingsSDK WiFi Scanner 1.0.1 allows Code Injection because it can be used with options to overwrite the default executable/binary path and its arguments. An attacker can abuse this functionality to execute arbitrary code.

  • Critical 9.8

    Magento command injection vulnerability

    Magento versions 2.3.4 and earlier, 2.2.11 and earlier (see note), 1.14.4.4 and earlier, and 1.9.4.4 and earlier have a command injection vulnerability. Successful exploitation could lead to arbitrary code execution.

  • Critical 9.8

    Magento command injection vulnerability

    Magento versions 2.3.4 and earlier, 2.2.11 and earlier (see note), 1.14.4.4 and earlier, and 1.9.4.4 and earlier have a command injection vulnerability. Successful exploitation could lead to arbitrary code execution.

  • Critical 9.8

    Magento command injection vulnerability

    Magento versions 2.3.4 and earlier, 2.2.11 and earlier (see note), 1.14.4.4 and earlier, and 1.9.4.4 and earlier have a command injection vulnerability. Successful exploitation could lead to arbitrary code execution.

  • Critical 9.8

    Magento command injection vulnerability

    Magento versions 2.3.4 and earlier, 2.2.11 and earlier (see note), 1.14.4.4 and earlier, and 1.9.4.4 and earlier have a command injection vulnerability. Successful exploitation could lead to arbitrary code execution.

  • Critical 9.1
    CVE-2020-8816 Exploited Public exploit EPSS 78%

    Pi-hole Web v4.3.2 (aka AdminLTE) allows Remote Code Execution by privileged dashboard users via a crafted DHCP static …

    KEV Dec 10, 2021
  • Critical 9.8

    OS Command Injection in jw.util

    An exploitable vulnerability exists in the configuration-loading functionality of the jw.util package before 2.3 for Python. When loading a configuration with FromString or FromStream with YAML, one can execute arbitrary Python code, resulting in OS command e…

  • Critical 9.1
    CVE-2020-4428 Exploited Public exploit EPSS 62%

    IBM Data Risk Manager 2.0.1, 2.0.2, 2.0.3, and 2.0.4 could allow a remote authenticated attacker to execute arbitrary c…

    KEV Nov 3, 2021
  • Critical 9.8

    curlrequest allows execution of arbitrary commands

    curlrequest through 1.0.1 allows reading any file by populating the file parameter with user input.