Skip to main content

Overview

The Modifiable Service Binaries check identifies Windows services where the service executable or DLL has weak file permissions. If a non-privileged user can modify a service binary, they can replace it with malicious code that will execute with the service’s privileges (often SYSTEM).

How It Works

SharpUp enumerates all services via WMI and checks if their binary paths are writable:
  1. Query all services using Win32_Service
  2. Extract the executable path from PathName
  3. Check if current user can modify the binary file
  4. Report vulnerable services with their state and startup mode

Technical Details

The check uses regex to extract the executable path from service PathName, which may include arguments.

Example Output

Interpretation:
  • VulnSvc is currently running and starts automatically
  • You can modify C:\Program Files\VulnApp\service.exe
  • Restarting the service will execute your modified binary with service privileges

Exploitation

Method 1: Direct Binary Replacement

Method 2: Add Local Admin

Method 3: Service Binary as Backdoor

Remediation

1

Identify Vulnerable Binaries

2

Fix Binary Permissions

3

Fix Parent Directory Permissions

4

Bulk Remediation Script

5

Verify Fix

For service binaries:
  • SYSTEM: Full Control
  • Administrators: Full Control
  • Users: Read & Execute only
  • TrustedInstaller: Full Control (for system services)
Inheritance: Disabled (permissions explicitly set)

Detection

Defensive Monitoring

Detection Strategies

  • Baseline all service binaries with cryptographic hashes
  • Alert on any modifications to service executables
  • Monitor file creation in service directories
  • Track file replacement activities

Real-World Scenarios

Context: Legacy application installed to C:\Apps with weak permissions. Service runs as LocalSystem.Attack Path:
  1. Standard user identifies modifiable service binary
  2. Replaces binary with malicious version
  3. Waits for service restart or triggers it
  4. Malicious code runs as SYSTEM
  5. Complete system compromise
Prevention:
  • Install applications to Program Files
  • Use proper installer that sets correct permissions
  • Regular permission audits
Context: Third-party monitoring agent has automatic updates that leave temporary files with weak permissions.Impact:
  • Attacker replaces agent binary during update
  • Agent runs on schedule with SYSTEM privileges
  • Lateral movement across all systems with agent installed
Solution:
  • Work with vendor to fix installer
  • Monitor agent directory for unauthorized changes
  • Use application whitelisting
Context: IT team created custom service for automation, installed to C:\Scripts with Users having modify rights.Risk:
  • Any user can replace service binary
  • Service runs hourly as SYSTEM
  • Easy privilege escalation vector
Fix:
  • Move to Program Files\CustomService
  • Set proper permissions (Users read-only)
  • Review service account permissions

Prevention Best Practices

Install to Program Files

Always install services and applications to protected system directories.

Use Proper Installers

Use Windows Installer (MSI) which sets correct permissions by default.

Principle of Least Privilege

Run services with minimum required privileges, not SYSTEM when possible.

Regular Audits

Periodically audit service binary permissions across all systems.

Automated Audit Script

Modifiable Services

Services with weak DACL permissions

Modifiable Service Registry Keys

Service registry keys with weak permissions

Unquoted Service Path

Services with unquoted paths containing spaces

Remediation Guide

Comprehensive remediation guidance

References

MITRE ATT&CK

T1574.010 - Hijack Execution Flow: Services File Permissions Weakness

Microsoft Security

Windows Security Policy Settings