This might allow attackers to execute their own programs, access unauthorized data files, or modify configuration in unexpected ways. If the product uses a search path to locate critical resources such as programs, then an attacker could modify that search path to point to a malicious program, which the targeted product would then execute. The problem extends to any type of critical resource that the product trusts.
Some of the most common variants of untrusted search path are:
| Impact | Details |
|---|---|
|
Gain Privileges or Assume Identity; Execute Unauthorized Code or Commands |
Scope: Integrity, Confidentiality, Availability, Access Control
There is the potential for arbitrary code execution with privileges of the vulnerable program.
|
|
DoS: Crash, Exit, or Restart |
Scope: Availability
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.
|
|
Read Files or Directories |
Scope: Confidentiality
The program could send the output of unauthorized files to the attacker.
|
| Phase(s) | Mitigation |
|---|---|
|
Architecture and Design; Implementation |
Strategy: Attack Surface Reduction |
|
Implementation |
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 |
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.
|
|
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 it, while execl() and execv() require a full path.
|
| 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. | 642 | External Control of Critical State Data |
| 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. | 673 | External Influence of Sphere Definition |
| 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. | 427 | Uncontrolled Search Path Element |
| 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. | 428 | Unquoted Search Path or Element |
| 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 |
| 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 |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | Category Category - a CWE entry that contains a set of other entries that share a common characteristic. | 1011 | Authorize Actors |
| Phase | Note |
|---|---|
| Implementation |
Class: Not Language-Specific (Undetermined Prevalence)
Class: Not OS-Specific (Undetermined Prevalence)
Example 1
This program is intended to execute a command that lists the contents of a restricted directory, then performs other actions. Assume that it runs with setuid privileges in order to bypass the permissions check by the operating system.
This code may look harmless at first, since both the directory and the command are set to fixed values that the attacker can't control. The attacker can only see the contents for DIR, which is the intended program behavior. Finally, the programmer is also careful to limit the code that executes with raised privileges.
However, because the program does not modify the PATH environment variable, the following attack would work:
Example 2
The following code from a system utility uses the system property APPHOME to determine the directory in which it is installed and then executes an initialization script based on a relative path from the specified directory.
The code above allows an attacker to execute arbitrary commands with the elevated privilege of the application by modifying the system property APPHOME to point to a different path containing a malicious version of INITCMD. Because the program does not validate the value read from the environment, if an attacker can control the value of the system property APPHOME, then they can fool the application into running malicious code and take control of the system.
Example 3
This code prints all of the running processes belonging to the current user.
If invoked by an unauthorized web user, it is providing a web page of potentially sensitive information on the underlying system, such as command-line arguments (CWE-497). This program is also potentially vulnerable to a PATH based attack (CWE-426), as an attacker may be able to create malicious versions of the ps or grep commands. While the program does not explicitly raise privileges to run the system commands, the PHP interpreter may by default be running with higher privileges than users.
Example 4
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.
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.
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 |
|---|---|
|
Application relies on its PATH environment variable to find and execute program.
|
|
|
Database application relies on its PATH environment variable to find and execute program.
|
|
|
Chain: untrusted search path enabling resultant format string by loading malicious internationalization messages.
|
|
|
Untrusted search path using malicious .EXE in Windows environment.
|
|
|
setuid program allows compromise using path that finds and loads a malicious library.
|
|
|
Server allows client to specify the search path, which can be modified to point to a program that the client has uploaded.
|
| Method | Details |
|---|---|
|
Black Box |
Use monitoring tools that examine the software's process as it interacts with the operating system and the network. This technique is useful in cases when source code is unavailable, if the software was not developed by you, or if you want to verify that the build phase did not introduce any new weaknesses. Examples include debuggers that directly attach to the running process; system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and sniffers and protocol analyzers that monitor network traffic. Attach the monitor to the process and look for library functions and system calls that suggest when a search path is being used. One pattern is when the program performs multiple accesses of the same file but in different directories, with repeated failures until the proper filename is found. Library calls such as getenv() or their equivalent can be checked to see if any path-related variables are being accessed. |
|
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 |
|
Manual Analysis |
Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 744 | CERT C Secure Coding Standard (2008) Chapter 11 - Environment (ENV) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 752 | 2009 Top 25 - Risky Resource Management |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 808 | 2010 Top 25 - Weaknesses On the Cusp |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 878 | CERT C++ Secure Coding Section 10 - Environment (ENV) |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1200 | Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1354 | OWASP Top Ten 2021 Category A08:2021 - Software and Data Integrity Failures |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1403 | Comprehensive Categorization: Exposed Resource |
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.| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| PLOVER | Untrusted Search Path | ||
| CLASP | Relative path library search | ||
| CERT C Secure Coding | ENV03-C | Sanitize the environment when invoking external programs |
| CAPEC-ID | Attack Pattern Name |
|---|---|
| CAPEC-38 | Leveraging/Manipulating Configuration File Search Paths |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
PLOVER | |
| Modifications | ||
| Modification Date | Modifier | Organization |
|
2025年04月03日
(CWE 4.17, 2025年04月03日) |
CWE Content Team | MITRE |
| updated Mapping_Notes | ||
|
2024年07月16日
(CWE 4.15, 2024年07月16日) |
CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Detection_Factors, Relationships, Time_of_Introduction | ||
| 2023年01月31日 | CWE Content Team | MITRE |
| updated Description | ||
| 2022年04月28日 | CWE Content Team | MITRE |
| updated Research_Gaps | ||
| 2021年10月28日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2020年02月24日 | CWE Content Team | MITRE |
| updated References, Relationships | ||
| 2019年09月19日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2019年06月20日 | CWE Content Team | MITRE |
| updated Related_Attack_Patterns, Relationships | ||
| 2019年01月03日 | CWE Content Team | MITRE |
| updated Related_Attack_Patterns | ||
| 2018年03月27日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, References, Relationships, Type | ||
| 2017年11月08日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Modes_of_Introduction, References, Relationships, Taxonomy_Mappings | ||
| 2015年12月07日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2014年02月18日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Detection_Factors, Potential_Mitigations | ||
| 2012年05月11日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, References | ||
| 2011年09月13日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2011年06月01日 | CWE Content Team | MITRE |
| updated Common_Consequences | ||
| 2011年03月29日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples | ||
| 2010年09月27日 | CWE Content Team | MITRE |
| updated Description, Relationships | ||
| 2010年06月21日 | CWE Content Team | MITRE |
| updated Detection_Factors, Potential_Mitigations | ||
| 2010年04月05日 | CWE Content Team | MITRE |
| updated Applicable_Platforms | ||
| 2010年02月16日 | CWE Content Team | MITRE |
| updated References, Relationships | ||
| 2009年12月28日 | CWE Content Team | MITRE |
| updated References | ||
| 2009年03月10日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Potential_Mitigations | ||
| 2009年01月12日 | CWE Content Team | MITRE |
| updated Applicable_Platforms, Common_Consequences, Demonstrative_Examples, Description, Observed_Examples, Potential_Mitigations, Relationships, Time_of_Introduction | ||
| 2008年11月24日 | CWE Content Team | MITRE |
| updated Relationships, Taxonomy_Mappings | ||
| 2008年09月08日 | CWE Content Team | MITRE |
| updated Common_Consequences, Relationships, Taxonomy_Mappings | ||
| 2008年07月01日 | Eric Dalci | Cigital |
| updated Time_of_Introduction | ||
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.