CWE-77: Improper Neutralization of Special Elements used in a Command

What is CWE-77?

CWE-77 is Improper Neutralization of Special Elements used in a Command. The flaw arises when the product builds all or part of a command from externally influenced input but fails to neutralize, or incorrectly neutralizes, special elements that can alter the intended command when it is sent to a downstream component. The database currently holds 637 vulnerabilities mapped to CWE-77 and 4 of them are in the CISA Known Exploited Vulnerabilities catalog.

OWASP TOP 10:2025 RANK5 — A05:2025 — Injection
Related CVES (365 days)637
AbstractionClass
Likelihood of exploitHigh

Vulnerabilities mapped to CWE-77

637 vulnerabilities206% increase year over year

Vulnerabilities in CISA KEV for CWE-77

4 vulnerabilitiesNo change year over year

Official definition

ByMitre CWE

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. (Roles: Attack-Focused)

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.

Detailed description

Many protocols and products use their own command languages. Consequently, focusing only on OS or shell command strings is insufficient, because special syntax in a custom command language can also change the operation the application intended to perform. The weakness occurs when untrusted data is incorporated into a command and passed to an executing component without appropriate neutralization, allowing the data to terminate the intended command or introduce additional operations.

Characteristics

The defining pattern is untrusted or externally influenced data entering a command string that the product executes or sends to another component, while special characters or syntax are not handled correctly. The target may be an operating-system or shell command, but it may also be a custom protocol or product-specific command language. The weakness typically arises during implementation, when external data becomes part of a string executed as a command.

Common consequences

A malicious user may inject a delimiter, such as a semicolon, that ends the intended command and introduces a different command. This can enable unauthorized code or command execution and grant capabilities or privileges the attacker should not have. The resulting impacts can affect confidentiality, integrity, and availability, depending on the commands that become executable.

ImpactScopeExplanation
Execute Unauthorized Code or CommandsIntegrity, Confidentiality, AvailabilityIf a malicious user injects a character (such as a semi-colon) that delimits the end of one command and the beginning of another, it may be possible to then insert an entirely new and unrelated command that was not intended to be executed. This gives an attacker a privilege or capability that they would not otherwise have.

Risk mitigations

Architecture and design: Prefer library calls over external processes when they can provide the required functionality. Implementation: If external commands are necessary, create them statically whenever possible. Validate input using an accept-known-good allowlist that strictly follows the required specification, including length, type, permitted values, syntax, missing or extra fields, relationships between fields, and business rules; reject or transform nonconforming input. Do not rely only on denylists of malicious patterns, although denylists can help detect attacks or reject clearly malformed input. Operation: Enforce an allowlist of sanctioned commands at runtime. System configuration: Assign permissions so users cannot access or open privileged files.

  1. Architecture and DesignIf at all possible, use library calls rather than external processes to recreate the desired functionality.
  2. ImplementationIf possible, ensure that all external commands called from the program are statically created.
  3. Input Validation · ImplementationAssume 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.
  4. OperationRun time: Run time policy enforcement may be used in an allowlist fashion to prevent use of any non-sanctioned commands.
  5. System ConfigurationAssign permissions that prevent the user from accessing/opening privileged files.

Detection methods

Automated static analysis, commonly called SAST, can find some instances by analyzing source or compiled code without execution. It typically models data flow and control flow, then searches for potentially vulnerable paths connecting input sources with sinks where data interacts with external components or lower layers such as the operating system. This approach has high effectiveness, but it is limited to cases that the analysis can model and recognize.

MethodApproachEffectiveness
Automated Static AnalysisAutomated 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.)High

Representative vulnerabilities

The following are representative examples, not an exhaustive list:

  • CVE-2026-27806: a device management product allowed injection of Tcl/expect commands.
  • CVE-2022-1509, CVE-2021-41282, and CVE-2019-13398: allowed injection of sed script syntax.
  • CVE-2024-5184: an ML-based email analysis product exposed an API service where a malicious user could inject a direct prompt, take over service logic, and cause system prompts or sensitive data to be disclosed.
  • CVE-2020-11698: allowed injection of SNMP commands into a configuration file.
  • CVE-2019-12921: allowed command injection in the Magick Vector Graphics (MVG) language.
  • CVE-2022-36069: avoided OS command injection while generating Git commands but allowed injection of optional arguments when input began with a dash, a CWE-88 issue that could enable code execution.
  • CVE-1999-0067: a canonical OS command injection example in which a CGI program failed to neutralize the | metacharacter when invoking a phonebook program.
  • CVE-2020-9054: a chain in which improper input validation in a username parameter led to OS command injection, reportedly exploited in the wild according to CISA KEV.
Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.