CWE•Base•Draft•20 recent CVEs
CWE-427Uncontrolled Search Path Element
Description
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.
[object Object]
Common consequences
- Confidentiality,Integrity,Availability→Execute Unauthorized Code or Commands
Potential mitigations
- Architecture and Design,ImplementationHard-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.
- ImplementationWhen 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 ref
- ImplementationRemove 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.
- ImplementationCheck 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.
- ImplementationUse 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.
Related CWEs
Recent CVEs classified under this CWE
CVE-2026-483888.62026-07-28CVE-2026-81647.32026-07-28CVE-2026-165197.32026-07-24CVE-2026-217706.52026-07-17CVE-2026-56748.82026-07-16CVE-2026-429367.82026-07-15CVE-2026-482727.82026-07-14CVE-2026-04878.42026-07-14CVE-2026-483648.22026-07-13CVE-2026-483638.22026-07-13CVE-2026-155157.02026-07-13CVE-2026-572398.22026-07-08CVE-2026-564377.82026-07-08CVE-2026-389727.82026-07-02CVE-2026-546727.82026-06-30CVE-2025-131624.42026-06-23CVE-2026-542328.82026-06-22CVE-2026-492418.82026-06-22CVE-2026-66452026-06-22CVE-2026-119582026-06-18