Skip to main content
Active Directory Federation Services (ADFS) provides Single Sign-On (SSO) to external applications via SAML 2.0 and WS-Federation. The token-signing certificate is the crown jewel: its private key allows forging SAML assertions for any user against any relying party, surviving password resets and account disables.

How ADFS Works

Key components:
  • 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. If ExtranetLockoutEnabled is false, the threshold is effectively unlimited.
Keep spraying intervals above 30 minutes per user. Monitor for 342 or 391 ADFS event IDs in the ADFS event log that indicate lockout activity.

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’s ImmutableID (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.
If you can write to the mapped attribute on your own account, you control the claim.
Overly broad passthrough rules: Rules of the form 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 a NotOnOrAfter 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

A successful replay returns an authenticated session without any credential input.

Why SPs Are Vulnerable

  • No AssertionID cache 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 InResponseTo check)

Mitigations


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