This vulnerability occurs when an application relies on an external search path, provided by a user or environment, to find and load critical resources like executables or libraries. Because the application does not fully control this path, an attacker can manipulate it to point to malicious files.
An untrusted search path allows attackers to hijack the application's resource loading process. By manipulating environment variables like PATH or LD_PRELOAD on Linux, or the DLL search order on Windows, an attacker can trick the application into running their own malicious code, accessing sensitive data, or altering configuration. This happens because the application trusts the search path mechanism without properly validating the final location or integrity of the resources it loads. The core risk is the unauthorized elevation of control. Instead of exploiting a code flaw, the attacker subverts the trusted process of finding dependencies. To prevent this, developers must harden resource loading by using absolute paths, sanitizing environment variables, and explicitly defining safe search directories within the application's control, rather than relying on external system state.
Impact: Gain Privileges or Assume IdentityExecute Unauthorized Code or Commands
There is the potential for arbitrary code execution with privileges of the vulnerable program.
Impact: DoS: Crash, Exit, or Restart
The program could be redirected to the wrong files, potentially triggering a crash or hang when the targeted file is too large or does not have the expected format.
Impact: Read Files or Directories
The program could send the output of unauthorized files to the attacker.
Strategy: Attack Surface Reduction
c
/* Raise privileges to those needed for accessing DIR. /
cThe user sets the PATH to reference a directory under the attacker's control, such as "/my/dir/".
The attacker creates a malicious program called "ls", and puts that program in /my/dir
The user executes the program.
When system() is executed, the shell consults the PATH to find the ls program
The program finds the attacker's malicious program, "/my/dir/ls". It doesn't find "/bin/ls" because PATH does not contain "/bin/".
The program executes the attacker's malicious program with the raised privileges.
java//assume getCurrentUser() returns a username that is guaranteed to be alphanumeric (avoiding CWE-78)* $userName = getCurrentUser(); $command = 'ps aux | grep ' . $userName; system($command);
javaHigh