Kerberos
Last updated
Was this helpful?
Last updated
Was this helpful?
A Kerberos realm is a logical group of networked computers that share a common authentication database. The authentication database is used to store the Kerberos tickets that are issued to users and services when they authenticate to the network.
In a Kerberos environment, each networked computer is a member of a realm. The realm is responsible for authenticating users and services and for issuing and managing Kerberos tickets.
A Kerberos realm can be implemented on any type of network, including networks that are not running Windows. In fact, the Kerberos protocol was developed as an open standard and is used by many different types of operating systems and networks.
On a Windows network, a Kerberos realm is typically equivalent to a domain. Each domain in a Windows network is a member of a realm, and the domain controller is responsible for authenticating users and services and for issuing and managing Kerberos tickets.
However, on a non-Windows network, a Kerberos realm can be implemented independently of any domain structure. In this case, the Kerberos server is responsible for authenticating users and services and for issuing and managing Kerberos tickets.
The Hacker Recipes mainly covers Kerberos attacks in a Windows context, but some attacks can also be conducted in non-Windows networks.
Kerberos is an authentication protocol based on tickets. It basically works like this (simplified process):
Client asks the KDC (Key Distribution Center, usually is a domain controller) for a TGT (Ticket Granting Ticket). One of the requesting user's keys is used for pre-authentication. The TGT is provided by the Authentication Service (AS).
Client uses the TGT to ask the KDC for a ST (Service Ticket). That ticket is provided by the Ticket Granting Service (TGS).
Client uses the ST (Service Ticket) to access a service
Both tickets (TGT and ST) contain the PAC (Privilege Authentication Certificate), a set of information that the target service will read to decide if the authentication user can access the service or not (user ID, group memberships and so on). Only one very special and sensitive service account can write the PAC : krbtgt
.
A Service Ticket (ST) allows access to a specific service.
DES
Key derivated from user's password
RC4
Key == NT hash
AES128
Key derivated from user's password (with salt)
AES256
Key derivated from user's password (with salt)
Users are not the only ones whose NT hashes can be used to abuse Kerberos.
If Kerberos preauthentication is disabled for a user, it is possible to request a TGT for that specific user without knowing any credentials. When the TGT is requested, the KDC sends it along with a session key in the KRB_AS_REP
message to the requesting client. The session key being encrypted with the requested user's NT hash, it is possible to crack that session key offline in a an attempt to find the user's password. This is called ASREProasting.
If an attacker finds himself in a man-in-the-middle position, effectively capturing Kerberos messages, he could capture KRB_AS_REQ
messages and operate a similar cracking attempt.
When attackers have a foothold in the domain (i.e. valid domain credentials), they have the (intended) ability to request a service ticket (ST) for any valid SPN (ServicePrincipalName). The ST being encrypted with the service account's NT hash, when that service account's password is weak, it is then possible to crack the ST offline in a an attempt to find the password. This is called Kerberoasting. On a side note, obtaining a service ticket for a service specified by its SAN in an attempt to Kerberoast the account will only work if the service has at least one SPN.
Kerberos delegations allow services to access other services on behalf of domain users. For instance, this allows services to require access to other services' data on the authenticated user's behalf in order to pull data that only the said user is supposed to have access to.
In some situations, Kerberos delegations can be abused by attackers to operate lateral movement or privilege escalation.
Service for User to Self (S4U2self): allows a service to obtain a Service Ticket, on behalf of another user (called "principal"), to itself.
Service for User to Proxy (S4U2proxy): allows a service to obtain a Service Ticket, on behalf of a user to a different service.
U2U has nothing to do with S4U mechanisms and plays no part in delegation internals.
When requesting a service ticket, the client (cname
) specifies the service it wants to obtain access to by supplying it's sname
, which can be one of 9 types (). Shortly put, the following formats are supported:
()
If the service ticket is requested through a specific request, then neither of the conditions above will be required, the target service user can be specified by its UPN (userPrincipalName
).
(sources: and ).
The TGT is used to ask for STs. TGTs can be obtained when supplying a valid secret key. That key can be one of the following (read ).
()
Again, Microsoft has poorly implemented the zero-knowledge proof concept in Kerberos. An attacker knowing a user's NT hash could use it to ask the KDC for a TGT (if RC4 key is accepted). This is called .
A TGT is encrypted with the krbtgt
's NT hash. An attacker knowing the krbtgt
's NT hash can forge TGTs impersonating a domain admin. He can then request STs as a domain admin for any service. The attacker would have access to everything. This forged TGT is called a .
A ST is encrypted with the service account's NT hash. An attacker knowing a service account's NT hash can use it to forge a Service ticket and obtain access to that service. This forged Service ticket is called a .
, and attacks are used by attackers to obtain illegitimate tickets that can then be used to access services using Kerberos without knowing any password. This is called Pass-the-ticket.
In , the delegation will not work. Depending on the context, the vulnerability (CVE-2020-17049) can be used to try to bypass restrictions.
Kerberos delegations can be abused by attackers to obtain access to valuable assets and sometimes even escalate to domain admin privileges. Regarding and , those types of delegation rely on Kerberos extensions called S4U2Self and S4U2Proxy.
This extension can only be used by an account that has at least one SPN (except if S4U2self is combined with ).
alternatively, in the TGS-REQ
, in the pre-authentication data, the PA-PAC-OPTIONS
structure must contain a padata value with the resource-based constrained delegation bit set ().
nota bene 1: this only applies if the resource-based constrained delegation (RBCD) is actually possible and authorized in the proper AD objects attributes.
nota bene 2: Rubeus and Impacket's getST always set that bit when doing S4U2proxy.
Request contains a PA-FOR-USER
padata type structure containing the name and the realm of the user to impersonate ().
Request contains the CNAME-IN-ADDL-TKT
flag in the kdc-options
field, indicating S4U2proxy is used ().
[U2U] allows users to host secure application services on their desktop machines. [...] In the user-to-user protocol, one user acts as a server, and the other user acts as a client. ().
Request contains the ENC-TKT-IN-SKEY
flag in the kdc-options
field, indicating that the ticket for the end server is to be encrypted in the session key from the additional TGT provided ().
operate
operate an attack
retrieve and decrypt the PAC (Privileged Attribute Certificate) of any account. Could be used to obtain a .