Unquoted Service Path Privilege Escalation
When a Windows service binary path contains spaces and is not enclosed in quotes, the Windows service control manager tries multiple path interpretations. For a path like C:\Program Files\Some App\service.exe, Windows tries C:\Program.exe, then C:\Program Files\Some.exe, then C:\Program Files\Some App\service.exe. If you can write to any intermediate directory, planting a binary at an earlier resolution point gives you SYSTEM code execution.
Prerequisites Check
You need write access to at least one directory in the service path before the actual binary. Check available drives and writable directories:
Step 1 — Find Vulnerable Services
Using PowerUp:
Manual enumeration — find all unquoted paths with spaces:
Or check all services:
PowerShell alternative:
Step 2 — Understand the Resolution Order
For a path like:
Windows tries in order:
C:\Program.exeC:\Program Files\Vulnerable.exeC:\Program Files\Vulnerable App\service.exe
You need write access to C:\ to plant Program.exe, or to C:\Program Files\ to plant Vulnerable.exe.
Check write access to each intermediate directory:
Look for (W), (M), or (F) for your user, BUILTIN\Users, or Everyone.
Using accesschk:
Step 3 — Determine the Binary Name
The binary name is everything before the first space in each path segment. For:
The candidate binaries are:
C:\Program.exeC:\Program Files\Vulnerable.exe
Use whichever directory you can write to.
Step 4 — Create the Malicious Binary
Transfer to target and place in the writable directory:
Step 5 — Restart the Service
Or reboot if restart is not available:
Step 6 — Verify
Why C:\Program Files Is Often Writable
On misconfigured systems, BUILTIN\Users has write access to custom application directories under Program Files. Standard Microsoft applications are protected, but third-party installers frequently set weak permissions on their installation directories.
Always check custom application paths specifically — C:\Program Files\ThirdPartyApp\ is more likely writable than C:\Program Files\ itself.
Cleanup
References
-
Windows Service Binary Pathdocs.microsoft.com/en-us/windows/win32/services/service-binary (opens in new tab)
Microsoft Docs Path resolution behavior for service executables with spaces.
-
Get-ServiceUnquoted Automated unquoted path detection with write permission validation.
Was this helpful?
Your feedback helps improve this page.