---
title: "CAPEC-13: Subverting Environment Variable Values"
url: https://radicalnotion.ai/capec/capec-13
type: capec
description: "The adversary directly or indirectly modifies environment variables used by or controlling the target software. The adversary's goal is to cause the target software to deviate from its expected operation in a manner that benefits the adversary."
updated: 2026-06-01
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CAPEC-13: Subverting Environment Variable Values

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

## Description

The adversary directly or indirectly modifies environment variables used by or controlling the target software. The adversary's goal is to cause the target software to deviate from its expected operation in a manner that benefits the adversary.

## Execution flow

### Step 1: Explore

\[Probe target application\] The adversary first probes the target application to determine important information about the target. This information could include types software used, software versions, what user input the application consumes, and so on. Most importantly, the adversary tries to determine what environment variables might be used by the underlying software, or even the application itself.

### Step 2: Experiment

\[Find user-controlled environment variables\] Using the information found by probing the application, the adversary attempts to manipulate any user-controlled environment variables they have found are being used by the application, or suspect are being used by the application, and observe the effects of these changes. If the adversary notices any significant changes to the application, they will know that a certain environment variable is important to the application behavior and indicates a possible attack vector.

- Alter known environment variables such as "$PATH", "$HOSTNAME", or "LD\_LIBRARY\_PATH" and see if application behavior changes.

### Step 3: Exploit

\[Manipulate user-controlled environment variables\] The adversary manipulates the found environment variable(s) to abuse the normal flow of processes or to gain access to privileged resources.

## Prerequisites

- An environment variable is accessible to the user.
- An environment variable used by the application can be tainted with user supplied data.
- Input data used in an environment variable is not validated properly.
- The variables encapsulation is not done properly. For instance setting a variable as public in a class makes it visible and an adversary may attempt to manipulate that variable.

## Skills required

- **Low:** In a web based scenario, the client controls the data that it submitted to the server. So anybody can try to send malicious data and try to bypass the authentication mechanism.
- **High:** Some more advanced attacks may require knowledge about protocols and probing technique which help controlling a variable. The malicious user may try to understand the authentication mechanism in order to defeat it.

## Consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity, Availability | Execute Unauthorized Commands | Run Arbitrary Code |
| Confidentiality, Access Control, Authorization | Bypass Protection Mechanism | - |
| Availability | Unreliable Execution | - |
| Confidentiality | Read Data | - |
| Accountability | Hide Activities | - |

## Mitigations

- Protect environment variables against unauthorized read and write access.
- Protect the configuration files which contain environment variables against illegitimate read and write access.
- Assume all input is malicious. Create an allowlist that defines all valid input to the software system based on the requirements specifications. Input that does not match against the allowlist should not be permitted to enter into the system.
- Apply the least privilege principles. If a process has no legitimate reason to read an environment variable do not give that privilege.

## Example instances

Changing the LD\_LIBRARY\_PATH environment variable in TELNET will cause TELNET to use an alternate (possibly Trojan) version of a function library. The Trojan library must be accessible using the target file system and should include Trojan code that will allow the user to log in with a bad password. This requires that the adversary upload the Trojan library to a specific location on the target. As an alternative to uploading a Trojan file, some file systems support file paths that include remote addresses, such as \\\\172.16.2.100\\shared\_files\\trojan\_dll.dll. See also: Path Manipulation (CVE-1999-0073)

The HISTCONTROL environment variable keeps track of what should be saved by the history command and eventually into the ~/.bash\_history file when a user logs out. This setting can be configured to ignore commands that start with a space by simply setting it to "ignorespace". HISTCONTROL can also be set to ignore duplicate commands by setting it to "ignoredups". In some Linux systems, this is set by default to "ignoreboth" which covers both of the previous examples. This means that " ls" will not be saved, but "ls" would be saved by history. HISTCONTROL does not exist by default on macOS, but can be set by the user and will be respected. Adversaries can use this to operate without leaving traces by simply prepending a space to all of their terminal commands.

## Related weaknesses (CWE)

- [CWE-15](https://radicalnotion.ai/cwe/cwe-15): External Control of System or Configuration Setting
- [CWE-20](https://radicalnotion.ai/cwe/cwe-20): Improper Input Validation
- [CWE-73](https://radicalnotion.ai/cwe/cwe-73): External Control of File Name or Path
- [CWE-74](https://radicalnotion.ai/cwe/cwe-74): Improper Neutralization of Special Elements in Output Used by a Downstream Component
- [CWE-200](https://radicalnotion.ai/cwe/cwe-200): Exposure of Sensitive Information to an Unauthorized Actor
- [CWE-285](https://radicalnotion.ai/cwe/cwe-285): Improper Authorization
- [CWE-302](https://radicalnotion.ai/cwe/cwe-302): Authentication Bypass by Assumed-Immutable Data
- [CWE-353](https://radicalnotion.ai/cwe/cwe-353): Missing Support for Integrity Check

## Related attack patterns

| Relationship | CAPEC | Name |
| --- | --- | --- |
| Parent | [CAPEC-77](https://radicalnotion.ai/capec/capec-77) | Manipulating User-Controlled Variables |
| Peer | [CAPEC-10](https://radicalnotion.ai/capec/capec-10) | Buffer Overflow via Environment Variables |
| Can precede | [CAPEC-14](https://radicalnotion.ai/capec/capec-14) | Client-side Injection-induced Buffer Overflow |

## Taxonomy mappings

| Taxonomy | Entry | Id |
| --- | --- | --- |
| ATTACK | Impair Defenses:Impair Command History Logging | 1562.003 |
| ATTACK | Hijack Execution Flow:Dynamic Linker Hijacking | 1574.006 |
| ATTACK | Hijack Execution Flow:Path Interception by PATH Environment Variable | 1574.007 |

## Frequently asked questions

### What is CAPEC-13?

The adversary directly or indirectly modifies environment variables used by or controlling the target software. The adversary's goal is to cause the target software to deviate from its expected operation in a manner that benefits the adversary.

### How does a Subverting Environment Variable Values attack work?

It typically unfolds over 3 phases. It begins with: \[Probe target application\] The adversary first probes the target application to determine important information about the target. This information could include types software used, software versions, what user input the application consumes, and so on. Most importantly, the adversary tries to determine what environment variables might be used by the underlying software, or even the application itself.

### How do you prevent CAPEC-13?

Protect environment variables against unauthorized read and write access.

### What weaknesses does CAPEC-13 target?

CAPEC-13 exploits 8 CWE weaknesses, including CWE-15 (External Control of System or Configuration Setting), CWE-20 (Improper Input Validation), CWE-73 (External Control of File Name or Path) and CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component).

### How severe is CAPEC-13?

MITRE rates CAPEC-13 as Very High severity with high likelihood of attack.

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

---

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