Delegation abuse: unconstrained keeps the TGT, constrained trusts the wrong bit
Kerberos delegation lets a service act as you. Unconstrained delegation caches your TGT on the server; constrained and resource-based delegation trust attributes an attacker can often set. What CVE-2020-17049 changed, and how to find and fix delegation in your directory.
By Ahmed PingerPublished
8 min read13 views
Kerberos delegation exists so that a front-end service can act on your behalf against a back-end service. You authenticate to a web application, and the web application needs to reach a database as you, not as itself. Delegation is the mechanism that makes that work. It is also one of the most productive escalation surfaces in Active Directory, because the three flavours of it fail in three different ways, and all three end with a service impersonating a privileged user.
The one distinction to hold onto: delegation is the directory deciding that one account is allowed to obtain and use another account's authentication to a third service. Unconstrained delegation makes that decision the most dangerous way possible, by caching the user's full Ticket-Granting Ticket. Constrained and resource-based delegation try to narrow it, but they hang the decision on attributes that an attacker who controls the right object can often set.
Why the three flavours carry very different risk
Unconstrained delegation is the original and the worst. When a computer or account is trusted for unconstrained delegation, any user who authenticates to it forwards their Ticket-Granting Ticket, and the server caches that TGT in memory. A TGT is the master key to that user's identity. If an attacker compromises a server trusted for unconstrained delegation and then gets a privileged user, or a domain controller's machine account, to authenticate to it, they harvest a TGT that lets them act as that principal anywhere. Combined with a coercion technique (see the PetitPotam post) to force a domain controller to authenticate to the compromised server, this is a direct path to domain compromise.
Constrained delegation was meant to fix that by limiting an account to delegating only to a named list of services, held in msDS-AllowedToDelegateTo. The narrowing is real, but the protocol-transition variant (S4U2Self followed by S4U2Proxy) lets a compromised service request a ticket to itself as an arbitrary user and then forward it to the allowed target. If the compromised account can delegate to a sensitive service, the attacker can reach that service as any user, including a domain administrator.
Resource-based constrained delegation (RBCD) inverts the control: instead of the front-end being trusted to delegate, the back-end resource names who is allowed to delegate to it, in msDS-AllowedToActOnBehalfOfOtherIdentity. This is architecturally cleaner, but it moves the decision onto an attribute of the target object. An attacker who can write that attribute on a computer object, and who can create or control a computer account to name in it, can grant themselves delegation to that machine. The ability to create computer accounts is often available to ordinary users, because the machine account quota is not zero by default.
The CVE that anchors the constrained case: CVE-2020-17049
The real vendor anchor here is CVE-2020-17049, a security feature bypass in how the Key Distribution Center decides whether a service ticket is valid for delegation via Kerberos Constrained Delegation, published 2020-11-11 and rated CVSS 3.1 6.6 (Medium) by Microsoft (NVD's own score is 7.2, High). The NVD description is precise: "a compromised service that is configured to use KCD could tamper with a service ticket that is not valid for delegation to force the KDC to accept it." The public technique built on it is known as the Bronze Bit attack, because it turns on a single ticket flag that should have prevented the delegation.
Microsoft's fix, tracked in KB4598347, introduced the PerformTicketSignature registry control and rolled enforcement out in phases through 2021, so that the KDC signs and validates the tickets used with constrained delegation and rejects the tampered ones. The lesson that generalises: delegation security depends on the KDC correctly enforcing which tickets may be forwarded, and a flaw in that check quietly widens every constrained-delegation configuration in the domain at once. For the certificate-based escalation that often follows a delegation foothold, see the ESC1 post.
A lab you can build without Docker
One domain controller and one member server are enough to reproduce all three configurations.
- Promote a Windows Server 2022 evaluation VM (180-day ISO or VHD) to a domain controller with
Install-ADDSForest. - Join a second Windows Server evaluation VM as a member server that you will configure, in turn, for unconstrained, constrained, and resource-based delegation.
- Add a client and a couple of ordinary user accounts, including one privileged account you will use only to observe what a TGT left on an unconstrained-delegation host looks like.
The Samba AD route (samba-tool domain provision on a Linux VM) will host the directory objects and attributes, but the delegation attack surface and the security event schema below are Windows-specific, so the Windows route is the better teacher here. As with the other posts in this set, the aim is to read your own directory and logs, not to run offensive tooling; the public toolchains for delegation abuse are documented elsewhere and are not reproduced here.
Finding delegation in your own directory
Every delegation relationship in the domain is a line you should be able to justify. Enumerate all three kinds.
# Unconstrained delegation: computers and users trusted for delegation.
# TRUSTED_FOR_DELEGATION is bit 0x80000 of userAccountControl.
Get-ADObject -LDAPFilter "(userAccountControl:1.2.840.113556.1.4.803:=524288)" `
-Properties userAccountControl, servicePrincipalName |
Select-Object Name, ObjectClass
# Constrained delegation: accounts with an allowed-to-delegate-to list.
Get-ADObject -LDAPFilter "(msDS-AllowedToDelegateTo=*)" `
-Properties msDS-AllowedToDelegateTo |
Select-Object Name, msDS-AllowedToDelegateTo
# Resource-based constrained delegation: objects that name who may delegate to them.
Get-ADObject -LDAPFilter "(msDS-AllowedToActOnBehalfOfOtherIdentity=*)" `
-Properties msDS-AllowedToActOnBehalfOfOtherIdentity |
Select-Object Name
Read the first list hardest. Any computer trusted for unconstrained delegation that is not a domain controller is a standing liability, because it will cache the TGT of anyone who authenticates to it. The classic finding is an old application server that was set for unconstrained delegation years ago and forgotten.
For the RBCD list, the follow-up question is who can write msDS-AllowedToActOnBehalfOfOtherIdentity on those objects, and who can create computer accounts to name in it. Check the machine account quota:
Get-ADObject (Get-ADDomain).DistinguishedName -Properties ms-DS-MachineAccountQuota |
Select-Object ms-DS-MachineAccountQuota
If that value is not zero, ordinary users can create computer accounts, which is one of the two ingredients an RBCD attack needs.
Fixing it
Eliminate unconstrained delegation wherever it is not strictly required. For the rare service that genuinely needs it, move to constrained or resource-based delegation instead. Domain controllers are the expected exception; a member server trusted for unconstrained delegation almost never is.
Protect privileged accounts from being delegated at all. Set the "Account is sensitive and cannot be delegated" flag (the NOT_DELEGATED userAccountControl bit) on administrative accounts, or add them to the Protected Users group, whose members cannot be delegated with either unconstrained or constrained delegation. This means that even if a delegation misconfiguration exists, a domain administrator's identity cannot be forwarded through it.
Reduce the machine account quota. Setting ms-DS-MachineAccountQuota to zero removes the ability for ordinary users to create the computer accounts that RBCD and several other attacks rely on, and delegates machine creation to administrators.
Apply the CVE-2020-17049 enforcement. Install the 13 July 2021 or later updates on every domain controller. From that update the KDC enforces ticket signing, rejects the tampered tickets that the Bronze Bit technique depends on, and ignores the PerformTicketSignature registry setting, so a legacy override no longer weakens it.
Tighten who can write delegation attributes. msDS-AllowedToDelegateTo and msDS-AllowedToActOnBehalfOfOtherIdentity should be writable only by administrators. Delegated permissions that let a helpdesk tier edit computer objects can inadvertently include the write that enables RBCD.
Detecting it
Delegation changes are configuration events, and they are rare in a healthy domain, which makes them good detections.
- Event 4742, "A computer account was changed," records changes to
AllowedToDelegateToand to the delegation-related userAccountControl flags. Microsoft's own monitoring guidance for 4742 calls out watching theTrusted For DelegationandTrusted To Authenticate For Delegationflags precisely because turning them on can be an approved action, a mistake, or an attack, and you want to know which. A computer suddenly becoming trusted for unconstrained delegation is a high-signal event. - Writes to
msDS-AllowedToActOnBehalfOfOtherIdentityon a computer object indicate an RBCD relationship being created. Directory-change auditing on that attribute turns the RBCD setup step into an alert. - New computer accounts created by ordinary users, correlated with an RBCD write, is the two-step signature of the resource-based attack.
- A privileged account authenticating to a server trusted for unconstrained delegation is the moment a TGT gets cached where it can be stolen. Correlating logon events against your inventory of unconstrained-delegation hosts flags the dangerous authentications.
What to take away
Delegation is a legitimate need built on a dangerous primitive: one account using another's authentication against a third service. Unconstrained delegation caches the full TGT and should be treated as a standing compromise waiting for the right authentication to walk in, which coercion can arrange. Constrained and resource-based delegation narrow the blast radius but hang the decision on attributes, and an attacker who can write those attributes, often with a computer account they created themselves, writes their own permission. CVE-2020-17049 is the reminder that the KDC's enforcement of which tickets may be forwarded is load-bearing, and a flaw in it widens every configuration at once. Remove unconstrained delegation, mark privileged accounts as non-delegatable, set the machine account quota to zero, and audit writes to the delegation attributes. The mechanism is meant to be narrow; your job is to keep it that way.
Further reading
- NVD: CVE-2020-17049: Kerberos KDC security feature bypass in constrained delegation
- Microsoft KB4598347: Managing deployment of Kerberos S4U changes for CVE-2020-17049: PerformTicketSignature and the enforcement timeline
- Microsoft Learn: Kerberos Constrained Delegation overview: S4U2Proxy, resource-based delegation, and the security implications
- Microsoft Learn: 4742(S) A computer account was changed: AllowedToDelegateTo and delegation flag monitoring
- Microsoft Learn: Protected Users security group: members cannot be delegated
- Microsoft Learn: How to configure protected accounts: the "Account is sensitive and cannot be delegated" flag
- Microsoft Learn: ms-DS-MachineAccountQuota attribute: the quota that gates user-created computer accounts
- ASD ACSC and partners: Detecting and mitigating Active Directory compromises (September 2024): delegation among the common techniques
Was this useful?
Get the next write-up by email
New technical write-ups by email when we publish. No sales sequence, and every email has an unsubscribe link.
Prefer a feed? RSS. How we handle your address: privacy notice.
Comments
Loading comments…