1. Resources
  2. Detection rules
  3. Service Installed on a Domain Controller

Service Installed on a Domain Controller detection rules

A new Windows service on a domain controller runs code as SYSTEM on the machine that holds every credential of the domain. Attackers create services for remote execution and persistence. Detected as events 7045 and 4697.

Platform
Active Directory
Severity
High
Log source
Windows Security event log, Windows System event log (domain controllers)
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Administrator rights on the domain controller, locally or over the network, or control of an account or management tool that has those rights.
Impact
Code execution as SYSTEM on a domain controller, from where the attacker can extract the credentials of the whole domain and keep access after passwords have been changed.
Response
Take the domain controller off the network, stop and disable the service, and handle the directory database and the krbtgt key as exposed.
Mitigation
Restrict remote access to domain controllers to Tier 0 administrators who work from hardened administrative workstations, and keep the agents and management tools on them few.
Event IDs
469846977045

How the attack works

A Windows service is a program that the Service Control Manager starts, usually under the SYSTEM account and often automatically at boot. Creating a service is therefore a way to run code with the highest local rights and to have it run again after every restart. Administrators can create services on another machine through the remote interface of the Service Control Manager. Remote administration and software deployment tools work that way, and so do attackers who hold stolen administrator credentials and want to execute code on a machine they have not logged on to.

On a domain controller the stakes are higher than on any other server. Code that runs as SYSTEM there can read the directory database, the krbtgt key and the secrets of every account, so one malicious service amounts to control of the domain. At the same time legitimate service installations on domain controllers are few: security agents, backup and monitoring software, and drivers that arrive with updates. That makes every installation worth recording and the unexpected ones worth an alert.

Windows writes two events when a service is installed. The Service Control Manager logs event 7045 in the System log, with the service name, the path of the program, the service type, the start type and the service account. With the audit subcategory Audit Security System Extension enabled, the Security log receives event 4697 with the same details and, in addition, the account that installed the service and its logon ID. Microsoft Defender for Identity bases its suspicious service creation alert on event 7045. A scheduled task reaches the same end by another route, so one more rule on this page reads event 4698, which records each new task with its creator and its full content when the audit subcategory Audit Other Object Access Events is enabled.

What an attacker needs

  • Administrator rights on the domain controller, locally or over the network. That means membership in the Administrators, Domain Admins or Enterprise Admins groups, or control of an account or management tool that has those rights.

Impact

Code execution as SYSTEM on a domain controller, repeated at every start if the service starts automatically. From there the attacker can extract the credentials of the whole domain, forge tickets, load a kernel driver to switch off security software, and keep access after passwords have been changed.

Detection rules

Scheduled Task Created on a Domain Controller by a User Account

Detects event 4698 (a scheduled task was created) in the Security log where the creating account is not a computer account. A scheduled task is the second common way, next to a service, to run code on a server from a distance and to have it run again later, and on a domain controller a task that runs as SYSTEM has the same reach as a service. Tasks that Windows and locally running agents register under the SYSTEM account are logged with the computer account as subject and are excluded, so a task created by code that already runs as SYSTEM is not detected. The event holds the creating account and its logon ID, the task name and the full XML content of the task, including the command it runs and the account it runs as. Microsoft recommends monitoring all task creation events on critical computers, and notes that tasks in the root of the Task Scheduler Library and tasks that store a password deserve attention. The rule cannot tell whether the computer is a domain controller, so apply it to the Security logs of domain controllers only. Requires the audit subcategory Audit Other Object Access Events.

LevelMediumStatusExperimentalLog sourceWindows Security event log
title: Scheduled Task Created on a Domain Controller by a User Account
id: 0093caa3-2b6f-480e-bbec-e517e75f98b9
status: experimental
description: >-
  Detects event 4698 (a scheduled task was created) in the Security log
  where the creating account is not a computer account. A scheduled task
  is the second common way, next to a service, to run code on a server
  from a distance and to have it run again later, and on a domain
  controller a task that runs as SYSTEM has the same reach as a service.
  Tasks that Windows and locally running agents register under the SYSTEM
  account are logged with the computer account as subject and are
  excluded, so a task created by code that already runs as SYSTEM is not
  detected. The event holds the creating account and its logon ID, the
  task name and the full XML content of the task, including the command it
  runs and the account it runs as. Microsoft recommends monitoring all
  task creation events on critical computers, and notes that tasks in the
  root of the Task Scheduler Library and tasks that store a password
  deserve attention. The rule cannot tell whether the computer is a domain
  controller, so apply it to the Security logs of domain controllers only.
  Requires the audit subcategory Audit Other Object Access Events.
references:
  - https://attack.mitre.org/techniques/T1053/005/
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4698
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-other-object-access-events
author: Forestall
date: 2026-11-18
tags:
  - attack.execution
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1053.005
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 4698
  filter_computer_accounts:
    SubjectUserName|endswith: '$'
  condition: selection and not 1 of filter_*
