How ADFS Works
- Federation Server: the ADFS service, typically at
https://adfs.$DOMAIN/adfs/ls - Token-signing certificate: private key signs every outbound assertion. Stored in the ADFS configuration database, encrypted via DPAPI under the ADFS service account.
- Relying Party Trusts (RPs): the service providers (Office 365, Salesforce, internal apps) that trust this ADFS instance
- Claim rules: transforms AD attributes (UPN, groups, extensionAttributes) into SAML claims sent to the RP
Enumeration
Unauthenticated Discovery
Authenticated Enumeration (PowerShell on ADFS server)
ADFSDump
ADFSDump extracts the full ADFS configuration including the token-signing private key. Run on the ADFS server with local admin, or supply the ADFS service account credentials.Credential-Based Attacks
ADFS exposes forms-based authentication at/adfs/ls. Crucially, ADFS maintains its own lockout policy separate from AD’s fine-grained password policy. Many deployments have no extranet lockout configured, making spraying safe at low volume.
User Enumeration
ADFS returns distinct responses for valid versus invalid usernames, enabling unauthenticated enumeration before any authentication attempt.Password Spraying
Check lockout settings before spraying. IfExtranetLockoutEnabled is false, the threshold is effectively unlimited.
Golden SAML
The most impactful ADFS attack. Once you possess the token-signing private key, you can forge SAML assertions for any user, for any relying party, indefinitely. The forgery is cryptographically valid and indistinguishable from a legitimate assertion. Why it is dangerous:- No password required for the impersonated user
- Survives password resets, account disables, MFA enrollment changes
- Valid against every SP trusting this ADFS until the cert is rotated
- Leaves no trace in AD (no logon event against the impersonated account)
Step 1: Extract the Token-Signing Private Key
The private key is stored in the ADFS configuration database (Windows Internal Database or SQL Server), encrypted with DPAPI under the ADFS service account’s master key.Step 2: Identify Target RP and Claims
Step 3: Get the Target User’s ImmutableID (Azure AD / O365)
For Office 365 / Azure AD federated domains, the assertion NameID must be the user’sImmutableID (base64-encoded objectGUID).
Step 4: Forge and Submit the Assertion
Claim Manipulation
ADFS issues assertions containing claims that SPs use to make authorization decisions. If the SP trusts claims without re-validating them against the directory, controlling the claim value equals controlling access.Attack Surface
AD attribute passthrough: Claim rules often map AD attributes directly to SAML claims.c:[] => issue(claim = c); pass through every attribute. If the SP grants access based on any of these and you control an attribute, it is a direct escalation path.
With Golden SAML (no AD write needed): Forge the assertion with arbitrary claim values directly in the signed XML.
Enumeration
SAML Replay Attack
A valid SAML assertion intercepted in transit can be reused within its validity window (typically 1 to 5 minutes). Assertions carry aNotOnOrAfter timestamp and a unique AssertionID. If the SP does not cache used AssertionID values to prevent reuse, the assertion can be replayed to establish a second session.
Interception Methods
- MitM on the browser redirect (POST binding: assertion is in the POST body, visible in plaintext over HTTP)
- XSS on the SP or a co-hosted application that leaks the POST body
- Browser history, proxy logs, or referrer headers containing the base64 assertion
- Compromised reverse proxy or WAF sitting in front of the SP
Replay Procedure
Why SPs Are Vulnerable
- No
AssertionIDcache maintained server-side - Validity window wider than 2 minutes (some apps set 10 to 30 minutes)
- POST binding used without strict transport security (assertion visible in clear)
- SP accepts redirect binding without verifying the assertion was intended for it (missing
InResponseTocheck)
Mitigations
| Control | Mitigates |
|---|---|
Enable ADFS Extranet Lockout (ExtranetLockoutEnabled) | Credential spray |
| Rotate token-signing certificate | Golden SAML with extracted key |
| Enable ADFS auditing (Event 1200, 1202, 1203, 1204) | Token issuance visibility |
| Monitor DPAPI access on ADFS service account | Key extraction detection |
| SP-side AssertionID cache | Replay attacks |
| Restrict claim passthrough rules | Claim manipulation |
| Enforce short assertion validity windows (< 2 min) | Replay attacks |
| Use Azure AD Smart Lockout for federated tenants | Cloud-side spray detection |
References
ADFSDump
Mandiant tool to extract ADFS token-signing certificates and relying party configuration from a compromised ADFS server
shimit (Golden SAML)
CyberArk tool to forge SAML assertions using a stolen token-signing private key
Golden SAML: All Paths Lead to Rome
CyberArk’s original Golden SAML research
AADInternals
PowerShell toolkit for Azure AD and Office 365 attacks including Golden SAML for federated domains