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:- Query all services using
Win32_Service - Extract the executable path from
PathName - Check if current user can modify the binary file
- Report vulnerable services with their state and startup mode
Technical Details
PathName, which may include arguments.
Example Output
- 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
Recommended Permissions
For service binaries:- SYSTEM: Full Control
- Administrators: Full Control
- Users: Read & Execute only
- TrustedInstaller: Full Control (for system services)
Detection
Defensive Monitoring
Detection Strategies
- File Integrity Monitoring
- Permission Monitoring
- Service Monitoring
- Process Monitoring
- 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
Scenario 1: Legacy Application Service
Scenario 1: Legacy Application Service
Context: Legacy application installed to
C:\Apps with weak permissions. Service runs as LocalSystem.Attack Path:- Standard user identifies modifiable service binary
- Replaces binary with malicious version
- Waits for service restart or triggers it
- Malicious code runs as SYSTEM
- Complete system compromise
- Install applications to Program Files
- Use proper installer that sets correct permissions
- Regular permission audits
Scenario 2: Third-Party Monitoring Agent
Scenario 2: Third-Party Monitoring Agent
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
- Work with vendor to fix installer
- Monitor agent directory for unauthorized changes
- Use application whitelisting
Scenario 3: Custom IT Service
Scenario 3: Custom IT Service
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
- 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
Related Checks
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