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. It differs from code injection or SQL injection, which target different interpreters or execution contexts even though all arise from unsafe handling of untrusted input.
Overview
Command Injection is a vulnerability in which untrusted input causes an application to execute unintended operating-system commands or command-line arguments. 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. It should be considered alongside Credential Store. 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.
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.
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. The Command Injection context record for application to execute unintended operating-system commands, and command-line arguments should preserve source data, configuration or policy version, responsible actor, exception, and outcome. 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)