Understanding unquoted service path vulnerability¶
An unquoted service path vulnerability occurs when a service executable path contains folder names with spaces but lacks quotation marks around the entire path, The issue arises from how Windows interprets service paths. If the path is properly quoted or contains no spaces, the system runs the intended executable without issue. But if it is unquoted and includes spaces, Windows may attempt to execute unintended binaries along the path.
Breaking it down with an example¶
If an attacker has write permissions in any of the directories before the actual executable, they can create a malicious binary named after that directory. When the service starts, Windows may execute the attacker binary instead of the intended service executable, leading to privilege escalation, For example, given the intended executable path: C:\Program Files\Common Files\Service Folder\service.exe
-
First, it checks for
C:\Program.exe
-
If not found, it checks for
Note: If this file does not exist, Windows continues.C:\Program Files\Common.exe
-
Next, it checks for
Note: If this file does not exist, Windows continues.C:\Program Files\Common Files\Service.exe
-
Finally, it executes the intended binary: