Skip to content

LearnIdentity

Stolen token response: M365, Google, Okta

Brief

A password reset does not evict the holder of a stolen token: the access token runs to its expiry, some refresh tokens and sessions survive, and the device, authenticator and inbox rules the holder added stay. Eviction is revoke, then audit devices and methods, then rules.

Stage
Persistence
Reviewed
On this page
  1. Check first
  2. Does the token still work after the password reset?
  3. How do I revoke the sessions and tokens on each platform?
  4. Which devices and MFA methods did the holder add?
  5. Which inbox rules and forwards did they leave?
  6. The defender sees
  7. Done when
  8. Not covered
  9. Tools
  10. Related research
  11. Where this page fits
  12. Reviewed

All commands

Situation
A session cookie, access token or refresh token known or suspected stolen, for a tenant named in the scope letter. On an engagement the token belongs to our own test user and we capture it through our own proxy; on a live response it is the victim's and the responder runs the same steps. Tokens stay in environment variables and are never printed or written into the report.
Goal
An eviction record: for each platform, whether the token worked after the reset, when it was revoked, and every device, method, grant, rule and forward found and removed.
Outputs
Representative examples on placeholder hosts, trimmed to the lines that matter. Not captured from a public fixture yet.

Check first

  • Which token it is: a session cookie, an access token with 60 to 90 minutes to live, or a refresh token that mints new ones. Each behaves differently after a reset.
  • Which platforms the account reaches and which applications sit downstream; revocation at the identity provider does not end an application's own session.
  • Roles for the response: Privileged Authentication Administrator and Cloud Device Administrator on Entra, a Workspace admin with user security privileges, an Okta admin who can clear user sessions.
  • The time of the reset and of the last sign-in the user recognises; later entries are the holder's.
  • An agreed marker for anything created on an engagement, here ATARUS-TEST-2026-10-27.

Steps

Does the token still work after the password reset?

# the test user's password was reset five minutes ago; every token stays in a variable
curl -s -X POST "https://login.microsoftonline.com/example.onmicrosoft.com/oauth2/v2.0/token" \
  -d "client_id=$CLIENT_ID&grant_type=refresh_token&refresh_token=$RT_M365&scope=https://graph.microsoft.com/.default" \
  | jq -c '{token_type, expires_in, error, error_codes}'
curl -s -X POST https://oauth2.googleapis.com/token \
  -d "client_id=$GCLIENT&client_secret=$GSECRET&grant_type=refresh_token&refresh_token=$RT_GOOGLE" \
  | jq -c '{token_type, expires_in, error}'
curl -s -b "sid=$OKTA_SID" https://example.okta.com/api/v1/sessions/me | jq -c '{login, status, expiresAt}'

Expected output

{"token_type":"Bearer","expires_in":3599,"error":null,"error_codes":null}   # <- a fresh hour of Graph access after the reset
{"token_type":"Bearer","expires_in":3599,"error":null}
{"login":"tester-a@example.com","status":"ACTIVE","expiresAt":"2026-10-27T19:40:12.000Z"}   # <- the Okta session outlived the reset

Each platform keeps something alive. Microsoft's revocation table says a change by the user, self-service reset, or an admin reset from the Azure portal revokes only refresh tokens from a password sign-in, so a token from a passwordless sign-in stays; a reset from the Entra or Microsoft 365 admin center revokes those too; an access token runs to its expiry whichever route was used. Google revokes a refresh token on a password change only when it carries Gmail scopes, and sign-in cookies are a separate reset. Okta ends sessions on an admin reset only when the reset asks for it, revokeSessions in the API.

Negative result. Microsoft answers AADSTS50173, the grant revoked, or AADSTS50133; Google answers invalid_grant; Okta answers 404 from the sessions endpoint.

Fix. Treat the reset as one step of eviction and run the revocation below with every suspected theft. Shorten what survives: continuous access evaluation for Microsoft 365 apps, Token Protection where supported, Okta session lifetimes, and a sign-in cookie reset with every Workspace password reset.

