CWE Glossary Definition |
👁 x
|
CWE-427: Uncontrolled Search Path Element
|
Weakness ID: 427
Vulnerability Mapping:
ALLOWED
This CWE ID could be used to map to real-world vulnerabilities in limited situations requiring careful review
(with careful review of mapping notes)
Abstraction:
Base
Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource.
|
The product uses a fixed or controlled search path to find resources, but one or more locations in that path can be under the control of unintended actors.
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:
- the directory from which the program has been loaded
- the current working directory
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.
|
DLL preloading
|
This term is one of several that are used to describe exploitation of untrusted search path elements in Windows systems, which received wide attention in August 2010. From a weakness perspective, the term is imprecise because it can apply to both CWE-426 and CWE-427.
|
|
Binary planting
|
This term is one of several that are used to describe exploitation of untrusted search path elements in Windows systems, which received wide attention in August 2010. From a weakness perspective, the term is imprecise because it can apply to both CWE-426 and CWE-427.
|
|
Insecure library loading
|
This term is one of several that are used to describe exploitation of untrusted search path elements in Windows systems, which received wide attention in August 2010. From a weakness perspective, the term is imprecise because it can apply to both CWE-426 and CWE-427.
|
|
Dependency confusion
|
As of February 2021, this term is used to describe CWE-427 in the context of managing installation of software package dependencies, in which attackers release packages on public sites where the names are the same as package names used by private repositories, and the search for the dependent package tries the public site first, downloading untrusted code. It may also be referred to as a "substitution attack."
|
👁 Section Help This table specifies different individual consequences
associated with the weakness. The Scope identifies the application security area that is
violated, while the Impact describes the negative technical impact that arises if an
adversary succeeds in exploiting this weakness. The Likelihood provides information about
how likely the specific consequence is expected to be seen relative to the other
consequences in the list. For example, there may be high likelihood that a weakness will be
exploited to achieve a certain impact, but a low likelihood that it will be exploited to
achieve a different impact.
| Impact |
Details |
|
Execute Unauthorized Code or Commands
|
Scope: Confidentiality, Integrity, Availability
|
👁 +
Potential Mitigations
| Phase(s) |
Mitigation |
|
Architecture and Design; Implementation
|
Strategy: Attack Surface Reduction
Hard-code the search path to a set of known-safe values (such as system directories), or only allow them to be specified by the administrator in a configuration file. Do not allow these settings to be modified by an external party. Be careful to avoid related weaknesses such as CWE-426 and CWE-428.
|
|
Implementation
|
Strategy: Attack Surface Reduction
When invoking other programs, specify those programs using fully-qualified pathnames. While this is an effective approach, code that uses fully-qualified pathnames might not be portable to other systems that do not use the same pathnames. The portability can be improved by locating the full-qualified paths in a centralized, easily-modifiable location within the source code, and having the code refer to these paths.
|
|
Implementation
|
Strategy: Attack Surface Reduction
Remove or restrict all environment settings before invoking other programs. This includes the PATH environment variable, LD_LIBRARY_PATH, and other settings that identify the location of code libraries, and any application-specific search paths.
|
|
Implementation
|
Check your search path before use and remove any elements that are likely to be unsafe, such as the current working directory or a temporary files directory. Since this is a denylist approach, it might not be a complete solution.
|
|
Implementation
|
Use other functions that require explicit paths. Making use of any of the other readily available functions that require explicit paths is a safe way to avoid this problem. For example, system() in C does not require a full path since the shell can take care of finding the program using the PATH environment variable, while execl() and execv() require a full path.
|
👁 Section Help
This table shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition,
relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user
may want to explore.
👁 +
Relevant to the view "Research Concepts" (View-1000)
| Nature |
Type |
ID |
Name |
| ChildOf |
👁 Class
Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource.
|
668
|
Exposure of Resource to Wrong Sphere
|
| PeerOf |
👁 Base
Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource.
|
426
|
Untrusted Search Path
|
👁 +
Relevant to the view "Software Development" (View-699)
| Nature |
Type |
ID |
Name |
| MemberOf |
👁 Category
Category - a CWE entry that contains a set of other entries that share a common characteristic.
|
1219
|
File Handling Issues
|
👁 +
Relevant to the view "Weaknesses for Simplified Mapping of Published Vulnerabilities" (View-1003)
| Nature |
Type |
ID |
Name |
| ChildOf |
👁 Class
Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource.
|
668
|
Exposure of Resource to Wrong Sphere
|
👁 +
Modes
Of Introduction
👁 Section Help The different Modes of Introduction provide information
about how and when this
weakness may be introduced. The Phase identifies a point in the life cycle at which
introduction
may occur, while the Note provides a typical scenario related to introduction during the
given
phase.
| Phase |
Note |
| Implementation |
👁 +
Demonstrative Examples
Example 1
The following code is from a web application that allows users access to an interface through which they can update their password on the system. In this environment, user passwords can be managed using the Network Information System (NIS), which is commonly used on UNIX systems. When performing NIS updates, part of the process for updating passwords is to run a make command in the /var/yp directory. Performing NIS updates requires extra privileges.
(bad code)
Example Language: Java
... System.Runtime.getRuntime().exec("make"); ...
The problem here is that the program does not specify an absolute path for make and does not clean its environment prior to executing the call to Runtime.exec(). If an attacker can modify the $PATH variable to point to a malicious binary called make and cause the program to be executed in their environment, then the malicious binary will be loaded instead of the one intended. Because of the nature of the application, it runs with the privileges necessary to perform system operations, which means the attacker's make will now be run with these privileges, possibly giving the attacker complete control of the system.
Example 2
In versions of Go prior to v1.19, the LookPath function would follow the conventions of the runtime OS and look for a program in the directiories listed in the current path [REF-1325].
Therefore, Go would prioritize searching the current directory when the provided command name does not contain a directory separator and continued to search for programs even when the specified program name is empty.
Consider the following where an application executes a git command to run on the system.
(bad code)
Example Language: Go
func ExecuteGitCommand(name string, arg []string) error {
c := exec.Command(name, arg...)
var err error
c.Path, err = exec.LookPath(name)
if err != nil {
return err
}
}
An attacker could create a malicious repository with a file named ..exe and another file named git.exe. If git.exe is not found in the system PATH, then ..exe would execute [REF-1326].
Example 3
In February 2021 [REF-1169], a researcher was able to demonstrate the ability to breach major technology companies by using "dependency confusion" where the companies would download and execute untrusted packages.
The researcher discovered the names of some internal, private packages by looking at dependency lists in public source code, such as package.json. The researcher then created new, untrusted packages with the same name as the internal packages, then uploaded them to package hosting services. These services included the npm registry for Node, PyPi for Python, and RubyGems. In affected companies, their dependency resolution would search the public hosting services first before consulting their internal service, causing the untrusted packages to be automatically downloaded and executed.
👁 + Selected Observed
Examples
Note: this is a curated list of examples for users to understand the variety of ways in which this
weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference |
Description |
|
|
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.
|
|
|
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
|
|
|
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
|
|
|
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
|
|
|
SSL package searches under "C:/usr/local" for configuration files and other critical data, but C:/usr/local might be world-writable.
|
|
|
"DLL hijacking" issue in document editor.
|
|
|
"DLL hijacking" issue in encryption software.
|
|
|
"DLL hijacking" issue in library used by multiple media players.
|
|
|
"DLL hijacking" issue in illustration program.
|
|
|
"DLL hijacking" issue in address book.
|
|
|
"DLL hijacking" issue in network monitoring software.
|
|
|
"DLL hijacking" issue in web browser.
|
|
|
"DLL hijacking" issue in music player/organizer.
|
|
|
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.
|
|
|
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.
|
|
|
Software uses a search path that includes the current working directory (.), which allows local users to gain privileges via malicious programs.
|
|
|
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.
|
|
|
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.
|
|
|
Database trusts the PATH environment variable to find and execute programs, which allows local users to modify the PATH to point to malicious programs.
|
|
|
Database uses an environment variable to find and execute a program, which allows local users to execute arbitrary programs by changing the environment variable.
|
|
|
Server uses relative paths to find system files that will run in-process, which allows local users to gain privileges via a malicious file.
|
|
|
Product allows local users to execute arbitrary code by setting an environment variable to reference a malicious program.
|
|
|
Product includes the current directory in root's PATH variable.
|
|
|
Error during packaging causes product to include a hard-coded, non-standard directory in search path.
|
|
|
Product searches current working directory for configuration file.
|
|
|
Product searches current working directory for configuration file.
|
|
|
Product executable other program from current working directory.
|
|
|
Untrusted path.
|
|
|
Modification of trusted environment variable leads to untrusted path vulnerability.
|
|
|
Product searches /tmp for modules before other paths.
|
👁 +
Weakness Ordinalities
| Ordinality |
Description |
|
Primary
|
(where the weakness exists independent of other weaknesses)
|
| Method |
Details |
|
Automated Static Analysis
|
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
|
- Program Invocation
- Code Libraries
👁 Section Help This MemberOf Relationships table shows additional CWE Categories and Views that
reference this weakness as a member. This information is often useful in understanding where a
weakness fits within the context of external information sources.
| Nature |
Type |
ID |
Name |
| MemberOf |
👁 Category Category - a CWE entry that contains a set of other entries that share a common characteristic. |
991
|
SFP Secondary Cluster: Tainted Input to Environment
|
| MemberOf |
👁 Category Category - a CWE entry that contains a set of other entries that share a common characteristic. |
1403
|
Comprehensive Categorization: Exposed Resource
|
| MemberOf |
👁 Category Category - a CWE entry that contains a set of other entries that share a common characteristic. |
1443
|
OWASP Top Ten 2025 Category A08:2025 - Software or Data Integrity Failures
|
👁 +
Vulnerability Mapping Notes
|
Usage
|
ALLOWED-WITH-REVIEW
(this CWE ID could be used to map to real-world vulnerabilities in limited situations requiring careful review)
|
| Reasons |
Frequent Misinterpretation,
Abstraction,
Other
|
|
Rationale
|
This CWE entry is often confused with another closely-related entry about search paths.
|
|
Comments
|
CWE-426 and CWE-427 are often misused because they both mention search paths, although CWE-426 is focused on attacker control of the search path itself, while CWE-427 applies when the attacker cannot modify the search path but can write to one of the locations specified in the search path. Also, this entry is classified in a part of CWE's hierarchy that does not have sufficiently low-level coverage, which might reflect a lack of classification-oriented weakness research in the software security community. Conduct careful root cause analysis to determine the original mistake that led to this weakness. If closer analysis reveals that this weakness is appropriate, then this might be the best available CWE to use for mapping. If no other option is available, then it is acceptable to map to this CWE.
|
Relationship
Unlike untrusted search path ( CWE-426), which inherently involves control over the definition of a control sphere (i.e., modification of a search path), this entry concerns a fixed control sphere in which some part of the sphere may be under attacker control (i.e., the search path cannot be modified by an attacker, but one element of the path can be under attacker control).
Theoretical
This weakness is not a clean fit under CWE-668 or CWE-610, which suggests that the control sphere model might need enhancement or clarification.
| Mapped Taxonomy Name |
Node ID |
Fit |
Mapped Node Name |
| PLOVER |
Uncontrolled Search Path Element |
👁 + Submissions |
| Submission Date |
Submitter |
Organization |
2006-07-19
(CWE Draft 3, 2006-07-19)
|
PLOVER |
👁 + Contributions |
| Contribution Date |
Contributor |
Organization |
|
2022-05-24
|
Anonymous External Contributor |
|
provided observed examples and descriptions for Windows drive root
|
👁 + Modifications |
| Modification Date |
Modifier |
Organization |
2026-04-30
(CWE 4.20, 2026-04-30)
|
CWE Content Team |
MITRE |
|
updated References
|
2025-12-11
(CWE 4.19, 2025-12-11)
|
CWE Content Team |
MITRE |
|
updated Applicable_Platforms, Relationships, Weakness_Ordinalities
|
2025-09-09
(CWE 4.18, 2025-09-09)
|
CWE Content Team |
MITRE |
|
updated Affected_Resources, Functional_Areas, References
|
2025-04-03
(CWE 4.17, 2025-04-03)
|
CWE Content Team |
MITRE |
|
updated Mapping_Notes
|
2023-10-26
(CWE 4.13, 2023-10-26)
|
CWE Content Team |
MITRE |
|
updated Observed_Examples
|
2023-06-29
(CWE 4.12, 2023-06-29)
|
CWE Content Team |
MITRE |
|
updated Mapping_Notes
|
2023-04-27
(CWE 4.11, 2023-04-27)
|
CWE Content Team |
MITRE |
|
updated Demonstrative_Examples, Detection_Factors, References, Relationships
|
2023-01-31
(CWE 4.10, 2023-01-31)
|
CWE Content Team |
MITRE |
|
updated Description, Observed_Examples, References
|
2022-10-13
(CWE 4.9, 2022-10-13)
|
CWE Content Team |
MITRE |
|
updated Observed_Examples
|
2022-04-28
(CWE 4.7, 2022-04-28)
|
CWE Content Team |
MITRE |
|
updated Demonstrative_Examples
|
2021-03-15
(CWE 4.4, 2021-03-15)
|
CWE Content Team |
MITRE |
|
updated Alternate_Terms, Description, Maintenance_Notes, References, Theoretical_Notes
|
2020-06-25
(CWE 4.1, 2020-06-25)
|
CWE Content Team |
MITRE |
|
updated Potential_Mitigations
|
2020-02-24
(CWE 4.0, 2020-02-24)
|
CWE Content Team |
MITRE |
|
updated Relationships
|
2019-06-20
(CWE 3.3, 2019-06-20)
|
CWE Content Team |
MITRE |
|
updated Related_Attack_Patterns, Relationships
|
2019-01-03
(CWE 3.2, 2019-01-03)
|
CWE Content Team |
MITRE |
|
updated Related_Attack_Patterns
|
2015-12-07
(CWE 2.9, 2015-12-07)
|
CWE Content Team |
MITRE |
|
updated Relationships
|
2014-07-30
(CWE 2.8, 2014-07-31)
|
CWE Content Team |
MITRE |
|
updated Relationships
|
2014-02-18
(CWE 2.6, 2014-02-19)
|
CWE Content Team |
MITRE |
|
updated Demonstrative_Examples, Observed_Examples, Potential_Mitigations
|
2012-05-11
(CWE 2.2, 2012-05-15)
|
CWE Content Team |
MITRE |
|
updated Observed_Examples, Related_Attack_Patterns, Relationships
|
2011-06-01
(CWE 1.13, 2011-06-01)
|
CWE Content Team |
MITRE |
|
updated Common_Consequences
|
2011-03-29
(CWE 1.12, 2011-03-30)
|
CWE Content Team |
MITRE |
|
updated Potential_Mitigations
|
2010-09-27
(CWE 1.10, 2010-09-27)
|
CWE Content Team |
MITRE |
|
updated Alternate_Terms, Applicable_Platforms, Description, Maintenance_Notes, Observed_Examples, References, Relationship_Notes, Relationships
|
2009-07-27
(CWE 1.5, 2009-07-27)
|
CWE Content Team |
MITRE |
|
updated Description, Maintenance_Notes, Observed_Examples, Other_Notes, Potential_Mitigations, Relationships
|
2008-09-08
(CWE 1.0, 2008-09-09)
|
CWE Content Team |
MITRE |
|
updated Relationships, Observed_Example, Other_Notes, Taxonomy_Mappings
|
2008-07-01
(CWE 1.0, 2008-09-09)
|
Eric Dalci |
Cigital |
|
updated Potential_Mitigations, Time_of_Introduction
|
More information is available — Please edit the custom filter or select a different filter.
|