EoP - Unquoted Service Paths
Unquoted Service Path Vulnerabilities: Identification and Exploitation
Key Concepts
Service Path: The location of the executable file that a service runs.
Unquoted Path: A service path containing spaces but lacking quotation marks (e.g.,
C:\Program Files\My Service\service.exe
instead of"C:\Program Files\My Service\service.exe"
).Privilege Escalation: Gaining elevated access to protected resources.
Identifying Unquoted Service Paths
1. Using WMIC
The Windows Management Instrumentation Command-line (WMIC) can enumerate services with unquoted paths:
2. Using PowerShell
A PowerShell script provides a more automated method to identify unquoted paths:
3. Using PowerUp
PowerUp, a PowerShell script, identifies privilege escalation vectors, including unquoted paths:
Example Output:
Exploiting Unquoted Service Paths
Manual Exploitation Steps
Identify the Vulnerable Service: Use the methods above to detect vulnerable services.
Create a Malicious Executable: Generate a payload (e.g., a reverse shell) and place it in the same directory as the legitimate executable.
Stop the Service:
Replace the Executable: Replace the legitimate executable with the malicious payload.
Restart the Service:
Gain Access: When the service restarts, it will execute the malicious payload with elevated privileges.
Example of Automatic Exploitation with PowerUp
Use PowerUp’s Invoke-ServiceAbuse
to automate exploitation:
Replace [SERVICE_NAME]
with the vulnerable service name and specify the payload command.
Example of Exploitation Behavior
For a service with the path:
Windows will attempt to execute:
C:\Program.exe
C:\Program Files.exe
C:\Program Files\Something\legit.exe
If a malicious Program.exe
or Program Files.exe
is placed in these locations, it will execute with elevated privileges.
Exploiting with Metasploit
Metasploit provides an exploit module for unquoted service paths:
This automates the process of finding and exploiting unquoted paths.
Mitigation Strategies
1. Quote Service Paths
Always enclose service paths in quotes, particularly if they contain spaces:
2. Regular Audits
Periodically audit service configurations to detect and remediate unquoted paths.
3. Use Least Privilege
Run services with the least privilege required, avoiding LocalSystem
unless absolutely necessary.
4. Implement Security Policies
Adopt strict policies to manage service configurations.
5. Monitoring and Alerts
Set up monitoring to detect unauthorized changes to service paths or configurations.
Additional Resources
OWASP Top 10 Security Risks
Last updated