Jamal Darbo// Security PortfolioPortfolio v1
Portfolio Blog
Back to blog

Identity & Access

How a TGT becomes a service ticket

What happens inside the TGS exchange, from protecting the request and applying ticket limits to checking the reply and reusing cached credentials.

Kerberos series: view the reading order

A cybernetic Kerberos service ticket for TERMSRV/rdp01.lab.example

The phrase “use a TGT to request a service ticket” compresses a significant part of Kerberos into a single sentence. It tells us the input and the result, but leaves several questions unanswered. How does the client describe what it wants? How does the KDC know that the request has not been changed? Which properties of the existing TGT carry forward, and which decisions must the KDC make again?

These questions become important once we move beyond recognizing the messages and start examining the decisions behind them. In this article, I want to do exactly that, and follow an ordinary Ticket-Granting Service exchange, using RFC 4120, section 3.3 as the starting point.

Imagine Jamal (of course) connecting to rdp01.lab.example. His computer already has a valid TGT and its associated session key. The destination service is identified as TERMSRV/rdp01.lab.example, and both the client and server belong to the same realm. This keeps the discussion focused on requesting an ordinary service ticket, because cross-realm authentication and delegation introduce additional processing.

One clarification is useful before following the exchange: the TGT remains a TGT. The KDC issues a separate credential for the requested service. Thinking of the process as new issuance helps us ask the right question: what must the KDC establish before it can create that credential?

Building a request the KDC can trust

Before sending anything, the client can check whether it already holds suitable credentials for the destination. A credential cache allows tickets to be reused, so opening another connection does not necessarily produce another TGS exchange. For our example, assume Jamal’s computer has no usable ticket for this RDP service and therefore needs to request one. This distinction matters when following the protocol: the sequence begins because credentials are needed, rather than because every application must contact the KDC.

The client constructs a KRB_TGS_REQ. Its requested body describes more than the destination: it includes the service name and realm, requested ticket options, a requested expiration time, acceptable session-key encryption types, and a nonce (random number). Together, these fields describe the credential the client wants to obtain. The client also prepares an authenticator and combines it with the existing TGT in an embedded AP-REQ. That authentication structure is carried in a PA-TGS-REQ entry in the message’s padata field.

The KDC needs to know that the authentication information belongs to the request it received. Imagine Jamal’s computer asking for a ticket to the RDP server, while someone on the network changes the requested destination. The proof accompanying the request should not remain valid for whatever destination an attacker chooses.

To prevent this, the client calculates a cryptographic checksum over the request body and includes it inside the authenticator. You can think of this checksum as a fingerprint of the request’s contents. The authenticator is then encrypted using the TGT session key, protecting the checksum along with the other information inside it.

When the KDC receives the message, it checks whether the protected checksum matches the request body. Changing the service name, requested expiration time, or another covered field breaks that match. The proof therefore belongs to a particular request, including its parameters. RFC 4120 specifies this connection between the authenticator and the request body in section 5.2.7.1.

A very important detail is that information can be readable while still being protected against modification. In the basic exchange described here, the request body does not have to be encrypted for the KDC to detect that it was changed. The protected checksum provides the connection needed to verify its integrity.

What the KDC checks before issuing the ticket

The KDC begins by processing the TGT accompanying the request. It uses the appropriate key to decrypt the ticket and obtain the information inside, including the client identity and the TGT session key. That session key allows it to decrypt and validate the authenticator.

Several checks work together here. The presented ticket must be acceptable for the operation, the authenticator must be valid for that ticket, and its checksum must match the request body. If those checks fail, the KDC cannot proceed with ordinary ticket issuance.

For our example, the identity established through these credentials is Jamal. His computer can request a ticket for the RDP service, but it cannot simply choose a different user for the resulting ticket. In this ordinary exchange, the KDC takes the client identity from the authenticated ticket it received.

However, a valid request does not automatically mean that everything the client asks for will be granted (authentication vs authorization, remember). The KDC also evaluates the requested ticket options and applicable policy. The request describes what the client wants, and the KDC decides what it can issue.

For example, a client might request a forwarded ticket. That operation requires the existing ticket to permit forwarding through its FORWARDABLE flag. Adding an option to the request cannot create permission that the supporting credentials do not provide. The destination service can also have policy restrictions that affect whether the request is accepted.

Ticket lifetime follows the same principle. Suppose Jamal’s TGT expires at 17:00, and at 16:50 his computer requests a service ticket valid until 20:00. For this ordinary request, the new ticket cannot outlast the TGT supporting it. Other lifetime limits may shorten it further. Requesting a later expiration does not extend the existing TGT’s authority.

