CAPECattack pattern

CAPEC-88 OS Command Injection

High Official page ↗
Abstraction
Standard
Status
Draft
Likelihood of attack
High
Typical severity
High
CAPEC version
3.9

Description

In this type of an attack, an adversary injects operating system commands into existing application functions. An application that uses untrusted input to build command strings is vulnerable. An adversary can leverage OS command injection in an application to elevate privileges, execute arbitrary commands and compromise the underlying operating system.

Execution flow

1. [Explore] [Identify inputs for OS commands] The attacker determines user controllable input that gets passed as part of a command to the underlying operating system. 2. [Explore] [Survey the Application] The attacker surveys the target application, possibly as a valid and authenticated user 3. [Experiment] [Vary inputs, looking for malicious results.] Depending on whether the application being exploited is a remote or local one the attacker crafts the appropriate malicious input, containing OS commands, to be passed to the application 4. [Exploit] [Execute malicious commands] The attacker may steal information, install a back door access mechanism, elevate privileges or compromise the system in some other way.

Prerequisites

• User controllable input used as part of commands to the underlying operating system.

Skills required

• [High] The attacker needs to have knowledge of not only the application to exploit but also the exact nature of commands that pertain to the target operating system. This may involve, though not always, knowledge of specific assembly commands for the platform.

Consequences

• Confidentiality, Integrity, Availability: Execute Unauthorized Commands • Confidentiality, Access Control, Authorization: Gain Privileges, Bypass Protection Mechanism • Confidentiality: Read Data

Mitigations

• Use language APIs rather than relying on passing data to the operating system shell or command line. Doing so ensures that the available protection mechanisms in the language are intact and applicable. • Filter all incoming data to escape or remove characters or strings that can be potentially misinterpreted as operating system or shell commands • All application processes should be run with the minimal privileges required. Also, processes must shed privileges as soon as they no longer require them.

Related

Child of · CAPEC (1)

Weakness · CWE (4)

  • CWE-20 Improper Input Validation weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-78 Improper Neutralization of Special Elements used in an OS Command weakness
  • CWE-88 Improper Neutralization of Argument Delimiters in a Command weakness

Referenced by CWE · attack pattern (4)

  • CWE-20 Improper Input Validation weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-78 Improper Neutralization of Special Elements used in an OS Command weakness
  • CWE-88 Improper Neutralization of Argument Delimiters in a Command weakness