← Lab /Security & privacy

Active ADFS signing keys can be extracted from Machine DPAPI after manual certificate rotation

When AutoCertificateRollover is disabled and certificates are manually rotated, the active ADFS signing private key remains accessible via the machine-scoped DPAPI store, allowing attackers to forge valid SAML tokens.

Security & privacy Mandiant / GTIG 7 Jul 2026 Attack Real-world evidence

Published as “The ‘Ghost’ in the Database: Recovering Active ADFS Signing Keys via Machine DPAPI”

Why it matters

Compromise of the machine-DPAPI protected signing key allows unrestricted creation of valid SAML tokens, effectively bypassing MFA and other identity controls across all federated services.

Summary

Mandiant observed that disabling AutoCertificateRollover and performing a manual ADFS certificate rotation leaves a stale "ghost" entry in the WID database while the new signing key is stored in the machine-scoped DPAPI store. Using SharpDPAPI they recovered the active private key from C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\ and used it to forge a SAML assertion that granted Global Administrator access to Microsoft 365. The attack works without touching LSASS or the live ADFS process, reducing typical detection coverage. Evidence is based on a single red-team engagement on an on-prem ADFS host.

What they found 1

  1. Recovered machine-DPAPI key enables forging of a Global Administrator SAML assertion accepted by Entra ID.

    “The recovered key was used to forge a SAML assertion impersonating a Global Administrator identity, which Entra ID accepted as a valid authentication assertion, resulting in authenticated access at Global Administrator privilege level within the federated Microsoft 365 tenant.”

Caveats 2

  • All subsequent offline decryption attempts similarly failed, consistent with the masterkey not being recoverable through the evaluated on-disk recovery approach in this environment-though this observation is bounded to the assessed environment and does not represent a universal architectural property of all ADFS deployments.
  • SharpDPAPI /machine enumeration in the assessed environment confirmed that the active machine key material resided under this path, while the CNG Crypto\Keys store was not observed in use in the assessed environment.

What’s new here 4

  • Identifies configuration drift where manual certificate rotation leaves a stale database entry.
  • Demonstrates that the active ADFS signing key is stored in Machine DPAPI and can be recovered by a privileged local process.
  • Shows end-to-end key recovery and SAML token forgery without LSASS memory access.
  • Provides concrete detection and mitigation guidance for the identified attack path.