Repository navigation
Token Theft and Session Revocation
Last reviewed: 2026-11-28 (provider and MITRE ATT&CK documentation only; no session, key or certificate was revoked in any real environment)
Caution
Authorized use only. Revocation commands sign users out, break integrations and, for federation certificates, can cause an outage until every relying party trusts the new certificate. Run them only in environments you administer, under an incident or change record. See LEGAL.md.
Prerequisites: Cloud identity index ยท Identity log sources
Explain how attackers reuse tokens and sessions instead of passwords, how forged SAML tokens work, and exactly what each provider's revocation mechanism does and does not cancel.
Describes the theft patterns with ATT&CK references, then gives per-provider revocation procedures from the provider's documentation, each followed by its documented limits.
When credentials or sessions are compromised, revoke them in an order that actually ends the attacker's access, and know how long residual tokens can remain valid.
- Containing an account takeover or adversary-in-the-middle phishing incident
- Responding to a leaked access key, client secret or service account key
- Suspected compromise of a federation server or SAML token-signing key
| Pattern | What is stolen | Why MFA does not stop it | ATT&CK |
|---|---|---|---|
| Adversary-in-the-middle phishing proxy | Session cookie issued after a successful sign-in | The user completed MFA; the attacker replays the resulting session | T1539 Steal Web Session Cookie |
| Refresh / access token theft from a device or app | OAuth tokens | Tokens are bearer credentials | T1528 Steal Application Access Token |
| Device code phishing | Tokens from a device authorization flow the victim completes | The victim signs in on the real page | Hunt on Entra AuthenticationProtocol = deviceCode
|
| Long-lived workload secrets | Access keys, client secrets, service account keys | No user involved | T1552 Unsecured Credentials |
| Forged SAML tokens | The IdP's token-signing private key | The attacker mints new tokens with any claims | T1606.002 SAML Tokens |
Useful Entra sign-in fields for spotting replay: IPAddress, AutonomousSystemNumber, UserAgent, SessionId, UniqueTokenIdentifier, IncomingTokenType, AuthenticationProtocol and TokenProtectionStatusDetails (SigninLogs reference). A session used from a new network shortly after an interactive sign-in elsewhere is a common lead; check non-interactive sign-ins (AADNonInteractiveUserSignInLogs) as well: Microsoft lists "A client app uses an OAuth 2.0 refresh token to get an access token" among the events recorded there. For confidential clients, the logged IP of a non-interactive sign-in is the IP of the original token issuance, not the source of the refresh request (non-interactive sign-ins).
ATT&CK T1606.002 (version 1.4) describes how an adversary with a valid SAML token-signing certificate "may forge SAML tokens with any permissions claims and lifetimes", and how an adversary with enough permissions may instead "establish a new federation trust with their own" AD FS server. The second path is a tenant change, see T1484.002 Trust Modification.
Detect:
- Entra
AuditLogsDirectoryManagement activities "Set federation settings on domain", "Set domain authentication" and "Add unverified domain" (audit activities). Any of these outside a change window deserves investigation. - ATT&CK's detection strategy for forged tokens: SAML authentications with valid signatures but no matching earlier IdP events (it names AD FS event IDs 1200 and 1202 and Kerberos 4769), and tokens with abnormal lifetimes, issuers or claims compared with baseline.
- ATT&CK mitigations M1047 and M1026: enable AD FS advanced auditing and restrict AD FS server access to privileged access workstations.
Respond (Microsoft's emergency rotation of AD FS certificates):
- Record the current on-premises and cloud token-signing thumbprints:
Get-AdfsCertificate -CertificateType token-signingandGet-EntraFederationProperty -DomainName <domain> | FL Source, SigningCertificate. - Create two new token-signing certificates. With
AutoCertificateRollovertrue:Update-ADFSCertificate -CertificateType Token-Signing -Urgent, thenUpdate-ADFSCertificate -CertificateType Token-Signing. Microsoft explains that Entra ID keeps information about the previous certificate, so without the second certificate "it might be possible for the old token-signing certificate to authenticate users". ATT&CK's M1015 gives the same advice: rotate "in rapid succession twice". - Update Entra ID:
Update-MgDomainFederationConfiguration -DomainId <domain> -InternalDomainFederationId <id>, as a Hybrid Identity Administrator. - Remove the old certificate:
Remove-ADFSCertificate -CertificateType Token-Signing -thumbprint <thumbprint>. - Revoke and replace the AD FS and Web Application Proxy TLS certificates, update federation partners, and revoke users' refresh tokens.
Microsoft warns that emergency rotation revokes the old certificate immediately and might cause an outage until all federation partners have the new certificate. It also recommends protecting token-signing keys in a hardware security module.
Revoke sign-in sessions. Graph revokeSignInSessions (POST /users/{id | userPrincipalName}/revokeSignInSessions, no request body; least-privileged permission User.RevokeSessions.All) invalidates refresh tokens and browser session cookies by resetting signInSessionsValidFromDateTime. The PowerShell equivalent is Revoke-MgUserSignInSession -UserId <id>.
Documented limits:
- "There might be a small delay of a few minutes before tokens are revoked."
- It does not revoke sessions for external users.
- Already-issued access tokens are not recalled: for apps using access tokens, the user loses access when the access token expires (revoke user access). Access tokens default to a random lifetime of 60 to 90 minutes (75 on average) (token lifetimes).
- CAE shortens this for supporting services. Critical events (account deleted or disabled, password changed or reset, MFA enabled for the user, admin revokes all refresh tokens, high user risk) are evaluated "in any tenant" without a Conditional Access policy, and are enforced by Exchange Online, SharePoint Online and Teams. Because CAE-enabled services can revoke access on these events, the access tokens they accept can live "up to 28 hours" (CAE).
- Refresh tokens expire after 90 days of inactivity by default; refresh and session lifetimes are no longer configurable through token lifetime policies (use Conditional Access sign-in frequency instead).
Prevent replay: Conditional Access token protection accepts only device-bound sign-in session tokens such as Primary Refresh Tokens. For native apps it is enforced on Exchange Online, SharePoint Online and Microsoft Teams (plus Azure Virtual Desktop and Windows 365 on Windows); browser support is in preview and limited to selected web apps that access Azure Resource Manager. Microsoft recommends starting in report-only mode and capturing both interactive and non-interactive sign-in logs.
Service principals: remove the compromised secret or certificate, then review "Add service principal credentials" events for other keys the attacker may have added.
The IAM console's Revoke active sessions action attaches the inline policy AWSRevokeOlderSessions to the role (needs iam:PutRolePolicy). It denies all actions for sessions issued before a time set about 30 seconds in the future, to allow for propagation (revoke role sessions). The manual form is:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": { "DateLessThan": { "aws:TokenIssueTime": "2026-11-28T12:00:00Z" } }
}
]
}Documented limits:
- Not available for service-linked roles or IAM Identity Center permission-set roles.
-
aws:TokenIssueTimeexists only for temporary credentials, so this does nothing to an IAM user's long-term access keys. - Resource-based policies that grant access need their own explicit deny (disable temporary credential permissions).
- Temporary credentials last 900 seconds to 36 hours (default 12 hours). Credentials from
GetFederationTokenorGetSessionTokencalled as root cannot have their permissions changed, which is one reason never to call them as root. - Alternative targets for a deny:
aws:PrincipalArn,aws:SourceIdentityoraws:userid. AWS also provides the managed policyAWSDenyAll.
Deactivate first (reversible), investigate, then delete:
# Placeholders: replace with the compromised key ID and its owner
aws iam update-access-key --access-key-id <access-key-id> --status Inactive --user-name <iam-user-name>Status values are Active, Inactive and Expired; an inactive key can be reactivated (update-access-key). Then search CloudTrail for AssumeRole, GetSessionToken and GetFederationToken calls made with the key and revoke any sessions it created, as described above. Hunt for CreateAccessKey on other users (detection aws_cloudtrail_create_access_key_for_other_user.yml).
- Add the user's Identity Center user ID to the pre-deployed deny SCP (
identitystore:userId); keep it there at least 12 hours (prerequisites). - Remove permission-set and account-access assignments.
- Disable the user in the external IdP.
- Delete the user's active session in the Identity Center console; the user immediately loses access to the AWS access portal.
- Disable the user. Doing this before step 4 prevents ending the session from the console (revoke user permissions).
AWS does not document that deleting the portal session ends role credentials already issued to the user; the SCP is what blocks them in the meantime.
Service account keys (disable and enable keys):
gcloud iam service-accounts keys disable KEY_ID \
--iam-account=SA_NAME@PROJECT_ID.iam.gserviceaccount.com \
--project=PROJECT_IDGoogle states: "Disabling a service account key does not revoke short-lived credentials that were issued based on the key." To revoke those, disable or delete the service account itself. Deleting the key (gcloud iam service-accounts keys delete KEY_ID --iam-account=...) has the same caveat (create and delete keys). Audit-log authenticationInfo.serviceAccountKeyName shows which key created or exchanged credentials (AuditLog reference).
Workspace users:
-
users.signOut:POST https://admin.googleapis.com/admin/directory/v1/users/{userKey}/signOut"Signs a user out of all web and device sessions and reset their sign-in cookies." -
tokens.delete:DELETE https://admin.googleapis.com/admin/directory/v1/users/{userKey}/tokens/{clientId}"Deletes all access tokens issued by a user for an application." - Both need the scope
https://www.googleapis.com/auth/admin.directory.user.security. Reset the password and review 2SV methods as well; the login audit'suser_signed_out_due_to_suspicious_session_cookieevent shows Google acting on a suspicious cookie itself (login events).
- Block new sign-ins (disable the account or add the deny SCP).
- Revoke sessions and refresh tokens.
- Remove attacker-added credentials, app grants, MFA methods and federation changes.
- Rotate secrets the identity could read.
- Watch the logs for the documented residual window (minutes for Entra revocation, up to the access-token or session lifetime elsewhere) and confirm no further activity.
- Identity incident response
- OAuth consent & app investigation
- Active Directory tradecraft - on-premises Kerberos context for hybrid federation
- README.md - Cloud identity section index
- identity-lifecycle-and-privileged-access.md - Leaver procedure
- ../../PlayBooks/unauth_access.md - Unauthorized access playbook
- ../README.md - Cloud Security section index
โฌ ๏ธ Cloud Identity index | Master Index | ๐ฏ Role Navigation | Legal Notice
๐ Source: Cloud/Identity/token-theft-and-session-revocation.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Cloud
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics