Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 38 ยท Authentication: Kerberos

Kerberos Errors, NTLM Fallback and Troubleshooting

Diagnose Active Directory authentication problems: common Kerberos error codes, NTLM versus Kerberos, encryption types, security events 4768, 4769 and 4771, and Kerberoasting detection.

When authentication fails in a domain, the message on screen ("The target principal name is incorrect", "Access denied", a repeated password prompt) tells you little. The real answer is in the Kerberos error code and in the domain controller's security events. This lesson gives you a small catalogue of the codes you will meet, explains why Windows sometimes uses NTLM instead, and shows how to spot weak encryption and roasting attempts in the logs.

The commands described are Windows tools, shown read-only. The runnable parts are Python stand-ins that decode codes and analyse sample event data.

NTLM versus Kerberos

NTLM is the older challenge-response protocol. The server sends a random challenge, the client replies with a response computed from the password hash, and the server asks a domain controller to verify it (pass-through authentication). Compared with Kerberos:

Kerberos NTLM
Needs the server to contact a DC per login No (ticket is self-contained) Yes
Mutual authentication Yes No
Delegation Yes No
Works with IP addresses and unknown names No (needs a correct SPN) Yes
Resistant to relay attacks Far better Weak; relay and pass-the-hash are well known
Typical use Domain access by name Fallback, workgroup machines, legacy apps

Windows chooses Kerberos when the client has a name it can turn into an SPN and a reachable KDC, and falls back to NTLM otherwise. So NTLM in your logs is a symptom: you connected by IP, the name was a CNAME with no SPN, the clock was off, or the service is not domain-aware. The goal of a modern domain is to audit NTLM, fix the causes, then restrict it. The policy settings are under Network security: Restrict NTLM; start in audit mode, read events 8001 to 8004 in the NTLM operational log, and only then block.

Common Kerberos error codes

Code Name Typical cause
6 KDC_ERR_C_PRINCIPAL_UNKNOWN User name does not exist in this realm
7 KDC_ERR_S_PRINCIPAL_UNKNOWN SPN not found (missing or wrong name)
12 KDC_ERR_POLICY Logon hours, workstation restriction or similar
14 KDC_ERR_ETYPE_NOSUPP No common encryption type
18 KDC_ERR_CLIENT_REVOKED Account disabled, expired or locked out
23 KDC_ERR_KEY_EXPIRED Password expired
24 KDC_ERR_PREAUTH_FAILED Wrong password (the usual bad-password code)
25 KDC_ERR_PREAUTH_REQUIRED Normal first reply; client retries with pre-auth
31 KRB_AP_ERR_BAD_INTEGRITY Ticket cannot be decrypted (key mismatch, often stale password or SPN on the wrong account)
32 KRB_AP_ERR_TKT_EXPIRED Ticket expired
37 KRB_AP_ERR_SKEW Clock difference above 5 minutes
41 KRB_AP_ERR_MODIFIED Ticket changed or decrypted with the wrong key (duplicate SPN)
68 KDC_ERR_WRONG_REALM Referral or name suffix problem
Python Kerberos error lookup

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Encryption types

Tickets are encrypted with a negotiated algorithm identified by an etype number:

etype Name Notes
17 AES128-CTS-HMAC-SHA1-96 Good
18 AES256-CTS-HMAC-SHA1-96 Best widely supported
23 RC4-HMAC Key is the unsalted NT hash; fast to crack; being phased out
1, 3 DES Obsolete and disabled by default

The attribute msDS-SupportedEncryptionTypes on an account says which types it supports, and the domain-wide policy Network security: Configure encryption types allowed for Kerberos sets the defaults. Disabling RC4 for service accounts forces AES tickets, which are far more expensive to crack offline.

Reading the domain controller's security log

Three events matter most (enable Audit Kerberos Authentication Service and Audit Kerberos Service Ticket Operations under Advanced Audit Policy):

  • 4768: a TGT was requested (AS exchange). The result code is 0x0 on success; 0x18 is a bad password, 0x6 an unknown user, 0x12 a disabled or locked account.
  • 4769: a service ticket was requested. The ticket encryption type is included; 0x17 (RC4) requests for service accounts that support AES are suspicious.
  • 4771: Kerberos pre-authentication failed. A burst of these for many users from one client is password spraying.

Those same events are the raw material for detecting Kerberoasting: an attacker requests service tickets for many SPNs and cracks them offline. Warning signs are one account asking for tickets to dozens of different services in minutes, especially with RC4.

Python Spot Kerberoasting in sample 4769 events

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The data is invented; real detection also uses a baseline per account, because some scanners and applications legitimately request many tickets.

A troubleshooting routine

  1. Reproduce by name. Use the full DNS name, not the IP, and note exactly which name fails.
  2. Check time on client, server and DC (w32tm /query /status; w32tm /resync).
  3. Check DNS: the name resolves to the right server and the client uses domain DNS.
  4. Check the ticket cache: klist purge, retry, then klist to see which SPN was requested and whether a ticket was issued. If no ticket for the expected SPN appears, the SPN is missing or duplicated (SPNs).
  5. Check the DC logs for 4768, 4769 and 4771 around the failure time and read the result code.
  6. Check the account: disabled, locked, expired password, logon-hours restrictions, "this account supports Kerberos AES" flags.
  7. Check the secure channel of the computer: Test-ComputerSecureChannel. A computer whose password the domain no longer knows (after restoring from an old image) produces bad-integrity errors; reset it with Reset-ComputerMachinePassword.
  8. Check trusts and name suffix routing for cross-domain failures.

For debugging inside the protocol, Windows can log detailed Kerberos messages when the registry value KerbDebugLevel is set, but doing so is noisy, so reverse it as soon as you have the data.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A user types the wrong password. Which Kerberos error appears in the DC log (event 4768 or 4771)?

    Pre-authentication fails because the encrypted timestamp cannot be decrypted with the expected key.
  2. 2. A client connecting by IP address ends up using which protocol?

    Kerberos needs a service name to form the SPN. Without one Windows falls back to NTLM.
  3. 3. Why is RC4 (etype 23) considered weak?

    RC4 tickets encrypted with weak passwords can be brute-forced quickly, so AES is preferred.
  4. 4. A single account requests tickets for 40 different SPNs in a minute, all with RC4. What is the likely explanation?

    Mass service-ticket requests with weak encryption are the signature of an attacker collecting tickets to crack.
  5. 5. Which tool clears the Kerberos ticket cache on a Windows client?

    klist purge removes cached tickets so the next access requests new ones, which is the first step after changes to groups or SPNs.

Summary

  • NTLM appears when Kerberos cannot be used; fix the cause (names, SPNs, time) and audit before restricting NTLM.
  • Learn the code table: 24 bad password, 37 skew, 7 unknown SPN, 41 duplicate SPN or wrong key.
  • Prefer AES (etype 17 and 18) and watch events 4768, 4769 and 4771.
  • Troubleshoot in order: name, time, DNS, ticket cache, DC logs, account state, secure channel.

Next: LDAPS, Signing and Channel Binding