CAPECattack pattern
CAPEC-13 Subverting Environment Variable Values
Very High
Official page ↗
- Abstraction
- Detailed
- Status
- Stable
- Likelihood of attack
- High
- Typical severity
- Very High
- CAPEC 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
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.
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.
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
• Confidentiality, Integrity, Availability: Execute Unauthorized Commands
• 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.
Related
Att&ck technique · not in database (1)
Att&ck technique · MITRE ATT&CK (2)
Can precede · CAPEC (1)
- CAPEC-14 Client-side Injection-induced Buffer Overflow attack pattern
Child of · CAPEC (1)
- CAPEC-77 Manipulating User-Controlled Variables attack pattern
Peer of · CAPEC (1)
- CAPEC-10 Buffer Overflow via Environment Variables attack pattern
Weakness · CWE (8)
- CWE-15 External Control of System or Configuration Setting weakness
- CWE-20 Improper Input Validation weakness
- CWE-200 Exposure of Sensitive Information to an Unauthorized Actor weakness
- CWE-285 Improper Authorization weakness
- CWE-302 Authentication Bypass by Assumed-Immutable Data weakness
- CWE-353 Missing Support for Integrity Check weakness
- CWE-73 External Control of File Name or Path weakness
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness
Referenced by CWE · attack pattern (8)
- CWE-15 External Control of System or Configuration Setting weakness
- CWE-20 Improper Input Validation weakness
- CWE-200 Exposure of Sensitive Information to an Unauthorized Actor weakness
- CWE-285 Improper Authorization weakness
- CWE-302 Authentication Bypass by Assumed-Immutable Data weakness
- CWE-353 Missing Support for Integrity Check weakness
- CWE-73 External Control of File Name or Path weakness
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness