Dark Mode

Settings

Capec-13 Detail

Subverting Environment Variable Values

Detailed Software Likelihood: High Typical Severity: Very High

Parents: 77

Threats: T271 T293

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.

Not present

External ID Source Link Description
CAPEC-13 capec https://capec.mitre.org/data/definitions/13.html
CWE-353 cwe http://cwe.mitre.org/data/definitions/353.html
CWE-285 cwe http://cwe.mitre.org/data/definitions/285.html
CWE-302 cwe http://cwe.mitre.org/data/definitions/302.html
CWE-74 cwe http://cwe.mitre.org/data/definitions/74.html
CWE-15 cwe http://cwe.mitre.org/data/definitions/15.html
CWE-73 cwe http://cwe.mitre.org/data/definitions/73.html
CWE-20 cwe http://cwe.mitre.org/data/definitions/20.html
CWE-200 cwe http://cwe.mitre.org/data/definitions/200.html
T1562.003 ATTACK https://attack.mitre.org/wiki/Technique/T1562/003 Impair Defenses:Impair Command History Logging
T1574.006 ATTACK https://attack.mitre.org/wiki/Technique/T1574/006 Hijack Execution Flow:Dynamic Linker Hijacking
T1574.007 ATTACK https://attack.mitre.org/wiki/Technique/T1574/007 Hijack Execution Flow:Path Interception by PATH Environment Variable
REF-1 reference_from_CAPEC G. Hoglund, G. McGraw, Exploiting Software: How to Break Code, 2004--02, Addison-Wesley
Explore
  1. 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.

Experiment
  1. 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.

  2. Techniques
    Alter known environment variables such as "$PATH", "$HOSTNAME", or "LD_LIBRARY_PATH" and see if application behavior changes.
Exploit
  1. 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.

  1. An environment variable is accessible to the user.
  2. An environment variable used by the application can be tainted with user supplied data.
  3. Input data used in an environment variable is not validated properly.
  4. 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.

Not present

Low High
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.
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.
Integrity Availability Authorization Access Control Accountability Confidentiality
Execute Unauthorized Commands (Run Arbitrary Code) Execute Unauthorized Commands (Run Arbitrary Code) Bypass Protection Mechanism Bypass Protection Mechanism Hide Activities Execute Unauthorized Commands (Run Arbitrary Code)
Unreliable Execution Bypass Protection Mechanism
Read Data
  1. 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)
  2. 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.