How do I revoke the sessions and tokens on each platform?

curl -s -X POST -H "Authorization: Bearer $ADMIN_GRAPH" \
  https://graph.microsoft.com/v1.0/users/tester-a@example.onmicrosoft.com/revokeSignInSessions
curl -s -o /dev/null -w '%{http_code}\n' -X POST -H "Authorization: Bearer $ADMIN_GOOGLE" \
  https://admin.googleapis.com/admin/directory/v1/users/tester-a@example.com/signOut
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE -H "Authorization: SSWS $OKTA_API_TOKEN" \
  "https://example.okta.com/api/v1/users/00u1example/sessions?oauthTokens=true"

Expected output

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Edm.Boolean","value":true}   # <- refresh tokens and browser sessions issued before now stop working; access tokens already issued run to their expiry
204
204

The portal routes are the same actions. Entra admin center: Users, the user, Revoke sessions, with Account enabled switched off first. Google Admin console: Directory, Users, the user, Security, Sign-in cookies, Reset, which signs the user out of browsers and mobile devices but not desktop apps. Okta Admin Console: Directory, People, the user, More Actions, Clear User Sessions, confirmed in the Clear Sessions & Revoke Tokens dialog. Third party OAuth grants on Workspace go separately with DELETE .../users/<user>/tokens/<clientId>.

Negative result. The refresh token and session replay fails on every platform. An access token minted before the revocation still works until it expires, up to about an hour, unless the app enforces continuous access evaluation. A success after that is a token issued after the revocation time: a new sign-in to investigate, not a revocation that missed.

Fix. Write revocation and reset into the compromised account playbook as one action, and disable the account while the rest of this page runs.

Which devices and MFA methods did the holder add?

G="https://graph.microsoft.com/v1.0/users/tester-a@example.onmicrosoft.com"
curl -s -H "Authorization: Bearer $ADMIN_GRAPH" "$G/registeredDevices" \
  | jq -r '.value[] | [.displayName, .trustType, .registrationDateTime] | @tsv'
curl -s -H "Authorization: Bearer $ADMIN_GRAPH" "$G/authentication/methods" \
  | jq -r '.value[] | [."@odata.type", (.displayName // ""), (.createdDateTime // "")] | @tsv'
curl -s -H "Authorization: Bearer $ADMIN_GOOGLE" \
  https://admin.googleapis.com/admin/directory/v1/users/tester-a@example.com/asps | jq -r '.items[]? | [.codeId, .name, .creationTime] | @tsv'
curl -s -H "Authorization: SSWS $OKTA_API_TOKEN" https://example.okta.com/api/v1/users/00u1example/factors \
  | jq -r '.[] | [.factorType, .provider, .status, .created] | @tsv'

Expected output

LAPTOP-TESTER-A	AzureAd	2025-03-02T09:14:51Z
DESKTOP-4F9A1C2B	Workplace	2026-10-27T15:52:08Z   # <- registered forty minutes after the stolen session first signed in
#microsoft.graph.passwordAuthenticationMethod		
#microsoft.graph.microsoftAuthenticatorAuthenticationMethod	iPhone 13	2026-10-27T16:08:30Z   # <- an authenticator the user does not own
1842	Mail on old phone	1761580200264   # <- a Google app password, which bypasses 2-Step Verification
push	OKTA	ACTIVE	2026-10-27T16:11:02.000Z

Anything created after the last sign-in the user recognises goes. On Entra, DELETE /devices/{id} removes the device, or Update-MgDevice -AccountEnabled:$false disables it first, and DELETE .../authentication/microsoftAuthenticatorMethods/{id} removes the method. The token replay research shows what these registrations are for: a device that can request tokens and a second factor that passes the next prompt. On Workspace, DELETE .../asps/{codeId} removes the app password, POST .../verificationCodes/invalidate voids backup codes, and the Security section of the user's page shows the 2-Step Verification methods. On Okta, DELETE .../factors/{factorId} unenrols the factor.

