On this page
One service account can quietly hold the right to act as almost anyone in your domain. Kerberos delegation is the feature that grants it, and it is configured with a tick box most administrators set once, years ago, to make a web application talk to a file server.
When we test Active Directory, delegation settings are among the first things we read, because they turn "we compromised one service" into "we can act as a Domain Admin on another server". This post explains how the three kinds of delegation work at protocol level, then walks through a lab we built: a small domain with typical delegation settings, the delegated ticket we obtained for a Domain Admin, the fixes we tested (one of which did not behave as expected), the read-only audit script we use, and a detection we tuned against the domain controller's real audit log.
How Kerberos delegation works, and the assumption that breaks
A web application that reads files on the user's behalf needs to reach the file server as that user. Kerberos delegation solves this. There are three variants, each stored in a different place in the directory:
| Type | Where it is set | What the service can do |
|---|---|---|
| Unconstrained | TRUSTED_FOR_DELEGATION (0x80000) in the service account's userAccountControl | Users' full ticket-granting tickets (TGTs) are sent to the service. It can act as them to any service. |
| Constrained | msDS-AllowedToDelegateTo on the service account (a list of SPNs) | Act as a user only to the listed services. |
| Constrained with protocol transition | The list above plus TRUSTED_TO_AUTH_FOR_DELEGATION (0x1000000) | Act as any user to the listed services, even if the user never authenticated to it with Kerberos. |
| Resource-based (RBCD) | msDS-AllowedToActOnBehalfOfOtherIdentity on the target (a security descriptor) | The target lists which accounts may delegate to it. |
The flag values come from Microsoft's userAccountControl reference.
The assumption that breaks is "constrained means safe". Constrained delegation limits where the service can go. With protocol transition it does not limit who the service can be. The list of targets looks short and harmless in the console. The list of users it applies to is everyone who is not explicitly protected.
Root cause: S4U2Self and the forwardable flag
Constrained delegation uses two Kerberos extensions defined in MS-SFU:
- S4U2Self. The service asks the KDC (the domain controller's Kerberos service) for a ticket to itself, on behalf of a named user. No password or ticket from that user is involved. The service just names them.
- S4U2Proxy. The service presents that ticket as evidence and asks for a ticket to the back-end SPN, still as the user.
The KDC accepts the evidence ticket in step 2 only if it carries the forwardable flag. Whether it does is decided in step 1. The KDC sets it when the service account has protocol transition enabled and the named user is not marked "Account is sensitive and cannot be delegated" (NOT_DELEGATED, 0x100000). That single flag in one ticket is the whole security boundary. Everything we tested below comes back to it.
So the real question for any constrained-delegation account is: if someone obtains this account's key (from a config file, a memory dump, or by cracking a weak service password), which users can they become, and on which servers?
The lab and the delegated ticket
We built a small domain, lab.example.com, on a Samba 4.19 Active Directory domain controller in our sandbox. It holds two Domain Admins (alice, bob), a helpdesk user, and these delegation settings, all common in the networks we test:
APP01$: unconstrained delegation (left over from an old application).svc-web: constrained delegation tocifs/files01.lab.example.com, with protocol transition.svc-report: constrained delegation tohttp/intranet01.lab.example.com.INTRANET01$: RBCD allowingWS-0042$.
We exported the key of svc-web to a keytab, the position an attacker is in after compromising the web server. We then used MIT Kerberos's standard kvno tool, which supports S4U, to ask for a ticket to the file server as alice. We show the result, not a recipe:
$ klist -f -eDefault principal: [email protected] Valid starting Expires Service principal11/19/26 04:12:55 11/19/26 14:12:55 [email protected] for client [email protected], renew until 11/20/26 04:12:55, Flags: FRAT Etype (skey, tkt): aes256-cts-hmac-sha1-96, DEPRECATED:arcfour-hmac11/19/26 04:12:55 11/19/26 14:12:55 cifs/[email protected] for client [email protected], renew until 11/20/26 04:12:55, Flags: FRAT Etype (skey, tkt): aes256-cts-hmac-sha1-96, DEPRECATED:arcfour-hmac[!] HIGH: a service ticket to the file server as a Domain Admin, without alice's password or any sign-in by herTwo things to read in that output. The first ticket is the S4U2Self evidence ticket, and its flags start with F: forwardable. The second is the ticket the file server will accept as alice. The file server cannot tell this apart from alice really connecting through the web application.
The second detail is arcfour-hmac (RC4). Neither svc-web nor the file server's account had msDS-SupportedEncryptionTypes set, so the KDC encrypted their tickets with RC4. That is weaker against offline cracking and is worth fixing at the same time.
Testing the fixes, and the one that surprised us
We tested two fixes. On alice we set "Account is sensitive and cannot be delegated". On bob we only added him to the Protected Users group. Microsoft documents that Protected Users members cannot "delegate with unconstrained or constrained delegation". Then we repeated the same request for both, plus an ordinary user:
# for_user=alice (marked sensitive)kvno: KDC can't fulfill requested option cifs/[email protected]: constrained delegation failed# for_user=bob (Protected Users only)cifs/[email protected]: kvno = 2, keytab entry valid# for_user=helpdesk1cifs/[email protected]: kvno = 2, keytab entry valid $ klist -f | grep -A1 "svc-web@"11/19/26 04:13:14 11/19/26 14:13:14 [email protected] for client [email protected], renew until 11/20/26 04:13:14, Flags: RAT11/19/26 04:13:14 11/19/26 14:13:14 [email protected] for client [email protected], renew until 11/20/26 04:13:14, Flags: FRAT[+] alice: S4U2Self ticket issued WITHOUT the forwardable flag, so S4U2Proxy is refused[!] bob: still delegable on this KDC despite Protected Users membershipThe sensitive flag worked exactly as the protocol says. The S4U2Self ticket for alice still came back, but without F, and the KDC refused the next step. You can see the root cause in a single flag.
The Protected Users result was the surprise. On our Samba 4.19 KDC, membership alone did not stop delegation for bob. Microsoft's documentation says Windows Server domain controllers at the 2012 R2 functional level or later do enforce it, and we did not have a Windows DC in this lab to confirm that. The lesson we took is not "Protected Users is broken". It is that a control you have not tested on your domain controllers is a control you are assuming. The sensitive flag is checked in the ticket itself, works on every KDC we have seen, and costs nothing. So we set both: Protected Users for the wider protections, and the sensitive flag for delegation.
One more limit applies to both: the built-in Administrator account (RID 500) is exempt from authentication policies. Mark it sensitive explicitly, and do not use it day to day.
Auditing every delegation setting
Delegation is invisible in most admin consoles unless you open each account. We wrote a short, read-only Python script (using ldap3) that any authenticated domain user can run. That matters: an attacker with one ordinary account can read all of this too. It uses LDAP's bitwise matching rule (1.2.840.113556.1.4.803) to query flags, and a small parser for the RBCD security descriptor:
UF_TRUSTED_FOR_DELEG = 0x00080000 # unconstrained
UF_NOT_DELEGATED = 0x00100000 # "sensitive and cannot be delegated"
UF_T2A4D = 0x01000000 # protocol transition
MATCH = "1.2.840.113556.1.4.803" # LDAP bitwise-AND matching rule
# Unconstrained delegation, excluding domain controllers (SERVER_TRUST_ACCOUNT 0x2000)
q(f"(&(userAccountControl:{MATCH}:={UF_TRUSTED_FOR_DELEG})"
f"(!(userAccountControl:{MATCH}:=8192)))", ["sAMAccountName"])
def dacl_sids(sd):
"""RBCD is stored as a self-relative security descriptor. Return the SIDs of its allow ACEs."""
off_dacl = struct.unpack_from("<I", sd, 16)[0]
_, _, _, ace_count, _ = struct.unpack_from("<BBHHH", sd, off_dacl)
pos, out = off_dacl + 8, []
for _ in range(ace_count):
ace_type, _, ace_size = struct.unpack_from("<BBH", sd, pos)
if ace_type == 0x00: # ACCESS_ALLOWED_ACE: header, mask, SID
out.append(sid_to_str(sd[pos + 8:pos + ace_size]))
pos += ace_size
return out
What failed first
Our first version found privileged accounts with (adminCount=1), the usual shortcut. It reported only Administrator. alice and bob were missing, although both were in Domain Admins. adminCount is set by a background process (SDProp) on Windows, so newly added admins can lack it, and it also stays set on people who have left those groups. We replaced it with a transitive membership query (memberOf:1.2.840.113556.1.4.1941:=CN=Domain Admins,…) for Domain Admins, Enterprise Admins, Schema Admins and Administrators, and kept adminCount=1 as an extra signal. The second run:
$ python3 audit_delegation.py dc01.lab.example.com [email protected] '********' 'DC=lab,DC=example,DC=com'# 1. Unconstrained delegation (excluding domain controllers)[!] HIGH APP01$: any user who authenticates to it leaves a usable TGT behind# 2. Constrained delegation (msDS-AllowedToDelegateTo)[!] HIGH svc-report: any protocol (S4U2Self + S4U2Proxy) -> http/intranet01.lab.example.com WARN svc-report: msDS-SupportedEncryptionTypes not set, KDC may issue RC4 tickets[!] HIGH svc-web: any protocol (S4U2Self + S4U2Proxy) -> cifs/files01.lab.example.com WARN svc-web: msDS-SupportedEncryptionTypes not set, KDC may issue RC4 tickets# 3. Resource-based constrained delegation (msDS-AllowedToActOnBehalfOfOtherIdentity)MEDIUM INTRANET01$: accepts delegated tickets from WS-0042$# 4. Privileged accounts that can still be delegated WARN bob: Protected Users only, not marked sensitive (verify on your DCs)[!] HIGH Administrator: privileged and delegable[+] OK alice: marked sensitive, cannot be delegated# 5. Who can create computer accountsMEDIUM ms-DS-MachineAccountQuota = 10ms-DS-MachineAccountQuota is in the output because it is the default (10) on Windows too: any authenticated user can join up to ten computers to the domain. A computer account an attacker creates is an account with a key they control. Combined with write access to a server's RBCD attribute, it is the classic path from "can edit one computer object" to "can act as any non-sensitive user on that server".
Detecting changes to delegation
Most delegation abuse starts with a change: someone turns on a flag, adds an SPN to a list, or writes an RBCD descriptor. Those changes are rare in a healthy domain, which makes them a good alert.
To test this, we enabled Samba's directory-change audit log (dsdb_json_audit, see Samba's audit logging guide) and replayed a normal admin day over LDAPS: an unconstrained server disabled and re-enabled for patching, a workstation disabled and re-enabled, a description edit, and a service account's flags saved unchanged. Then three risky changes: unconstrained delegation turned on for INTRANET01$, svc-report allowed to delegate to ldap/dc01 (LDAP on the domain controller), and helpdesk1 trying to write RBCD on FILES01. The last one is what an attacker with a delegated helpdesk right would try. Our Samba 4.19 DC refused that write over LDAP (even for a Domain Admin, it only allows that attribute to be changed by the system itself). Windows allows it for anyone with write access to the attribute. Either way, the attempt is logged:
{"timestamp": "2026-11-19T04:15:48.291056+0000", "type": "dsdbChange", "dsdbChange": {"status": "Constraint violation", "operation": "Modify", "remoteAddress": "ipv4:127.0.0.1:43595", "userSid": "S-1-5-21-3783222890-2319530956-3933174240-1111", "dn": "CN=FILES01,CN=Computers,DC=lab,DC=example,DC=com", "attributes": {"msDS-AllowedToActOnBehalfOfOtherIdentity": {"actions": [{"action": "replace", "values": [{"base64": true, "value": "AQAEgBQAAAAAAAAAAAAAACQA…"}]}]}}}}Our first rule alerted on any write to userAccountControl or either delegation attribute. The tuned rule changes two things. For userAccountControl, a "replace" in the log carries only the new value, so the rule compares it with a nightly baseline snapshot and fires only when a delegation bit goes from 0 to 1. For the two delegation attributes, it alerts on every attempt, including refused ones, and raises severity when the writer is not a tier-0 admin or the target is a domain controller service:
for name in attrs.keys() & DELEG_ATTRS: # msDS-AllowedToDelegateTo, ...ActOnBehalfOf...
sev = "HIGH" if (actor not in TIER0 and e["statusCode"] != 0) or "ldap/" in vals else "MEDIUM"
out.append((sev, e["timestamp"], dn, f"{name} by {actor} -> {e['status']}"))
if "userAccountControl" in attrs and e["statusCode"] == 0:
new = int(attrs["userAccountControl"]["actions"][-1]["values"][0]["value"])
old = state.get(dn, 0) # seeded from the nightly snapshot
for bit, label in DELEG_BITS.items(): # 0x80000 and 0x1000000
if new & bit and not old & bit:
out.append(("HIGH", e["timestamp"], dn, f"{label} newly set by {actor}"))
state[dn] = new
$ python3 detect_delegation_changes.py dsdb_audit.jsonl baseline.json# 9 directory changes in window# v1 naive rule: 8 alerts 04:15:48 CN=APP01 userAccountControl 04:15:48 CN=APP01 userAccountControl 04:15:48 CN=WS-0042 userAccountControl 04:15:48 CN=WS-0042 userAccountControl 04:15:48 CN=svc-report userAccountControl 04:15:48 CN=INTRANET01 userAccountControl 04:15:48 CN=svc-report msDS-AllowedToDelegateTo 04:15:48 CN=FILES01 msDS-AllowedToActOnBehalfOfOtherIdentity# v2 tuned rule: 3 alerts[!] HIGH 04:15:48 CN=INTRANET01: TRUSTED_FOR_DELEGATION (unconstrained) newly set by S-1-5-21-…-500[!] HIGH 04:15:48 CN=svc-report: msDS-AllowedToDelegateTo add by S-1-5-21-…-500 -> Success ['ldap/dc01.lab.example.com'][!] HIGH 04:15:48 CN=FILES01: msDS-AllowedToActOnBehalfOfOtherIdentity replace by S-1-5-21-…-1111 -> Constraint violationThe naive rule raised eight alerts, five of them false positives: the two maintenance toggles on APP01$ (already unconstrained, so the bit was present in the new value), the two on the workstation, and the unchanged re-save on svc-report. The tuned rule raised three, all real, and none of the benign changes. It is a small data set, so treat that as a sanity check of the logic, not a false-positive rate.
On Windows, the same logic applies to event 5136 ("a directory service object was modified"), which needs "Audit Directory Service Changes" and a SACL on the objects. The attribute names are the same. We did not have Microsoft Sentinel in this lab, so the query below is the same logic translated to KQL and is untested there:
SecurityEvent
| where EventID == 5136
| extend Attr = extract(@"<Data Name=""AttributeLDAPDisplayName"">([^<]+)<", 1, EventData),
Value = extract(@"<Data Name=""AttributeValue"">([^<]*)<", 1, EventData),
ObjectDN = extract(@"<Data Name=""ObjectDN"">([^<]+)<", 1, EventData)
| where Attr in ("msDS-AllowedToDelegateTo", "msDS-AllowedToActOnBehalfOfOtherIdentity")
or (Attr == "userAccountControl"
and (binary_and(tolong(Value), 0x80000) != 0 or binary_and(tolong(Value), 0x1000000) != 0))
// then drop UAC rows where the bit was already set in your baseline (same idea as our v2)
For use rather than configuration, event 4769 (a service ticket was requested) has a "Transited Services" field that is filled in for S4U2Proxy requests. A delegated ticket for a privileged account is worth an alert on its own, because once those accounts are marked sensitive it should never happen.
Remediation
The changes we made in the lab with samba-tool, written as the Windows PowerShell equivalents (ActiveDirectory module):
# Privileged accounts: block delegation in the ticket itself
+ Get-ADGroupMember "Domain Admins" -Recursive | Set-ADAccountControl -AccountNotDelegated $true
+ Set-ADAccountControl -Identity Administrator -AccountNotDelegated $true
# Unconstrained delegation: domain controllers only
- APP01$ TrustedForDelegation = True
+ Set-ADAccountControl -Identity 'APP01$' -TrustedForDelegation $false
# Constrained delegation: Kerberos only unless the app truly needs protocol transition
- svc-web TrustedToAuthForDelegation = True
+ Set-ADAccountControl -Identity svc-web -TrustedToAuthForDelegation $false
# Service accounts that delegate: AES only, long random passwords (or gMSA)
+ Set-ADUser svc-web -KerberosEncryptionType AES128,AES256
# Ordinary users should not create computer accounts
- ms-DS-MachineAccountQuota = 10
+ Set-ADDomain -Identity lab.example.com -Replace @{"ms-DS-MachineAccountQuota"="0"}
Before you remove protocol transition, check with the application owner. Some front ends (for example, ones that authenticate users with forms or certificates) genuinely need it. In that case, keep the target list as short as possible, never include a domain controller SPN, and make sure every privileged account is marked sensitive, because that is now the only thing stopping the service from becoming them.
Checklist
- List every account with unconstrained delegation that is not a domain controller, and remove it.
- List every
msDS-AllowedToDelegateToentry, which ones use protocol transition, and why. - Read every RBCD descriptor and check who can write that attribute on servers.
- Mark all privileged accounts, including the built-in Administrator, as sensitive. Then test one with a real S4U request.
- Set
ms-DS-MachineAccountQuotato 0 and delegate computer joins to a named group. - Alert on changes to the three delegation settings, and on S4U2Proxy tickets for privileged accounts.
When we run an internal penetration test, this audit is part of the first day, and every finding comes with the specific account to change and a test that proves the change worked. If you are deciding what kind of exercise you need, red teaming or penetration testing explains the difference. For another Windows authentication weakness we covered recently, see our Outlook NTLM brief.
Tooling and references
- Our lab scripts:
audit_delegation.py(read-only LDAP audit),snapshot.py(nightlyuserAccountControlbaseline) anddetect_delegation_changes.py(the v1 and v2 rules), shown in part above. Lab: Samba 4.19.5 AD DC, MIT Kerberos client tools, Python withldap3. - MS-SFU: Service for User and Constrained Delegation Protocol, Microsoft.
- Kerberos constrained delegation overview, Microsoft.
- Protected Users security group, Microsoft.
- userAccountControl flags, Microsoft.
- Event 5136 and event 4769, Microsoft.
- MITRE ATT&CK T1558: Steal or Forge Kerberos Tickets.
- Setting up audit logging, Samba wiki.
Written by
Muaaz Ahmad
Penetration Tester, FutaqSec