Weakness · High
CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
What it is
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
- Severity (our rating)
- High
- Likelihood of exploit
- High
- Introduced during
- Implementation
- Exploited in the wild
- 31 known exploited CVEs
In more detail
Many protocols and products have their own custom command language. While OS or shell command strings are frequently discovered and targeted, developers may not realize that these other command languages might also be vulnerable to attacks.
What an attacker can do
- Execute Unauthorized Code or Commands (Integrity, Confidentiality, Availability)
How to prevent it
Architecture and Design
- If at all possible, use library calls rather than external processes to recreate the desired functionality.
Implementation
- If possible, ensure that all external commands called from the program are statically created.
- 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.
Operation
- Run time: Run time policy enforcement may be used in an allowlist fashion to prevent use of any non-sanctioned commands.
System Configuration
- Assign permissions that prevent the user from accessing/opening privileged files.
How to find it
- Automated Static Analysis. Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Exploited in the wild: 31 CVEs
Vulnerabilities caused by CWE-77 that attackers have used, from CISA's Known Exploited Vulnerabilities catalog, newest first.
- CVE-2016-3081Apache Struts Command Injection Vulnerability · added October 8, 2026
- CVE-2026-8037Progress LoadMaster Command Injection Vulnerability · added August 7, 2026
- CVE-2026-42271BerriAI LiteLLM Command Injection Vulnerability · added June 8, 2026
- CVE-2025-29635D-Link DIR-823X Command Injection Vulnerability · added April 24, 2026
- CVE-2026-22719Broadcom VMware Aria Operations Command Injection Vulnerability · added March 3, 2026
- CVE-2025-4008Smartbedded Meteobridge Command Injection Vulnerability · added October 2, 2025
- CVE-2025-59689Libraesva Email Security Gateway Command Injection Vulnerability · added September 29, 2025
- CVE-2025-10035 ransomwareFortra GoAnywhere MFT Deserialization of Untrusted Data Vulnerability · added September 29, 2025
- CVE-2020-25079D-Link DCS-2530L and DCS-2670L Command Injection Vulnerability · added August 5, 2025
- CVE-2016-10033PHPMailer Command Injection Vulnerability · added July 7, 2025
- CVE-2023-33538TP-Link Multiple Routers Command Injection Vulnerability · added June 16, 2025
- CVE-2023-20118Cisco Small Business RV Series Routers Command Injection Vulnerability · added March 3, 2025
- CVE-2024-12356BeyondTrust Privileged Remote Access (PRA) and Remote Support (RS) Command Injection Vulnerability · added December 19, 2024
- CVE-2024-9474 ransomwarePalo Alto Networks PAN-OS Management Interface OS Command Injection Vulnerability · added November 18, 2024
- CVE-2024-9380Ivanti Cloud Services Appliance (CSA) OS Command Injection Vulnerability · added October 9, 2024
- CVE-2024-3400 ransomwarePalo Alto Networks PAN-OS Command Injection Vulnerability · added April 12, 2024
- CVE-2024-3273D-Link Multiple NAS Devices Command Injection Vulnerability · added April 11, 2024
- CVE-2024-21887 ransomwareIvanti Connect Secure and Policy Secure Command Injection Vulnerability · added January 10, 2024
- CVE-2016-20017D-Link DSL-2750B Devices Command Injection Vulnerability · added January 8, 2024
- CVE-2023-1671Sophos Web Appliance Command Injection Vulnerability · added November 16, 2023
- CVE-2023-20887Vmware Aria Operations for Networks Command Injection Vulnerability · added June 22, 2023
- CVE-2023-1389TP-Link Archer AX-21 Command Injection Vulnerability · added May 1, 2023
- CVE-2022-40765 ransomwareMitel MiVoice Connect Command Injection Vulnerability · added February 21, 2023
- CVE-2018-19949 ransomwareQNAP NAS File Station Command Injection Vulnerability · added May 24, 2022
- CVE-2016-6367Cisco Adaptive Security Appliance (ASA) CLI Remote Code Execution Vulnerability · added May 24, 2022
- CVE-2010-5330Ubiquiti AirOS Command Injection Vulnerability · added April 15, 2022
- CVE-2020-2509QNAP Network-Attached Storage (NAS) Command Injection Vulnerability · added April 11, 2022
- CVE-2016-1555NETGEAR Multiple WAP Devices Command Injection Vulnerability · added March 25, 2022
- CVE-2015-2051D-Link DIR-645 Router Remote Code Execution Vulnerability · added February 10, 2022
- CVE-2021-22899Ivanti Pulse Connect Secure Command Injection Vulnerability · added November 3, 2021
- CVE-2019-0541Microsoft MSHTML Remote Code Execution Vulnerability · added November 3, 2021
H2 Security
Found it in your code?
We review where it appears, fix it with your team, and check it was not already used against you.
Talk to our teamT Academy
Stop writing it in the first place
Learn to build software and systems without weaknesses like this one, with practice on real hosts in your browser, every objective checked on the machine.
Start freeSource: MITRE Common Weakness Enumeration, CWE version 4.19.1. CWE is a trademark of The MITRE Corporation.