falsepositives:
  - Tier 0 administrators who schedule maintenance on a domain controller, and backup or management software that registers its tasks with a named service account. Match the event to a change record, and exclude the service account by exact SubjectUserName.
level: medium

False positives

  • Tier 0 administrators who schedule maintenance on a domain controller, and backup or management software that registers its tasks with a named service account. Match the event to a change record, and exclude the service account by exact SubjectUserName.

Service Installed on a Domain Controller by a User Account

Detects event 4697 (a service was installed in the system) in the Security log where the installing account is not a computer account. Installations that Windows and locally running agents perform under the SYSTEM account are logged with the computer account of the machine as subject and are excluded. What remains are services created by a named account, which is what an administrator and an attacker with administrator credentials produce when they install a service by hand or from another machine. A service created by code that already runs as SYSTEM on the domain controller is not detected here (see the System log rule). The rule cannot tell whether the computer is a domain controller, so apply it to the Security logs of domain controllers only. Requires the audit subcategory Audit Security System Extension. The event exists on Windows Server 2016 and later.

LevelMediumStatusExperimentalLog sourceWindows Security event log
title: Service Installed on a Domain Controller by a User Account
id: f4e42e73-87c1-4184-9048-0565c80d2069
status: experimental
description: >-
  Detects event 4697 (a service was installed in the system) in the Security
  log where the installing account is not a computer account. Installations
  that Windows and locally running agents perform under the SYSTEM account are
  logged with the computer account of the machine as subject and are excluded.
  What remains are services created by a named account, which is what an
  administrator and an attacker with administrator credentials produce when
  they install a service by hand or from another machine. A service created by
  code that already runs as SYSTEM on the domain controller is not detected
  here (see the System log rule). The rule cannot tell whether the computer is
  a domain controller, so apply it to the Security logs of domain controllers
  only. Requires the audit subcategory Audit Security System Extension. The
  event exists on Windows Server 2016 and later.
references:
  - https://attack.mitre.org/techniques/T1543/003/
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4697
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-security-system-extension
author: Forestall
date: 2026-11-14
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1543.003
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 4697
  filter_computer_accounts:
    SubjectUserName|endswith: '$'
  condition: selection and not 1 of filter_*
falsepositives:
  - Tier 0 administrators who install or update software on a domain controller by hand, and remote administration tools that create a service on the target for each command. Match the event to a change record and to the administrative workstation it came from.
  - Deployment or management platforms that install services with a named service account. Exclude that account by exact SubjectUserName, and treat the platform as Tier 0.
level: medium

False positives

  • Tier 0 administrators who install or update software on a domain controller by hand, and remote administration tools that create a service on the target for each command. Match the event to a change record and to the administrative workstation it came from.
  • Deployment or management platforms that install services with a named service account. Exclude that account by exact SubjectUserName, and treat the platform as Tier 0.

Service Installed on a Domain Controller (System Log)

Detects event 7045 of the Service Control Manager in the System log, which is written whenever a service is installed, with the service name, the path of the program, the service type, the start type and the service account. Microsoft Defender for Identity relies on the same event for its suspicious service creation alert. The rule reports every installation and cannot tell whether the computer is a domain controller, so apply it to the System logs of domain controllers only. It needs no audit policy. The System log does not show who installed the service in the event data, so use event 4697 of the Security log for that.

LevelLowStatusExperimentalLog sourceWindows System event log (domain controllers)
title: Service Installed on a Domain Controller (System Log)
id: f2f72324-1449-4ddd-9bd8-d0deeb1f3b0a
status: experimental
description: >-
  Detects event 7045 of the Service Control Manager in the System log, which is
  written whenever a service is installed, with the service name, the path of
  the program, the service type, the start type and the service account.
  Microsoft Defender for Identity relies on the same event for its suspicious
  service creation alert. The rule reports every installation and cannot tell
  whether the computer is a domain controller, so apply it to the System logs
  of domain controllers only. It needs no audit policy. The System log does not
  show who installed the service in the event data, so use event 4697 of the
  Security log for that.
references:
  - https://attack.mitre.org/techniques/T1543/003/
  - https://learn.microsoft.com/en-us/defender-for-identity/alerts-mdi-classic
  - https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/troubleshoot-unexpected-reboots-system-event-logs
author: Forestall
date: 2026-11-14
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1543.003
logsource:
  product: windows
  service: system
detection:
  selection:
    Provider_Name|contains: Service Control Manager
    EventID: 7045
  condition: selection
falsepositives:
  - Installation and update of security agents, backup, monitoring and management software, and of drivers that come with Windows or hardware updates. Build a list of the service names expected on your domain controllers and review what is not on it.
  - Administration tools that create a temporary service on the target each time they run a remote command. Their use against domain controllers should itself be limited to Tier 0 administrators.
