Although this weakness can occur with any type of resource, it is frequently introduced when a product uses a directory search path to find executables or code libraries, but the path contains a directory that can be modified by an attacker, such as "/tmp" or the current working directory.
In Windows-based systems, when the LoadLibrary or LoadLibraryEx function is called with a DLL name that does not contain a fully qualified path, the function follows a search order that includes two path elements that might be uncontrolled:
In some cases, the attack can be conducted remotely, such as when SMB or WebDAV network shares are used.
One or more locations in that path could include the Windows drive root or its subdirectories. This often exists in Linux-based code assuming the controlled nature of the root directory (/) or its subdirectories (/etc, etc), or a code that recursively accesses the parent directory. In Windows, the drive root and some of its subdirectories have weak permissions by default, which makes them uncontrolled.
In some Unix-based systems, a PATH might be created that contains an empty element, e.g. by splicing an empty variable into the PATH. This empty element can be interpreted as equivalent to the current working directory, which might be an untrusted search element.
In software package management frameworks (e.g., npm, RubyGems, or PyPi), the framework may identify dependencies on third-party libraries or other packages, then consult a repository that contains the desired package. The framework may search a public repository before a private repository. This could be exploited by attackers by placing a malicious package in the public repository that has the same name as a package from the private repository. The search path might not be directly under control of the developer relying on the framework, but this search order effectively contains an untrusted element.
Scope | Impact | Likelihood |
---|---|---|
Confidentiality Integrity Availability | Execute Unauthorized Code or Commands |
References | Description |
---|---|
CVE-2023-25815 | chain: a change in an underlying package causes the gettext function to use implicit initialization with a hard-coded path (CWE-1419) under the user-writable C:\ drive, introducing an untrusted search path element (CWE-427) that enables spoofing of messages. |
CVE-2022-4826 | Go-based git extension on Windows can search for and execute a malicious "..exe" in a repository because Go searches the current working directory if git.exe is not found in the PATH |
CVE-2020-26284 | A Static Site Generator built in Go, when running on Windows, searches the current working directory for a command, possibly allowing code execution using a malicious .exe or .bat file with the name being searched |
CVE-2022-24765 | Windows-based fork of git creates a ".git" folder in the C: drive, allowing local attackers to create a .git folder with a malicious config file |
CVE-2019-1552 | SSL package searches under "C:/usr/local" for configuration files and other critical data, but C:/usr/local might be world-writable. |
CVE-2010-3402 | "DLL hijacking" issue in document editor. |
CVE-2010-3397 | "DLL hijacking" issue in encryption software. |
CVE-2010-3138 | "DLL hijacking" issue in library used by multiple media players. |
CVE-2010-3152 | "DLL hijacking" issue in illustration program. |
CVE-2010-3147 | "DLL hijacking" issue in address book. |
CVE-2010-3135 | "DLL hijacking" issue in network monitoring software. |
CVE-2010-3131 | "DLL hijacking" issue in web browser. |
CVE-2010-1795 | "DLL hijacking" issue in music player/organizer. |
CVE-2002-1576 | Product uses the current working directory to find and execute a program, which allows local users to gain privileges by creating a symlink that points to a malicious version of the program. |
CVE-1999-1461 | Product trusts the PATH environmental variable to find and execute a program, which allows local users to obtain root access by modifying the PATH to point to a malicous version of that program. |
CVE-1999-1318 | Software uses a search path that includes the current working directory (.), which allows local users to gain privileges via malicious programs. |
CVE-2003-0579 | Admin software trusts the user-supplied -uv.install command line option to find and execute the uv.install program, which allows local users to gain privileges by providing a pathname that is under control of the user. |
CVE-2000-0854 | When a document is opened, the directory of that document is first used to locate DLLs , which could allow an attacker to execute arbitrary commands by inserting malicious DLLs into the same directory as the document. |
CVE-2001-0943 | Database trusts the PATH environment variable to find and execute programs, which allows local users to modify the PATH to point to malicious programs. |
CVE-2001-0942 | Database uses an environment variable to find and execute a program, which allows local users to execute arbitrary programs by changing the environment variable. |
CVE-2001-0507 | Server uses relative paths to find system files that will run in-process, which allows local users to gain privileges via a malicious file. |
CVE-2002-2017 | Product allows local users to execute arbitrary code by setting an environment variable to reference a malicious program. |
CVE-1999-0690 | Product includes the current directory in root's PATH variable. |
CVE-2001-0912 | Error during packaging causes product to include a hard-coded, non-standard directory in search path. |
CVE-2001-0289 | Product searches current working directory for configuration file. |
CVE-2005-1705 | Product searches current working directory for configuration file. |
CVE-2005-1307 | Product executable other program from current working directory. |
CVE-2002-2040 | Untrusted path. |
CVE-2005-2072 | Modification of trusted environment variable leads to untrusted path vulnerability. |
CVE-2005-1632 | Product searches /tmp for modules before other paths. |
CAPEC-ID | Attack Pattern Name |
---|---|
CAPEC-38 | Leveraging/Manipulating Configuration File Search Paths This pattern of attack sees an adversary load a malicious resource into a program's standard path so that when a known command is executed then the system instead executes the malicious component. The adversary can either modify the search path a program uses, like a PATH variable or classpath, or they can manipulate resources on the path to point to their malicious components. J2EE applications and other component based applications that are built from multiple binaries can have very long list of dependencies to execute. If one of these libraries and/or references is controllable by the attacker then application controls can be circumvented by the attacker. |
CAPEC-471 | Search Order Hijacking An adversary exploits a weakness in an application's specification of external libraries to exploit the functionality of the loader where the process loading the library searches first in the same directory in which the process binary resides and then in other directories. Exploitation of this preferential search order can allow an attacker to make the loading process load the adversary's rogue library rather than the legitimate library. This attack can be leveraged with many different libraries and with many different loading processes. No forensic trails are left in the system's registry or file system that an incorrect library had been loaded. |
Name | Organization | Date | Date release | Version |
---|---|---|---|---|
PLOVER | Draft 3 |
Name | Organization | Date | Comment |
---|---|---|---|
Eric Dalci | Cigital | updated Potential_Mitigations, Time_of_Introduction | |
CWE Content Team | MITRE | updated Relationships, Observed_Example, Other_Notes, Taxonomy_Mappings | |
CWE Content Team | MITRE | updated Description, Maintenance_Notes, Observed_Examples, Other_Notes, Potential_Mitigations, Relationships | |
CWE Content Team | MITRE | updated Alternate_Terms, Applicable_Platforms, Description, Maintenance_Notes, Observed_Examples, References, Relationship_Notes, Relationships | |
CWE Content Team | MITRE | updated Potential_Mitigations | |
CWE Content Team | MITRE | updated Common_Consequences | |
CWE Content Team | MITRE | updated Observed_Examples, Related_Attack_Patterns, Relationships | |
CWE Content Team | MITRE | updated Demonstrative_Examples, Observed_Examples, Potential_Mitigations | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Related_Attack_Patterns | |
CWE Content Team | MITRE | updated Related_Attack_Patterns, Relationships | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Potential_Mitigations | |
CWE Content Team | MITRE | updated Alternate_Terms, Description, Maintenance_Notes, References, Theoretical_Notes | |
CWE Content Team | MITRE | updated Demonstrative_Examples | |
CWE Content Team | MITRE | updated Observed_Examples | |
CWE Content Team | MITRE | updated Description, Observed_Examples, References | |
CWE Content Team | MITRE | updated Demonstrative_Examples, Detection_Factors, References, Relationships | |
CWE Content Team | MITRE | updated Mapping_Notes | |
CWE Content Team | MITRE | updated Observed_Examples |