Skip to content

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

  1. First, it checks for C:\Program.exe

    C:\Program.exe
    

  2. If not found, it checks for C:\Program Files\Common.exe

    C:\Program Files\Common.exe
    
    Note: If this file does not exist, Windows continues.

  3. Next, it checks for C:\Program Files\Common Files\Service.exe

    C:\Program Files\Common Files\Service.exe
    
    Note: If this file does not exist, Windows continues.

  4. Finally, it executes the intended binary:

    C:\Program Files\Common Files\Service Folder\service.exe