Service binary replacement is an attack where a trusted service’s executable file is swapped for a malicious one. It works by abusing write access to the service path, so the next start or restart runs attacker-controlled code with the service’s privileges.
What service binary replacement is
Service binary replacement is a persistence and execution-hijacking technique. The attacker does not need to create a new service; instead, they replace the trusted executable that the service launches, then wait for the next start, restart, or maintenance cycle to trigger their code under the service’s own privileges.
This makes the technique effective in environments where service paths are writable by non-admin users, where deployment tooling leaves loose file permissions behind, or where operational teams assume a service binary is stable once installed.
How the attack works
The core abuse is write access to the service path or the executable that the service manager calls. Once an attacker can overwrite or swap that file, the service manager becomes an unwitting execution mechanism. In practice, the compromise often looks like ordinary service recovery or reboot activity until the malicious binary is invoked.
That means the attacker is exploiting trust in the service definition as much as the binary itself. If the path, replacement target, or parent directory is writable, the attacker can turn a legitimate operational action into code execution without needing to change the service configuration in a visible way.
The technique is closely related to file-permission weaknesses and service integrity failures, so defensive validation should focus on the executable, its directory, and any linked update or packaging process that can alter the file without proper control. The D3FEND concept of D3-SBV Service Binary Verification is useful here because it frames the defender’s job as verifying that the binary on disk is still the trusted one, not merely assuming the service name is trustworthy.
Why it is dangerous
Once a service binary is replaced, the malicious code inherits whatever authority the service already had. That can mean local privilege escalation, lateral movement from a high-value host, access to protected data, or durable persistence that survives reboots and process restarts. The danger is amplified when the service runs as SYSTEM, root, or a service account with broad access.
It is also dangerous because it can blend in with normal operations. Services restart for patching, crashes, reconfiguration, and housekeeping. An attacker who times replacement carefully can make malicious execution look like routine administration unless integrity checks, file auditing, and allowlisting are in place.
From a control perspective, the most relevant weakness is usually overbroad write permission on binaries or their parent directories. M1022 Restrict File and Directory Permissions is directly relevant because reducing write access to service executables and service paths is one of the main ways to remove the attacker’s replacement opportunity.
How defenders detect and reduce exposure
Defenders should first inventory which services matter, where their binaries live, and who can modify those files or directories. Exposure usually shows up through weak ACLs, insecure deployment scripts, mis-scoped admin delegation, or legacy service installs that were never hardened after rollout.
Detection should combine integrity monitoring, file change auditing, and service-behaviour review. A changed binary hash, unexpected file owner, unsigned replacement, or service start from an unusual path is often more meaningful than process activity alone. A broader defensive model such as the MITRE D3FEND Guide helps connect those signals to verification, hardening, and detection techniques rather than treating them as isolated alerts.
When you are checking exposure, the practical question is simple: can anything other than the trusted deployment path write the executable or its parent folder? If the answer is yes, the service is exposed to binary replacement even if the service itself is otherwise well configured.
Response and recovery after suspected replacement
If service binary replacement is suspected, assume the service may have executed attacker-controlled code before the binary was discovered. Recovery should include restoring a trusted binary from a known-good source, validating the service configuration, and reviewing related startup tasks, scripts, and directories for additional persistence.
Post-incident review matters because the attacker may also have touched adjacent assets that support execution, such as scheduled restarts, service wrappers, loaders, or directories used during maintenance. The service binary is the visible symptom, but the compromise path may be broader than the swapped file itself.
For ongoing hardening, the most useful control pattern is disciplined file-permission management across the service path and any supporting artefacts. The same principle that protects binaries also protects related executable content, because replacement attacks often succeed where the operating system trusts a file location more than the file’s provenance.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1574.010 — Hijack Execution Flow: Services File Permissions Weakness | Service binary replacement is a service file-permission hijack technique. |
| Recommendation — Map writable service paths to T1574.010 and alert on unauthorized service binary changes. | ||
| NIST SP 800-53 Rev 5 | CM-5 — Access Restrictions for Change | Restricts who may modify system files and service executables. |
| SI-7 — Software, Firmware, and Information Integrity | Requires integrity checks to detect tampering with trusted executables. | |
| Recommendation — Apply CM-5 to limit who can change service binaries and related startup files. Use SI-7 to verify service binary integrity before execution and after change events. | ||
| CIS Controls v8 | CIS-5 — Account Management | Supports limiting who can obtain write access that enables service binary replacement. |
| CIS-8 — Audit Log Management | Logs file and service changes needed to spot executable replacement activity. | |
| Recommendation — Restrict privileged file-write access to the smallest set of approved administrators. Centralize file-integrity and service-change logs so replacement events are reviewable. | ||
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org