How it works
An NTLM relay forwards a victim's challenge and response exchange to a server of the attacker's choice, which then opens a session for the victim that the attacker controls. The mechanism is described on the SMB relay page. This page covers the most valuable target: LDAP on a domain controller.
LDAP is valuable because the session can write to the directory, and because every account has some write access there. A computer account can write several attributes on its own object, including the ones that decide who may impersonate users to that computer. So the attacker does not need to catch an administrator. Any computer's authentication is enough to take over that computer.
Two protections decide whether a domain controller accepts a relayed bind:
| Protection | What it does | Where it applies |
|---|---|---|
| LDAP signing | Integrity and authenticity for every message after the bind. The relaying attacker lacks the session key and cannot sign | SASL binds on port 389 without TLS |
| LDAP channel binding | Ties the authentication to the TLS session with a channel binding token. A relayed authentication carries a token for the wrong TLS session | SASL binds inside TLS: LDAPS on port 636 or StartTLS |
Each one covers a different transport, so enforcing only one leaves the other transport open. The defaults depend on the version:
| Platform | LDAP signing | Channel binding |
|---|---|---|
| Windows Server 2025, new deployment | Required by default | When supported by default, with auditing |
| Windows Server 2022 and earlier | Not required by default | Never by default |
Which authentication can be relayed
The protocol the victim used to reach the attacker matters:
- HTTP clients (WPAD proxy authentication, the WebClient service that handles WebDAV paths) do not ask for signing in their NTLM messages. Their authentication relays to LDAP and LDAPS cleanly. This is why relays to LDAP are usually fed by mitm6, WPAD spoofing, or coercion over WebDAV.
- SMB clients do ask for signing. A domain controller that receives those flags expects signed LDAP traffic, and the message integrity code (MIC) in NTLMv2 stops the attacker from clearing the flags. CVE-2019-1040 ("Drop the MIC") was a bypass that removed the MIC; it is fixed by the June 2019 updates. Clients that still send NTLMv1 have no MIC to protect them.
What the relayed session writes
- Resource-based constrained delegation. The session sets
msDS-AllowedToActOnBehalfOfOtherIdentityon the relayed computer to an account the attacker controls. The attacker then requests a service ticket to that computer as an administrator. See RBCD. - Shadow credentials. The session adds a key to
msDS-KeyCredentialLinkon the relayed account. The attacker then authenticates as that account with the matching certificate. See shadow credentials. - A new computer account, when
ms-DS-MachineAccountQuotaallows it. This needs LDAPS, because the directory only accepts a password for a new account over an encrypted connection. - ACL and group changes, when the relayed account is privileged: ntlmrelayx looks for rights that let it add a user to a privileged group or grant replication rights.
- Reads: a dump of users, groups and computers, LAPS passwords and gMSA passwords the relayed account may read.
Prerequisites
- A way to receive NTLM authentication over HTTP from a victim: a position on the victim's segment for poisoning, WPAD or DHCPv6 spoofing, or a domain account to coerce a host that runs the WebClient service.
- A domain controller that does not enforce LDAP signing (for a relay to port 389) or does not enforce channel binding (for a relay to port 636).
- For the RBCD variant: an account with a service principal name that the attacker controls, either an existing computer account or one the relay creates when the machine account quota is above zero.
- For the shadow credentials variant: a domain controller that supports PKINIT, which requires a domain controller certificate.
- NTLM allowed for the victim. Members of Protected Users cannot authenticate with NTLM.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Set up the source of authentication
Use any source that produces HTTP authentication. On the local segment, mitm6 with WPAD is the usual choice:
sudo mitm6 -d corp.example.com
With Responder, turn off its own HTTP and SMB servers in Responder.conf (HTTP = Off, SMB = Off) so the relay tool receives the connections:
sudo python3 Responder.py -I eth0 -v
2. Relay to LDAP and write RBCD
Relay a computer account's authentication to a domain controller and give an attacker-controlled account delegation rights over that computer:
# Create a computer account through the relay and delegate to it (needs LDAPS)
ntlmrelayx.py -6 -t ldaps://DC01.corp.example.com -wh wpad-proxy.corp.example.com --delegate-access
# Delegate to an account the attacker already controls
ntlmrelayx.py -t ldap://DC01.corp.example.com --delegate-access --escalate-user 'ATTACKER01$' --no-dump
ntlmrelayx prints the name and password of the computer account it created, and confirms that the account can now impersonate users on the relayed computer. The follow-on ticket request is on the RBCD page.
3. Relay to LDAPS and add shadow credentials
ntlmrelayx.py -t ldaps://DC01.corp.example.com --shadow-credentials --shadow-target 'WS01$' --no-dump
ntlmrelayx generates a key pair, adds the public key to msDS-KeyCredentialLink on the target, and saves the certificate and private key as a PFX file. The follow-on PKINIT authentication is on the shadow credentials page.
4. Other actions on the session
# Add a computer account only
ntlmrelayx.py -t ldaps://DC01.corp.example.com --add-computer 'ATTACKER01$' --no-dump
# Read LAPS and gMSA passwords the relayed account is allowed to read
ntlmrelayx.py -t ldaps://DC01.corp.example.com --dump-laps --dump-gmsa
# If a privileged user is relayed, escalate this account through ACL changes
ntlmrelayx.py -t ldap://DC01.corp.example.com --escalate-user alice
# Open an interactive LDAP console on a local TCP port
ntlmrelayx.py -t ldap://DC01.corp.example.com -i
| Option | Meaning |
|---|---|
-t ldap:// or ldaps:// |
Relay to LDAP on port 389 or LDAPS on port 636 |
--delegate-access |
Delegate access on the relayed computer account to the specified account |
--escalate-user |
Escalate this user instead of creating a new one |
--add-computer |
Add a new computer account, optionally with a name and password |
--shadow-credentials |
Add a key credential for PKINIT |
--shadow-target |
Account whose msDS-KeyCredentialLink is populated |
--no-dump |
Do not dump the directory |
--no-da, --no-acl |
Do not attempt to add a Domain Admin, or to run ACL attacks |
--dump-laps, --dump-gmsa, --dump-adcs |
Read LAPS passwords, gMSA passwords, or AD CS enrollment information |
--remove-mic |
Remove the MIC (CVE-2019-1040, unpatched systems only) |
-6, -wh |
Listen on IPv6 and serve a WPAD file, for use with mitm6 |
Impact
The relay turns a network position into privilege escalation inside the directory.
- Any computer account relayed: administrator access to that computer, through delegation or a key credential, and then the credentials of everyone who signs in to it.
- A server's computer account relayed: the same for the server. If the computer is a domain controller, delegation over it leads to its secrets and to DCSync. If it is an Exchange server or another computer with broad directory rights, the session inherits those rights.
- A privileged user relayed: direct changes to group membership and to the domain's ACL, which is control of the domain in one step.
- Any user relayed: a full dump of the directory for reconnaissance, and a computer account when the quota allows it, which is itself a domain foothold.
The changes persist after the relay ends. Delegation and key credentials stay on the object until someone removes them.
OPSEC and artifacts
- Writing as little as possible. Operators pass
--no-dump,--no-daand--no-aclso that the session makes one targeted write instead of a directory dump and automatic escalation attempts. The one write still changes an audited attribute. - Reusing an existing account.
--escalate-userwith an account the attacker already has avoids creating a computer account. When the relay does create one, the domain controller writes event 4741, and the creator is the relayed account, often a computer, which is unusual. - The delegation or key write. A change to
msDS-AllowedToActOnBehalfOfOtherIdentityormsDS-KeyCredentialLinkproduces event 5136 when directory change auditing and a SACL cover it. The actor is the relayed account, and for a computer account that means a machine modifying its own delegation, from an address that is not its own. - The bind itself. The domain controller records a network logon, event 4624, for the victim account with the attacker's host as the source address. A bind on port 389 without signing is counted in Directory Service event 2887 and, with LDAP interface diagnostics at level 2, listed with its client address in event 2889.
- Failed attempts against a hardened DC. When channel binding is enforced, a relayed bind over TLS fails and the DC logs event 3039 with the client address.
- Leftovers. The created computer account, the delegation entry and the added key credential remain in the directory, and the PFX file and loot directory remain on the attacker's host.
Detection
The relayed bind looks like an ordinary logon. The writes do not.
- A computer changing its own delegation or key credentials. Event 5136 for
msDS-AllowedToActOnBehalfOfOtherIdentityormsDS-KeyCredentialLinkwhere the subject is the computer account itself. The RBCD rules and shadow credentials rules cover these. - A computer account created by a computer or an ordinary user, in event 4741. See the machine account creation rules.
- Source address mismatch. A network logon to a domain controller for a computer account from an address that is not that computer; see the NTLM relay rules. After coercion, the same computer account shows up within seconds.
- LDAP posture events on domain controllers. Event 2889 lists clients that bind without signing. Events 3039, 3074 and 3075 report binds that fail or would fail channel binding. An address that appears here for many different accounts is a relay host.
// Directory writes that commonly follow an LDAP relay
WindowsEvent
| where EventID == 5136
| where tostring(EventData.AttributeLDAPDisplayName) in~ (
"msDS-AllowedToActOnBehalfOfOtherIdentity",
"msDS-KeyCredentialLink")
| project TimeGenerated, Computer,
Actor = tostring(EventData.SubjectUserName),
LogonId = tostring(EventData.SubjectLogonId),
ObjectDN = tostring(EventData.ObjectDN),
Attribute = tostring(EventData.AttributeLDAPDisplayName),
Operation = tostring(EventData.OperationType)
| extend SelfWrite = Actor endswith "$" and ObjectDN startswith strcat("CN=", trim_end(@"\$", Actor), ",")
| order by TimeGenerated desc
// LDAP posture: unsigned binds and channel binding failures, by domain controller
WindowsEvent
| where Channel == "Directory Service"
| where EventID in (2889, 3039, 3074, 3075)
| summarize Events = count() by Computer, EventID, bin(TimeGenerated, 1h)
| order by TimeGenerated desc
Join the LogonId of a suspicious 5136 to the TargetLogonId of the 4624 on the same domain controller to get the source address of the session that made the write. Legitimate key credential writes exist: Windows Hello for Business provisioning and Microsoft Entra Connect add keys, so baseline the accounts that do it. Event 2889 needs diagnostic level 2 for LDAP Interface Events, and events 3074 and 3075 need a channel binding policy other than Never on a recent build.
Mitigation
Audit first, then enforce both protections on every domain controller. The LDAP signing and channel binding guide has the full procedure.
- Find the clients that would break. Set the
16 LDAP Interface Eventsdiagnostic level to2and review events 2887 and 2889 for unsigned binds. - Turn on channel binding in compatibility mode. Set Domain controller: LDAP server channel binding token requirements to
When supported, then review events 3074 and 3075 and fix the clients they name. - Enforce channel binding. Set the same policy to
Always. - Enforce signing. Set Network security: LDAP client signing requirements to
Require signingon clients, then Domain controller: LDAP server signing requirements toRequire signing. On Windows Server 2025 use Domain controller: LDAP server signing requirements enforcement. - Move applications off simple binds. A cleartext simple bind is rejected once signing is required. Move those applications to Kerberos or to binds inside TLS.
- Set
ms-DS-MachineAccountQuotato 0 so a relayed session cannot create the computer account that the RBCD variant needs. See the MachineAccountQuota guide. - Remove the sources of HTTP authentication. Disable the WebClient service where WebDAV is not needed, remove WPAD discovery, filter rogue DHCPv6, and disable LLMNR and NBT-NS with the LLMNR and NBT-NS guide.
- Reduce NTLM. Disable NTLMv1, add privileged accounts to Protected Users, and keep domain controllers patched so the MIC cannot be removed.
- Audit the attributes. Enable Directory Service Changes auditing with a SACL that covers
msDS-AllowedToActOnBehalfOfOtherIdentityandmsDS-KeyCredentialLinkon computer and user objects.
Detection rules for this attack
Log events to collect
FAQ
Why relay to LDAP instead of SMB?
An SMB relay only helps if the victim is an administrator on the target. A relay to LDAP on a domain controller lets the attacker write to the directory with the victim's rights, and every computer account can write delegation and key credential attributes on itself. That turns any relayed computer account into administrator access to that computer.
Do LDAP signing and channel binding both have to be enforced?
Yes. LDAP signing protects binds on port 389 without TLS. Channel binding protects binds inside TLS, on port 636 or after StartTLS. With only signing enforced, the attacker relays to LDAPS. With only channel binding enforced, the attacker relays to plain LDAP. Enforce both on every domain controller.
Can authentication that arrives over SMB be relayed to LDAP?
Not on patched systems. A Windows SMB client asks for signing in its NTLM messages, the domain controller then expects signed LDAP traffic, and the message integrity code stops the attacker from removing that request. HTTP clients do not ask for signing, so authentication from WPAD or WebDAV is what gets relayed to LDAP.
How do you detect an NTLM relay to LDAP?
Look for what the relay writes: event 5136 for msDS-AllowedToActOnBehalfOfOtherIdentity or msDS-KeyCredentialLink changed by the computer's own account, or event 4741 for a computer account created by a computer. Directory Service events 2889 and 3039 show unsigned binds and binds that fail channel binding.
References
- Adversary-in-the-Middle, T1557 (MITRE ATT&CK)
- LDAP signing for Active Directory Domain Services (Microsoft Learn)
- LDAP channel binding for Active Directory Domain Services (Microsoft Learn)
- Impacket ntlmrelayx.py
- The worst of both worlds: Combining NTLM Relaying and Kerberos delegation (dirkjanm.io)
- CVE-2019-1040: Windows NTLM Tampering Vulnerability (Microsoft Security Response Center)
- 5136(S): A directory service object was modified (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.