Command Injection
Pronunciation: kuh-MAND in-JEK-shun
Also known as: OS Command Injection
Definition
Command Injection is a vulnerability in which untrusted input causes an application to execute unintended operating-system commands or command-line arguments. It is used to describe a path by which an attacker can read data, alter systems, run malware, steal secrets, or take control of application infrastructure.
Overview
Meaning and scope
Command Injection is a vulnerability in which untrusted input causes an application to execute unintended operating-system commands or command-line arguments. It is used to describe a path by which an attacker can read data, alter systems, run malware, steal secrets, or take control of application infrastructure.
Mechanism and operation
Its operational purpose is to describe a path by which an attacker can read data, alter systems, run malware, steal secrets, or take control of application infrastructure. A typical workflow is as follows: The application builds a shell command from user-controlled data and passes it to an interpreter. Attackers add separators, substitutions, options, or encoded payloads that change the intended command behavior. Core controls include avoid shell execution, use safe library APIs, fixed command and argument allowlists, parameter separation, least-privilege service accounts, sandboxing, input constraints, patching, and security testing. In payment and crypto operations, A vulnerable export, file conversion, wallet tool, callback utility, or administrative function could expose API credentials, private keys, customer data, or payment records.
Practical payment example
An attacker supplies shell metacharacters in a file-name parameter, exposing a backend that passes untrusted text to a command interpreter.
Operational checks
Evidence should include affected endpoint, input, execution path, command, process identity, host events, accessed secrets, outbound connections, code version, exploit proof, and remediation test. Escaping or filtering alone is fragile because behavior varies across operating systems, shells, and encodings. A production treatment of Command Injection should test the use of an application to execute unintended operating-system commands or command-line arguments within the relevant asset, decision, or service state.
Distinctions and limits
Review of Command Injection should determine whether safeguards addressing application to execute unintended operating-system commands, and command-line arguments changed exposure in practice, not merely whether a document or setting existed.
Related reading
Related definitions: Credential Store.
Example
An attacker supplies shell metacharacters in a file-name parameter, exposing a backend that passes untrusted text to a command interpreter.
Comparison
The relevant distinction is code injection or SQL injection, which target different interpreters or execution contexts even though all arise from unsafe handling of untrusted input. Review of Command Injection should determine whether safeguards addressing application to execute unintended operating-system commands, and command-line arguments changed exposure in practice, not merely whether a document or setting existed.
Key Takeaway
Command Injection is best prevented by avoiding shell construction with untrusted input and using constrained, non-shell APIs under least privilege.
Sources
- OS Command Injection Defense Cheat Sheet — OWASP (2026-08-03)
- Security and Privacy Controls for Information Systems and Organizations — NIST (2026-08-03)
- Logging Cheat Sheet — OWASP (2026-08-03)