Writable Executables or Directories in System Paths

Executables, or directories that privileged processes search for programs and DLLs, such as those in the system PATH, can be modified by unprivileged users.

SeverityHigh
CVSS 3.17 CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H Open in the calculator
CVSS 4.07.3 CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator
CWECWE-427: Uncontrolled Search Path Element
OWASP Top 10A08:2025 Software or Data Integrity Failures
MITRE ATT&CKT1574.007 Path Interception by PATH Environment Variable, T1574.001 DLL
CategoryBroken Access Control

Description

Standard users can write to executables, or to directories, from which privileged processes load code. The common cases are a directory in the system-wide PATH environment variable that Users or Authenticated Users can write to, often added by development tools or runtimes installed outside C:\Program Files; program or script files run by services, scheduled tasks or other users that any user can modify; and application directories that a privileged process searches for DLLs. The same weakness exists on Linux and other Unix-like systems where a directory in the PATH used by root, or by scripts root runs, is writable by other users, or where root runs programs which other users are able to change.

When a privileged process starts a program or loads a DLL by name rather than by full path, Windows searches a sequence of directories, and the system PATH directories come last in the standard DLL search order. A file planted in a writable directory on that route can be loaded in place of a missing or legitimate component. A local user who plants or modifies a program or DLL that a privileged process later runs gains that process's privileges, and when the process belongs to a service or a root job, this gives full control of the host; where the modified file is run by other users instead, the attacker gains their privileges and access. Exploitation depends on a privileged process loading from the writable location, which may only happen at a service restart or reboot, and on the attacker knowing which file name it looks for.

The weakness is identified by checking the permissions of each PATH directory and of the files that privileged processes run, for example with icacls, Sysinternals accesschk or find with its -writable test, and local enumeration tools such as WinPEAS, PowerUp and linPEAS report it.

Remediation

  • Remove write, modify and full control permissions for non-administrative users and groups from every directory in the system PATH, and from executables, scripts and DLLs run by services, scheduled tasks and administrators. On Linux, make such files and directories owned by root and not writable by group or other users.
  • Remove directories from the system PATH that do not need to be there, and install software into protected locations such as C:\Program Files or root-owned system directories.
  • Where a directory must stay writable for an application, take it out of the system PATH and run the application by its full path.
  • Ask vendors to load components by full path and to use the restricted DLL search options the platform provides.

For example, to stop a tools directory inheriting write access for all authenticated users while keeping read and execute access:

icacls "C:\Tools" /inheritance:d icacls "C:\Tools" /remove:g "Authenticated Users" icacls "C:\Tools" /grant:r "Users:(OI)(CI)RX"

As an interim measure, monitor the affected directories for new executable and DLL files. Confirm the fix by repeating the permission checks as a standard user.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Windows and Linux Hosts Findings

Every Windows and Linux Hosts finding