**Walking Along the PATHS of the Administrator**
A Windows service was installed with an unquoted executable path containing spaces, so Windows would try to run executables from parent directories first. An attacker with local user access could place a malicious executable in a writable parent directory and gain SYSTEM privileges when the service starts.
Published on systemweakness.com
In this blog, we’ll discuss how service paths can be abused to escalate privileges in Windows systems. As usual, we’ll look at the theoretical aspects of this abuse, and then we’ll have a practical walkthrough of the abuse.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the service executable path was not enclosed in quotes, so the Windows CreateProcess function interpreted the space-separated path ambiguously and searched parent directories first.
Impact
An attacker with local user access could escalate to SYSTEM privileges if a writable parent directory exists and the service restarts.
What the attacker needed
Local user access on Windows; unquoted service path with spaces; writable parent directory; service runs as SYSTEM or Administrator
The fix
The service executable path should be enclosed in quotes, and write access to system directories should be restricted.
How it was found
- Create a service with an unquoted executable path containing spaces.
- Create the directories referenced in the path and grant write access to a low-privileged user.
- Enumerate running services and identify one with an unquoted path.
- Check the service account and verify write access to a parent directory.
- Generate a malicious executable and place it in the writable directory.
- Restart the service or reboot the system to trigger execution and obtain elevated privileges.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When Windows starts a service, it reads the path to the program. If that path has spaces and is not wrapped in quotes, Windows may try to run a program from a folder higher up first. If a normal user can write to that folder, they can put their own program there and it will run with the service's high privileges.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.