Exploit an unquoted service path with a writable earlier prefix
Needs: An earlier executable prefix is absent and creatable, service identity is higher and a start/restart trigger exists
PowerShell commands
# Baseline
Get-CimInstance Win32_Service |
Where-Object { $_.PathName -match '\s' -and $_.PathName -notmatch '^\s*"' } |
Select-Object Name,StartName,State,StartMode,PathName
Windows commands
REM Baseline
icacls C:\
icacls "C:\Program Files"
icacls "C:\Program Files\Vendor App"
sc.exe qc SERVICE
Confirmed only if: path contains spaces and is unquoted; an earlier attempted executable such as
C:\Program.exeorC:\Program Files\Vendor.exeis absent and creatable; service runs higher; trigger exists. A listed unquoted path alone is a false positive.
Verify → Confirm the earlier prefix is actually selected after the trigger and verify its resulting token.
If it fails → A quoted path, existing protected earlier file, unwritable directory or absent trigger defeats the chain. More detail ↓
Explanation & examples
Exploit an unquoted service path with a writable earlier prefix
- USE WHEN
- A service command line contains unquoted spaces
- STARTING ACCESS
- A verified Windows foothold with a known token, integrity level and groups
- RESULT
- Verified execution of the earlier executable candidate
Recognize the clue
List service command lines and accounts, then inspect every earlier executable prefix in the actual unquoted path.
Get-CimInstance Win32_Service | Select-Object Name,StartName,State,PathName
StartName: LocalSystem
PathName: C:\Program Files\Vendor App\service.exe -d
Quotes around executable: absentMeans: Spaces plus absent executable quoting create candidate earlier prefixes; writable placement and trigger remain unproved.
Confirm: Read the unquoted service command with sc qc. Check each earlier executable prefix for write/create access with icacls; confirm the service account and restart trigger. Spaces alone do not make the path exploitable.
- After validation
- A usable earlier prefix is selected at a privileged trigger: choose this parsing route.
- Ruled out in this context
- All earlier prefixes are protected, already occupied or the executable is correctly quoted: reject it.
- Still inconclusive
- A scanner flag without prefix/trigger checks leaves exploitability unknown.
Troubleshooting: A quoted path, existing protected earlier file, unwritable directory or absent trigger defeats the chain.
Additional prerequisite checks
Get-CimInstance Win32_Service | Select-Object Name,StartName,PathName
For C:\Program Files\Vendor App\service.exe -d, check every attempted prefix:
Confirmed only if: path contains spaces and is unquoted; an earlier attempted executable such as
C:\Program.exeorC:\Program Files\Vendor.exeis absent and creatable; service runs higher; trigger exists. A listed unquoted path alone is a false positive.
Why it works
Windows executable-path parsing may try earlier space-separated prefixes. Spaces alone do not create control; each attempted prefix and its creation rights matter.
Worked example · hypothetical
Observation: a service uses an unquoted Program Files path. Test: inspect each attempted prefix and its directory ACL. Illustrative output: all earlier prefixes are protected. Interpretation: this is not an exploitable path under the current identity.
New identity, privilege, host or route? Re-enumerate → All topic tasks →