Q&A-8Explain a Kerberos application authentication flow.
Answer
The 90-second answer
A Kerberos application login is three exchanges, and the client never holds a service key.
-
AS exchange. The client sends an AS-REQ to the KDC (UDP/TCP 88) naming its principal,
alice@EXAMPLE.COM, plus pre-authentication data: a timestamp encrypted with a key derived from her password (AES string-to-key. PBKDF2, 4096 iterations, RFC 3962; RFC 8009 adds the SHA-2 enctypes at 32768 iterations). The KDC decrypts it to prove she knows the password and returns an AS-REP: a TGT encrypted with the realm'skrbtgt/EXAMPLE.COMkey, and a session key encrypted with Alice's key. She can hold the TGT but neither read nor forge it. -
TGS exchange. For a named service she sends a TGS-REQ carrying the TGT, an authenticator encrypted with the TGT session key, and the target SPN,
HTTP/web01.example.com@EXAMPLE.COM. The KDC returns a service ticket encrypted with web01's long-term key, plus a fresh session key encrypted under the TGT session key. -
AP exchange. She sends the ticket plus a new authenticator encrypted with the service session key. web01 decrypts the ticket with its keytab, decrypts the authenticator with the session key inside the ticket, checks the timestamp against clock skew, and records it in a replay cache. If mutual auth is required it returns an AP-REP.
Authentication ends there. Authorization, what Alice may do on web01, is the application's decision, usually from a PAC or an LDAP lookup.
Why the pieces exist
The TGT exists because only the KDC knows every service key; it is the only party that can mint a ticket a service will accept. The authenticator exists because the service ticket is a bearer token: a copy is replayable. The authenticator is fresh per request and single-use: the timestamp bounds it and the replay cache rejects a second copy.
Trade-offs
- Mutual auth: off by default. Turn on AP-REP when the client must not hand credentials to an impostor; costs one round trip.
- Ticket lifetime: the KDC caps each ticket at min(requested lifetime, remaining TGT lifetime, the service principal's
max_life). Active Directory's default domain policy is 10 h for user tickets with 7 d renewal; MIT krb5'skdc.confdefaults aremax_life24 h andmax_renewable_life0 (no renewal). Long lifetimes cut KDC traffic but widen the window a stolen ticket is usable. - Delegation: constrained (S4U2Self/S4U2Proxy,
msDS-AllowedToDelegateTo) limits a service to named backends. Unconstrained delegation hands the service a forwardable TGT for everything: avoid.
Failure modes
| Symptom | Cause | Detection |
|---|---|---|
KRB_AP_ERR_SKEW | clocks differ by more than the 300 s default skew | NTP drift on either host |
KRB_AP_ERR_REPEAT | authenticator seen before: replay cache hit, or a client retrying a cached authenticator | acceptor replay cache |
| Decrypt failure at the service | SPN mismatch, duplicate SPN on the wrong account, or stale keytab after rotation (kvno mismatch) | service logs; klist -k vs KDC kvno |
KDC_ERR_S_PRINCIPAL_UNKNOWN | service principal never registered | KDC log |
KDC_ERR_PREAUTH_FAILED | client's cached key is stale after a password change | KDC log; klist on the client |
KRB_AP_ERR_TKT_EXPIRED | ticket past endtime; client should renew or re-authenticate | service log; klist shows expiry |
Message trace (KDC on port 88; UDP for small messages, TCP for large)
- AS-REQ → KDC:
alice@EXAMPLE.COM, PA-ENC-TIMESTAMP. - AS-REP ← TGT (encrypted with
krbtgt/EXAMPLE.COM) + TGT session key (encrypted with Alice's key). - TGS-REQ → KDC: TGT + authenticator (TGT session key) + SPN.
- TGS-REP ← service ticket (encrypted with web01's key) + service session key (encrypted with TGT session key).
- AP-REQ → web01: ticket + authenticator (service session key).
- AP-REP ← web01 (optional): timestamp + subkey (service session key).
Worked check
Alice authenticates at 09:00 and gets a TGT with a 10 h lifetime: it expires at 19:00 and is renewable until 09:00 seven days later. At 09:05 she asks for HTTP/web01.example.com; the KDC sets the service ticket's endtime to the minimum of her requested lifetime, the TGT's remaining life, and web01's max_life. Here 19:00, capped by the TGT. At 09:06 she sends the AP-REQ and web01's clock reads 09:08: a 120 s difference, inside the 300 s skew, so it accepts. Had web01 read 09:20, the 840 s gap exceeds skew and it returns KRB_AP_ERR_SKEW; the fix is NTP, not a larger skew.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.