---
title: "CAPEC-248: Command Injection"
url: https://radicalnotion.ai/capec/capec-248
type: capec
description: "An adversary looking to execute a command of their choosing, injects new items into an existing command thus modifying interpretation away from what was intended. Commands in this context are often standalone strings that are interpreted by a downstream component and cause specific responses. This type of attack is possible when untrusted values are used to build these command strings. Weaknesses in input validation or command construction can enable the attack and lead to successful exploitation."
updated: 2026-06-01
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CAPEC-248: Command Injection

- **Abstraction:** Meta
- **Status:** Stable
- **Typical severity:** High
- **Likelihood of attack:** Medium
- **CAPEC catalog version:** 3.9

## Description

An adversary looking to execute a command of their choosing, injects new items into an existing command thus modifying interpretation away from what was intended. Commands in this context are often standalone strings that are interpreted by a downstream component and cause specific responses. This type of attack is possible when untrusted values are used to build these command strings. Weaknesses in input validation or command construction can enable the attack and lead to successful exploitation.

## Prerequisites

- The target application must accept input from the user and then use this input in the construction of commands to be executed. In virtually all cases, this is some form of string input that is concatenated to a constant string defined by the application to form the full command to be executed.

## Consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity, Availability | Execute Unauthorized Commands | A successful command injection attack enables an adversary to alter the command being executed and achieve a variety of negative consequences depending on the makeup of the new command. This includes potential information disclosure or the corruption of application data. |

## Mitigations

- All user-controllable input should be validated and filtered for potentially unwanted characters. Using an allowlist for input is desired, but if use of a denylist approach is necessary, then focusing on command related terms and delimiters is necessary.
- Input should be encoded prior to use in commands to make sure command related characters are not treated as part of the command. For example, quotation characters may need to be encoded so that the application does not treat the quotation as a delimiter.
- Input should be parameterized, or restricted to data sections of a command, thus removing the chance that the input will be treated as part of the command itself.

## Related weaknesses (CWE)

- [CWE-77](https://radicalnotion.ai/cwe/cwe-77): Improper Neutralization of Special Elements used in a Command

## Related attack patterns

| Relationship | CAPEC | Name |
| --- | --- | --- |
| Child | [CAPEC-40](https://radicalnotion.ai/capec/capec-40) | Manipulating Writeable Terminal Devices |
| Child | [CAPEC-66](https://radicalnotion.ai/capec/capec-66) | SQL Injection |
| Child | [CAPEC-88](https://radicalnotion.ai/capec/capec-88) | OS Command Injection |
| Child | [CAPEC-136](https://radicalnotion.ai/capec/capec-136) | LDAP Injection |
| Child | [CAPEC-183](https://radicalnotion.ai/capec/capec-183) | IMAP/SMTP Command Injection |
| Child | [CAPEC-250](https://radicalnotion.ai/capec/capec-250) | XML Injection |
| Child | [CAPEC-676](https://radicalnotion.ai/capec/capec-676) | NoSQL Injection |
| Related | [CAPEC-182](https://radicalnotion.ai/capec/capec-182) | Flash Injection |

## Taxonomy mappings

| Taxonomy | Entry | Id |
| --- | --- | --- |
| OWASP Attacks | Command Injection | - |

## Frequently asked questions

### What is CAPEC-248?

An adversary looking to execute a command of their choosing, injects new items into an existing command thus modifying interpretation away from what was intended. Commands in this context are often standalone strings that are interpreted by a downstream component and cause specific responses. This type of attack is possible when untrusted values are used to build these command strings. Weaknesses in input validation or command construction can enable the attack and lead to successful exploitation.

### How do you prevent CAPEC-248?

All user-controllable input should be validated and filtered for potentially unwanted characters. Using an allowlist for input is desired, but if use of a denylist approach is necessary, then focusing on command related terms and delimiters is necessary.

### What weaknesses does CAPEC-248 target?

CAPEC-248 exploits one CWE weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command).

### How severe is CAPEC-248?

MITRE rates CAPEC-248 as High severity with medium likelihood of attack.

Primary source: [MITRE CAPEC](https://capec.mitre.org/data/definitions/248.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/capec/capec-248). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