level: low

False positives

  • Installation and update of security agents, backup, monitoring and management software, and of drivers that come with Windows or hardware updates. Build a list of the service names expected on your domain controllers and review what is not on it.
  • Administration tools that create a temporary service on the target each time they run a remote command. Their use against domain controllers should itself be limited to Tier 0 administrators.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Service installed over a network logon from a host that is not an administrative workstation

Detection hypothesisJoins two logsNeeds your own lists

Remote execution with stolen administrator credentials creates the service through the remote interface of the Service Control Manager, inside a network logon session from the attacker's host. Joining the installation to its logon session gives the logon type and source address. A service installed in a network session that comes from anywhere but the Tier 0 administrative workstations and the management servers of the approved agents is the remote execution pattern.

  1. On every domain controller, take event 4697 (a service was installed in the system) and keep SubjectUserName, SubjectLogonId, ServiceName and ServiceFileName.
  2. On the same domain controller, find the event 4624 whose TargetLogonId equals that SubjectLogonId; Microsoft names the logon ID as the value that links the two events. Read LogonType, IpAddress and WorkstationName.
  3. Keep installations made in a network logon (LogonType 3) and compare IpAddress with your list of administrative workstations and management servers.
  4. Report every installation from an address outside the list, first those whose program path is in a temporary or user-writable folder.

Events46974624

LimitsLogon IDs are unique per computer only, so join events of the same domain controller. Deployment tools that install agents from a management server need that server on the list. An attacker working from an allowed administrative workstation, or through an interactive session on the domain controller, is not seen. Event 4697 needs Audit Security System Extension, and Microsoft notes that the address fields of 4624 depend on the authentication context.

Triage

  • Read the service name and the path of the program. A random-looking name, a path in a temporary or user-writable folder, a command interpreter or script host as the program, or a network path are strong signs of misuse.
  • Check the service type and the start type. Kernel and file system drivers (types 0x1 and 0x2) and services installed as disabled are rare and deserve attention, as Microsoft notes for event 4697.
  • In event 4697 identify the installing account and use the logon ID to find the logon (4624), its type and its source address. A network logon from a workstation followed by a service installation is the pattern of remote execution.
  • Compare with change records and with the other domain controllers. A legitimate agent is installed on all of them, by the same tool, in the same maintenance window.
  • If the service is not explained, isolate the domain controller, keep the program file for analysis, and treat the domain as compromised until shown otherwise.

Response

Once the attack is confirmed:

  1. Take the domain controller off the network, then stop and disable the service. Keep the service configuration as evidence together with the program file.
  2. Disable or reset the account that installed the service (event 4697) and isolate the computer the installation came from.
  3. Check every other domain controller for the same service name or program path in event 7045.
  4. The code ran as SYSTEM on a domain controller, so handle the directory database and the krbtgt key as exposed and start the recovery described for NTDS.dit Extraction.
  5. Rebuild the domain controller from trusted media instead of cleaning it, because a service or driver that ran as SYSTEM may have changed more than the events show.
  6. Find out how the administrator credentials were obtained and close that path before the rebuilt server goes into service.

Mitigation

  • Restrict remote access to domain controllers to Tier 0 administrators who work from hardened administrative workstations, as Microsoft recommends for this alert in Defender for Identity.
  • Keep the number of agents and management tools on domain controllers small and manage them from Tier 0 systems only. A deployment or monitoring platform that can install services on domain controllers is itself Tier 0.
  • Keep the administrators of domain controllers few, and never let their credentials be used on lower-tier machines, where they can be stolen and reused for a remote service installation.
  • Use application control on domain controllers, so that unapproved programs and drivers do not run even when a service is created for them.
  • Collect the System log of every domain controller, and enable the audit subcategory Audit Security System Extension so that event 4697 is written.

Frequently asked questions

Which of the two events shows who installed the service?

Event 4697 in the Security log. It carries the installing account and its logon ID, which lead to the logon event and its source address. Event 7045 in the System log has the service name, the program path, the service type, the start type and the service account, but not the installer.

Do these events need an audit policy?

Event 7045 needs none. The Service Control Manager writes it to the System log whenever a service is installed. Event 4697 is written only when the audit subcategory Audit Security System Extension is enabled, and it exists on Windows Server 2016 and later.

What does the Security log rule miss?

A service created by code that already runs as SYSTEM on the domain controller. Such an installation is logged with the computer account as subject, and the rule excludes computer accounts to keep out Windows and locally running agents. The System log rule reports every installation and covers that case.

What does a legitimate service installation on a domain controller look like?

It belongs to a security agent, to backup, monitoring or management software, or to a driver that arrives with an update. A legitimate agent is installed on all domain controllers, by the same tool, in the same maintenance window, and has a change record. A service on one domain controller only, with a random-looking name or a path in a temporary folder, fits none of that.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.