NTLM Internals: The Challenge/Response Handshake and Its Hashes
How NTLM authentication works on Windows: the three messages of the NTLMSSP handshake, Netlogon pass-through validation for domain accounts, how the NT hash and the NTLMv1 and NTLMv2 responses are derived, where NTLM is still used instead of Kerberos, and the telemetry and hardening that let a defender measure and reduce it.
Introduction
NTLM (NT LAN Manager) is a family of challenge/response authentication protocols. A client proves to a server that it knows a user’s password without sending the password: the server sends a random challenge, and the client returns a value computed from the challenge and a key derived from the password.1
NTLM predates Active Directory. In a modern domain Kerberos is the
preferred protocol, and NTLM survives as a fallback for every situation
in which Kerberos cannot be used. On Windows, both the client and the server
side are implemented by the MSV1_0 authentication package inside
lsass.exe, exposed to applications through the NTLM security support
provider (NTLMSSP) and the Negotiate package.2
NTLM has well-known weaknesses: there is no mutual authentication of the server, there is no binding to the target unless additional protections are configured, and the key is derived from the password with a single unsalted hash. Microsoft has announced the deprecation of NTLM and recommends that organizations audit and reduce its use.3 This article describes the protocol in enough depth to understand both its telemetry and its hardening.
The three-message handshake
NTLM authentication consists of three messages exchanged between the client and the server, carried inside the application protocol (SMB, HTTP, LDAP and others). When the account belongs to a domain, the server cannot verify the response on its own and forwards it to a domain controller (Figure 1).1
sequenceDiagram
autonumber
participant C as Client
participant S as Server (SMB, HTTP, LDAP...)
participant DC as Domain controller
C->>S: NEGOTIATE_MESSAGE (Type 1): supported features and flags
S-->>C: CHALLENGE_MESSAGE (Type 2): 8-byte server challenge + target info
Note over C: Computes the response from the<br/>NT hash and the challenge
C->>S: AUTHENTICATE_MESSAGE (Type 3): responses, user, domain, MIC
alt Domain account
S->>DC: Netlogon pass-through (secure channel)
Note over DC: Recomputes the response from the<br/>NT hash stored in NTDS.dit
DC-->>S: Accept or deny + user authorization data
else Local account
Note over S: Validates against its own SAM
end
Figure 1. The NTLM handshake and Netlogon pass-through validation.
| # | Message | Content |
|---|---|---|
| 1 | NEGOTIATE_MESSAGE (client → server) | Negotiation flags announcing the features the client supports, for example NTLMSSP_NEGOTIATE_NTLM, NTLMSSP_NEGOTIATE_128, NTLMSSP_NEGOTIATE_56, signing and sealing; optionally the client’s domain and workstation names |
| 2 | CHALLENGE_MESSAGE (server → client) | An 8-byte random server challenge (nonce); the server’s negotiation flags; the target info list (AV_PAIRs) with NetBIOS and DNS names of the server and its domain and, for NTLMv2, a timestamp |
| 3 | AUTHENTICATE_MESSAGE (client → server) | The LM and NT challenge responses, the user name, domain and workstation, an optional encrypted session key and, when the target info contains a timestamp, a Message Integrity Code (MIC) computed over all three messages |
The MIC protects the integrity of the handshake: it prevents tampering with the negotiation flags of the three messages, for example to remove the request for signing.1
Netlogon pass-through validation
For a local account, MSV1_0 on the server looks up the user’s NT hash in the local SAM and verifies the response directly.
For a domain account, the server does not know the user’s key. MSV1_0
forwards the challenge and the response to a domain controller over the
Netlogon secure channel, the authenticated channel that every
domain-joined computer maintains with a DC using its computer account
password. The request is made through the NetrLogonSamLogonWithFlags RPC
method.4 The DC reads the user’s NT hash from the Active Directory
database (NTDS.dit), recomputes the expected response, and returns the
result together with the user’s authorization data, which the server uses to
build the access token.
Unlike Kerberos, NTLM therefore needs a round trip to a domain controller for every authentication of a domain account. The server learns only that the user is valid; the client never learns whether it talked to the genuine server.
Hashes and responses
The NT hash
Every NTLM response is derived from one long-term key, the NT hash
(sometimes called the NTLM hash or NT one-way function, NTOWFv1):1
1
NT hash = MD4( UTF-16LE(password) ) 16 bytes
The NT hash is stored in the SAM for local accounts and in NTDS.dit for
domain accounts, and MSV1_0 keeps it in LSASS memory for the lifetime of a
logon session to provide single sign-on (see the
LSASS article).
Two properties of this derivation matter to a defender:
- It is unsalted. The same password produces the same NT hash on every account and every system.
- It is password-equivalent. NTLM never uses the password itself, only the NT hash. Possession of the hash is enough to compute valid responses, which is why it must be protected exactly like a password.
The LM hash (legacy)
The older LM hash converts the password to upper case, pads or truncates
it to 14 characters, splits it into two 7-byte halves and uses each half as a
DES key to encrypt a fixed constant. The result is case-insensitive, limited
to 14 characters and made of two independent halves, so its effective
strength is very low. Windows has not stored LM hashes by default since
Windows Vista and Windows Server 2008, controlled by the policy Network
security: Do not store LAN Manager hash value on next password change
(NoLMHash = 1).5
NTLMv1 response
The NTLMv1 response pads the NT hash to 21 bytes, splits it into three 7-byte DES keys and encrypts the 8-byte server challenge with each of them, producing a 24-byte response.1
1
2
K1 | K2 | K3 = NT hash padded to 21 bytes, split into 3 x 7 bytes
NTLMv1 response = DES(K1, challenge) | DES(K2, challenge) | DES(K3, challenge)
The response depends only on the NT hash and the server challenge. There is no client contribution and no timestamp, and DES with 56-bit keys is weak. NTLMv1 should be treated as unacceptable on any modern network.
NTLMv2 response
NTLMv2 introduces an intermediate key bound to the user and domain names and a client-generated blob:1
1
2
3
4
NTOWFv2 = HMAC-MD5( NT hash, UTF-16LE( UPPER(user) + domain ) )
blob = timestamp | client challenge (8 bytes) | target info | ...
NTProofStr = HMAC-MD5( NTOWFv2, server challenge | blob )
NTLMv2 resp. = NTProofStr | blob
flowchart TB
PW["Password"] -->|"UTF-16LE, MD4"| NT["NT hash"]
NT -->|"HMAC-MD5 with UPPER(user) + domain"| V2["NTOWFv2"]
SC["Server challenge"] --> P
BL["Blob: timestamp, client challenge, target info"] --> P
V2 --> P["HMAC-MD5: NTProofStr"]
P --> R["NTLMv2 response = NTProofStr + blob"]
NT -.->|"legacy: DES x 3 over the server challenge"| R1["NTLMv1 response"]
Figure 2. Derivation of the NT hash and of the NTLMv1 and NTLMv2 responses.
| NTLMv1 | NTLMv2 | |
|---|---|---|
| Primitive | DES (56-bit keys) | HMAC-MD5 |
| Inputs | NT hash, server challenge | NT hash, user, domain, server challenge, client blob |
| Client nonce | No | Yes (client challenge in the blob) |
| Timestamp | No | Yes, limits the validity window of a response |
| Target info / MIC | No | Yes, binds the response to the server’s names and protects the handshake |
| Status | Disabled by policy on modern Windows; removed in recent releases3 | Default |
NTLMv2 is much stronger than NTLMv1, but it inherits the properties of the NT hash. A captured NTLMv2 exchange can still be subjected to offline password guessing, so the strength of the user’s password remains the real protection. Neither version authenticates the server to the client.
Where NTLM is used
NTLMSSP is not a transport of its own: its three messages are embedded in the authentication mechanism of many application protocols.2
| Protocol | Typical use |
|---|---|
| SMB / CIFS | File shares and administrative shares (C$, ADMIN$, IPC$) |
| HTTP | Integrated Windows Authentication in IIS and Exchange |
| LDAP | Directory queries and binds against Active Directory |
| MS-SQL | SQL Server Windows authentication |
| WinRM / WMI | Remote management |
| RPC / DCOM | Remote procedure calls and distributed COM |
| SMTP | Exchange mail relay |
When the Negotiate package is used, Windows picks Kerberos first and falls back to NTLM when Kerberos cannot complete. Common reasons are:
- the target is addressed by IP address instead of a host name, so no SPN matches;
- the client or the server is not a domain member (workgroup);
- no domain controller is reachable from the client;
- the target has no registered SPN, or the SPN is duplicated;
- a legacy application calls NTLM directly instead of Negotiate;
- the resources are in another forest without a suitable trust.
Because these conditions are common, NTLM persists in many Active Directory environments long after Kerberos became the default. They also explain why an attacker who can influence name resolution or the authentication target may try to steer a client toward NTLM, and why the hardening controls below focus on binding NTLM to its intended target and on reducing its use.
Telemetry
The NTLM traffic of a domain can be measured with built-in logs, which is the first step toward restricting it.
| Source | Event | Use |
|---|---|---|
| Security log (DC, or member for local accounts) | 4776 The computer attempted to validate the credentials for an account6 |
Every NTLM validation, with the account, the source workstation and the error code |
| Security log (server) | 4624 / 4625 with Authentication Package = NTLM7 |
Logons that used NTLM; the Package Name (NTLM only) field reports NTLM V1 or NTLM V2 |
| Microsoft-Windows-NTLM/Operational | 8001–8004 audit events8 |
Generated when the Restrict NTLM policies are set to audit; identify the clients, servers and processes that use NTLM |
| Netlogon log | netlogon.log with debug logging |
Pass-through authentication requests on the DC, including NTLMv1 |
Analytics worth building on these sources:
- NTLMv1 usage. Any
4624withNTLM V1is a configuration problem to fix. - Privileged accounts over NTLM. Administrative accounts should authenticate with Kerberos; NTLM logons for them deserve attention.
- Unusual sources. NTLM logons from hosts that normally use Kerberos, or a
burst of
4776failures for many accounts from one source. - Anonymous and machine-account NTLM. NTLM authentications of computer accounts toward unexpected servers can indicate coerced authentication.
Hardening
| Control | Effect |
|---|---|
LAN Manager authentication level = Send NTLMv2 response only. Refuse LM & NTLM (LmCompatibilityLevel = 5) |
Clients send only NTLMv2, DCs refuse LM and NTLMv19 |
NoLMHash = 1 |
No LM hash is stored on password change5 |
| Restrict NTLM policies (audit first, then deny) | Inventory, then block, incoming, outgoing and domain-wide NTLM, with exception lists for remaining dependencies8 |
| SMB signing required | Binds the SMB session to the authenticated identity and defeats relaying to SMB10 |
| LDAP signing and channel binding | Require signed LDAP and bind LDAPS authentication to the TLS channel11 |
| Extended Protection for Authentication (EPA) | Binds HTTP authentication (IIS, Exchange, AD CS web enrollment) to the TLS channel12 |
| Protected Users group | Members cannot authenticate with NTLM at all13 |
| Fix SPNs and name resolution | Removes the most common causes of fallback from Kerberos |
Experiment: measuring NTLM on a host
The configured LAN Manager authentication level can be read from the registry. A missing value means the operating system default applies:
1 Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' -Name LmCompatibilityLevel, NoLMHash -ErrorAction SilentlyContinueThe most recent NTLM logons, with the protocol version, can be extracted from the Security log (administrative rights required):
1 2 3 4 5 6 Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4624 } -MaxEvents 500 | Where-Object { $_.Properties[10].Value -eq 'NTLM' } | Select-Object TimeCreated, @{ n = 'Account'; e = { $_.Properties[5].Value } }, @{ n = 'Version'; e = { $_.Properties[14].Value } }, @{ n = 'Source'; e = { $_.Properties[18].Value } }
Summary
NTLM authenticates a client with a three-message challenge/response
handshake: NEGOTIATE, CHALLENGE and AUTHENTICATE. The client
answers the server’s challenge with a value derived from the NT hash, an
unsalted MD4 of the password that is password-equivalent for the protocol.
For domain accounts the server forwards the response to a domain controller
over the Netlogon secure channel. NTLMv1 is a DES-based legacy
response with no client contribution; NTLMv2 adds a client challenge, a
timestamp, target information and a MIC, but still offers no server
authentication and still exposes captured exchanges to offline guessing.
NTLM persists as Kerberos’s fallback and is embedded in SMB, HTTP, LDAP and
many other protocols. Defenders should measure it with 4776, 4624 and the
NTLM operational log, eliminate NTLMv1 and LM, enforce signing and channel
binding, and progressively restrict NTLM where Kerberos can take its place.
References
-
Microsoft Open Specifications, [MS-NLMP]: NT LAN Manager (NTLM) Authentication Protocol. ↩︎ ↩︎2 ↩︎3 ↩︎4 ↩︎5 ↩︎6
-
Microsoft Learn, NTLM overview. ↩︎ ↩︎2
-
Microsoft Learn, Deprecated features in the Windows client: NTLM. ↩︎ ↩︎2
-
Microsoft Open Specifications, [MS-NRPC]: Netlogon Remote Protocol. ↩︎
-
Microsoft Learn, Network security: Do not store LAN Manager hash value on next password change. ↩︎ ↩︎2
-
Microsoft Learn, 4776(S, F): The computer attempted to validate the credentials for an account. ↩︎
-
Microsoft Learn, 4624(S): An account was successfully logged on. ↩︎
-
Microsoft Learn, Network security: Restrict NTLM: Audit NTLM authentication in this domain. ↩︎ ↩︎2
-
Microsoft Learn, Network security: LAN Manager authentication level. ↩︎
-
Microsoft Learn, Overview of Server Message Block signing. ↩︎
-
Microsoft Support, 2020, 2023, and 2024 LDAP channel binding and LDAP signing requirements for Windows (KB4520412). ↩︎
-
Microsoft Learn, Extended Protection for Authentication overview. ↩︎
-
Microsoft Learn, Protected Users security group. ↩︎