A ticket requested at 16:50 until 20:00 is limited by the TGT expiration at 17:00
The requested lifetime cannot extend beyond the TGT’s expiration.

The KDC must also choose a suitable encryption type for the new client-service session key. The client supplies a list of acceptable types, but the choice must also work for the destination and satisfy the KDC’s configuration. This is why the client’s preferred algorithm is only one part of the decision. Also, the encryption type of the new session key should not be confused with the encryption type used to protect the ticket itself. These are separate cryptographic choices.

Once the relevant checks succeed, the KDC creates the new ticket and its associated session key. Some information comes from the existing credentials, while other information is specific to the new ticket. The client identity remains Jamal, but the destination is now the RDP service and the new session key is intended for communication between that client and service.

The original authentication time is also carried forward. If Jamal authenticated at 08:00 and requested this service ticket at 10:30, those times describe different events. Issuing a new service ticket does not mean he supplied his original authentication proof again at 10:30. The ticket preserver that distinction between the earlier authentication and the later issuance.

In Active Directory, the KDC also processes the authorization information associated with the ticket. For example, it creates the service ticket’s PAC (Privilege Attribute Certificate) using relevant information from the TGT’s PAC and generates new signatures. This means the new ticket is more than a copy of the old one with a different service name.

How the client knows it received the right response

The KDC returns the result in a KRB_TGS_REP. As discussed in the earlier article about ticket encryption, the response carries the service ticket and separately protected information for the client, including its copy of the new session key.

There is one detail worth mentioning here. The client may have included a subkey in its request’s authenticator. In the basic TGS exchange, the KDC uses that subkey to protect the the client’s reply information when one was supplied. Otherwise, it uses the TGT session key. This reply-protection key is separate from the newly issued client-service session key.

After decrypting its part of the response, the client still needs to check that the answer matches its request. This is where the nonce becomes useful. The client includes this number when constructing the request, and the KDC returns the same value inside the protected reply. The client compares the two values to help establish that the response belong to the exchange it started.

The client also checks the returned identity and service information, along with relevant ticket times. It should not accept an unrelated ticket simply because the response could be decrypted.

The two protected parts of a TGS reply, their keys, and the checks performed by the client
One reply, two protected parts, and a shared session key.

Imagine Jamal’s computer requesting credentials for two services around the same time. Both responses could be legitimate, but the client must still associate each response with the correct request. The returned nonce and service information help it make that distinction.

The checks therefore work in both directions. The KDC verifies the request before issuing credentials, and the client verifies the response before accepting them. Successful decryption is part of that process, but the participants also need to check that the information makes sense in the exchange they are performing.

Once the response has been accepted, Jamal’s computer stores the service credentials in its cache. It can then use them when authenticating to the RDP service, and potentially reuse them for later authentication while they remain suitable and valid. The original TGT remains available for requesting other tickets. Credential caching is what allows these exchanges to happen when needed, without contacting the KDC for every subsequent connection.

Jamal reuses cached RDP credentials with a fresh authenticator and keeps the TGT for requesting other service tickets
Caching avoids a new ticket request for every connection.

By the time Jamal’s computer connects to the RDP server, the TGS exchange has already done its work. The computer holds credentials for that service, together with the session key and the information needed to use them. His original TGT remains available if another application needs a different ticket.

From Jamal’s perspective, he simply opened Remote Desktop. But behind that action, Kerberos used an existing authentication to prepare credentials for a specific destination. That is what makes the TGS exchange central to single sign-on: one authentication can support access to multiple services, while each ticket request still passes through the KDC’s checks. I hope you learned something new and useful about Kerberos.

Sources

https://www.rfc-editor.org/rfc/rfc4120.html#section-3.3

https://web.mit.edu/kerberos/krb5-latest/doc/basic/ccache_def.html

https://github.com/krb5/krb5/blob/master/src/lib/krb5/krb/send_tgs.c

https://www.rfc-editor.org/rfc/rfc4120.html#section-5.2.7.1

https://www.rfc-editor.org/rfc/rfc4120.html#section-3.3.2

https://github.com/krb5/krb5/blob/master/src/kdc/kdc_util.c

https://learn.microsoft.com/en-us/windows/win32/secauthn/ticket-granting-service-exchange

https://github.com/krb5/krb5/blob/master/src/kdc/do_tgs_req.c

https://github.com/krb5/krb5/blob/master/src/kdc/tgs_policy.c

https://www.rfc-editor.org/rfc/rfc4120.html#section-3.3.3

https://web.mit.edu/kerberos/krb5-latest/doc/admin/enctypes.html

https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-kile/2e5dcf34-4b51-44a0-b45a-277ed616ca39

https://github.com/krb5/krb5/blob/master/src/lib/krb5/krb/gc_via_tkt.c