Negative result. Every device, method, app password and factor predates the incident and the user recognises each one.

Fix. Make enrolment cost a fresh strong authentication: the Conditional Access user actions for registering security information and joining devices, a device limit, app passwords off in the Workspace 2-Step Verification policy, and an Okta policy that demands a possession factor before another enrols.

Which inbox rules and forwards did they leave?

Connect-ExchangeOnline
Get-InboxRule -Mailbox tester-a@example.onmicrosoft.com -IncludeHidden | Format-Table Name,Enabled,Priority,RuleIdentity -AutoSize
Get-Mailbox tester-a@example.onmicrosoft.com | Format-List ForwardingAddress,ForwardingSmtpAddress,DeliverToMailboxAndForward
curl -s -H "Authorization: Bearer $DWD_GMAIL" \
  https://gmail.googleapis.com/gmail/v1/users/tester-a@example.com/settings/filters | jq -c '.filter[]? | {id, criteria, action}'
curl -s -H "Authorization: Bearer $DWD_GMAIL" https://gmail.googleapis.com/gmail/v1/users/tester-a@example.com/settings/autoForwarding

Expected output

Name Enabled Priority RuleIdentity
---- ------- -------- ------------
.    True    1        16752869479666417665   # <- a one character name, moving matches to RSS Feeds and marking them read

ForwardingAddress          :
ForwardingSmtpAddress      : smtp:tester-a.archive@tester.example   # <- a copy of every message leaves the tenant
DeliverToMailboxAndForward : True
{"id":"ANe1BmjQ7f3a","criteria":{"query":"payroll OR \"direct deposit\""},"action":{"removeLabelIds":["INBOX","UNREAD"]}}   # <- payroll mail archived before the user sees it
{"enabled":false}

The rules are what the holder came for: hiding replies while a payment change goes out. We read each rule, note the folder and terms, remove it, and remove the forward. The Gmail calls use a service account with domain-wide delegation; Okta has no mailbox, so the same checks run in the suite behind it.

Negative result. Only rules the user describes, no forwarding address, autoForwarding disabled, and Gmail filters the user recognises.

Fix. Block automatic forwarding to external addresses at the tenant, AutoForwardingMode Off in the Exchange Online outbound spam policy and the Workspace Gmail setting that lets users forward only to internal addresses, and alert on every new or changed inbox rule and on Workspace's out-of-domain forwarding event, because a rule made from a stolen session looks exactly like one the user made.

The defender sees

The replay is a non-interactive sign-in in AADNonInteractiveUserSignInLogs with the victim's UserPrincipalName, the holder's IPAddress and UserAgent, the stolen session's SessionId now appearing from a new address, and IncomingTokenType naming the token used. Entra ID Protection should have raised an unfamiliar sign-in or anonymous address detection, and a Conditional Access block, result 53003, means a valid token was stopped at the last step. The audit log records the holder's work as Add device, Add registered owner to device and User registered security info, and the response as Update StsRefreshTokenValidFrom Timestamp, Delete device and Admin deleted security info; the mailbox audit log records the rule as UpdateInboxRules, on by default for the owner. Workspace writes login_success with its login_type and is_suspicious flags, suspicious_login, 2sv_enroll and email_forwarding_out_of_domain to the login audit. Okta writes user.session.start with client.ipAddress and an authenticationContext.externalSessionId the holder's later events share, user.mfa.factor.activate for the new factor, security.threat.detected where ThreatInsight knew the address, and user.session.clear for our revocation. A reset that raised a ticket while none of these raised an alert is the finding, and it matters more than the theft.

Done when

The replay after the reset is recorded, sessions and refresh tokens are revoked on every platform the account reaches, the device, method and grant lists match what the user recognises, and no unexplained rule or forward remains.

Not covered

How the token was stolen, which the MFA and device code research covers, Conditional Access and sign-in policy design, and on-premises Active Directory; the outputs shown are representative examples on placeholder tenants, not captured runs.