SPN Validation

Table of contents
A Brief Kerberos Recap
Within an Active Directory environment, users authenticate to resources using Kerberos. It usually goes something like this:
- Determine which service to connect to on which host, and derive an SPN of the form service/host.
- Ask the KDC for a ticket to this SPN.
a. The KDC searches for an account matching the SPN and fetches the long-term key.
b. The KDC composes a ticket encrypted with this key. - Send the SPN to the target host.
- If the server can decrypt the ticket with its key, the user is authenticated.
This is greatly simplified. For a more detailed analysis, see my blog article on Kerberos. In Active Directory, the SPN maps to a computer account with a long-term key, just like a normal user account. A computer account usually has several SPN mappings, most notably host/hostname. All SPNs mapping to the same account share the same key, so they can usually be used interchangeably. The only thing the host usually cares about is whether or not it can decrypt the ticket. In fact, you can request a ticket with the SPN SERVER$ or even use U2U authentication with SMB.
For example, on Titanis, you could use these:
Smb2Client ls //lumon-fs1/c$ -UserName … -SpnOverride cifs/lumon-fs1=LUMON-FS1$ -Password … -Kdc lumon-dc1
Smb2Client ls //lumon-fs1/c$ -UserName … -U2u LUMON-FS1$ -Password … -Kdc lumon-dc1Since both commands result in a ticket with a key matching that of the computer account, the server accepts them.
Quick NTLM Note
Although NTLM doesn’t require SPNs like Kerberos does, NTLMv2 optionally provides the SPN within the NTLM_AUTHENTICATE packet. This SPN is evaluated in the same manner as if Kerberos had been used. In Titanis, -SpnOverride affects NTLM as well.
Enter Server SPN Target Name Validation
Windows offers a policy that requires the SPN on the ticket to match both the service class and the host name. This may be configured either as a group policy:
Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options > Microsoft network server: Server SPN target name validation level |
Or as a registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters |
The policy offers three (3) settings:
- Disabled: The server does not require that an SPN be specified, nor does it verify any SPN that is provided.
- Accept (1): If the client provides an SPN, validate it, and fail the authentication if the provided SPN doesn’t match what the server expects.
- Require (2): The client must provide an SPN, and the SPN must be valid.
When using Kerberos, the SPN validation occurs after the ticket itself is validated. That is, if the ticket is invalid, the server rejects the authentication request with KRB5KRB_AP_ERROR_MODIFIED (41) to indicate that the server cannot decrypt the ticket.
This policy only affects SMB. It does not affect other protocols, such as RPC. RPC bindings over named pipes are affected, while RPC bindings over TCP are not. While there is a similar-sounding policy for Kerberos named “Require strict target SPN match on remote procedure calls”, it is unrelated and does not perform the same validation.
What It Does
With this policy enabled, the server accepts SPNs matching:
- The NetBIOS computer name: cifs/LUMON-FS1
- The fully qualified domain name: cifs/lumon-fs1.corp.lumon.ind
- U2U tickets to the computer account: LUMON-FS1$
- An IP address currently assigned to the machine; this includes:
a. The IPv4 local loopback: cifs/127.0.0.1
b. The IPv6 local loopback: cifs/::1
c. The IPv6 link-local addresses, without the interface index: cifs/fe80::a25a:80a7:614d:d3aa
d. The IPv6 link-local addresses, with any interface index: cifs/fe80::a25a:80a7:614d:d3aa%17
When using Kerberos, those SPNs must be manually mapped in Active Directory for the KDC to issue the ticket. NTLM requires no special setup, as the SPN is simply a text field in the NTLM_AUTHENTICATE packet.
Here are some things that don’t work:
- Tickets with a service class other than cifs
- Other IPv4 loopback addresses, such as 127.0.0.2 or 127.1
- Other names registered on the host as alternate names
- The machine account name: LUMON-FS1$
If the SPN validation fails, either because the client provided the wrong SPN or none at all, the server rejects the authentication request with STATUS_ACCESS_DENIED (0xC0000022). The SMB server logs an error with Event ID 551 in its log (Microsoft-Windows-SMBServer/Security). The event data includes the SPN sent by the user.

Why It Matters
Here is a typical red team workflow:
- Get the NTLM hash of the machine, usually using shadow credentials with Kerberos PKINIT.
- Forge a ticket for a user of choice with an SPN of host/computer.
- Connect to the server and do various RPC/SMB things.
The choice of host is usually because 1) it’s usually the default, 2) some tooling expects it, and 3) it is used by several RPC protocols and also works with SMB. An actor may also use some form of a credential relay to capture an NTLM authentication from another connection and replay it to a target SMB server.
While using Titanis on a recent engagement, performing the above steps resulted in STATUS_ACCESS_DENIED.
Whenever Titanis connects to a network service, it accepts a ticket cache. It first checks whether the ticket cache contains a ticket with the appropriate SPN. For SMB, the SPN is cifs/hostname. This doesn’t match host/hostname, so the operator used the -SpnOverride feature, like this:
Smb2Client ls //server/c$ -TicketCache ticket.ccache -SpnOverride cifs/server=host/serverThis instructs Titanis that whenever a component requests a ticket for cifs/server, search instead for host/server. Titanis uses any matching ticket as-is. Specifically, the ticket is transmitted with its original SPN of host/server. This matched the ticket from Step #2, resulting in STATUS_ACCESS_DENIED. I instructed the operator to slightly change the syntax:
Smb2Client ls //server/c$ -TicketCache ticket.ccache -SpnOverride cifs/server~=host/serverSee the difference? The ~ in the -SpnOverride instructs Titanis to use host/server for the lookup only, but the SPN in the ticket is changed to cifs/server before itis transmitted, since that is the appropriate SPN. And since both host/ and cifs/ map to the same account in Active Directory, the ticket encryption key still matches. This resolved the issue, and the operator was able to proceed. To confirm, we checked the registry controlling SPN validation, which confirmed my suspicions.