MSDN Community

Articles

Securing Windows Services

Introduction

Windows services run in the background and often have elevated privileges. Properly securing them is essential to protect the operating system and data from malicious attacks.

Threat Model

Common threats include:

Service Hardening

Apply the following hardening steps:

  1. Set the Start Type to Manual or Disabled for services that are not required.
  2. Limit the Service SID to only the privileges it truly needs.
  3. Configure the Failure Actions to restart only when safe.

Code Signing

Always sign your service binaries with a trusted certificate. This allows Windows to verify integrity at load time.

signtool sign /fd SHA256 /a /tr http://timestamp.digicert.com /td SHA256 MyService.exe

Access Control

Define precise ACLs on the service executable and on its registry key (HKLM\System\CurrentControlSet\Services\MyService).

# Example: Grant Local Service read/write, deny Everyone else
icacls "C:\Program Files\MyService\MyService.exe" /grant "NT AUTHORITY\Local Service":(RX) /remove "Everyone"

Use sc sdset to manage service DACLs directly.

Auditing & Logging

Enable auditing for service creation, modification, and start/stop events:

auditpol /set /subcategory:"Security System Extension" /success:enable /failure:enable

Leverage Windows Event Log (Event ID 7036, 7040) and channel the output to a SIEM.

Best Practices

Conclusion

Securing Windows services is a multi‑layered effort that combines proper configuration, code signing, access control, and continuous monitoring. By following the guidelines above, administrators can greatly reduce the attack surface of their Windows environments.

← Back to Articles