Skip to main content

Wolfcore Cyber Security

OAuth Access and Refresh Tokens: Why Theft Matters

Written by Ruben Selby, founder and penetration tester at Wolfcore. Last reviewed 2 December 2026.

Part of the Wolfcore Resources library: Credentials, identity and exposure.

In one sentence: Access tokens and refresh tokens are digital passes your apps hold after you sign in, and anyone who steals one can act as you without knowing your password or needing your multi-factor code.

What it is

When you sign in to Microsoft 365 or Google Workspace, or approve a third-party app, the service does not hand the app your password. It issues tokens. RFC 6749, the OAuth 2.0 standard, defines two:

  • Access token: a credential used to reach protected resources, representing a specific scope and duration of access.
  • Refresh token: a credential used to get new access tokens when the old one expires. Issuing one is optional.

Access tokens are short-lived. In Microsoft Entra ID, Microsoft says they last 1 hour by default. Refresh tokens last much longer: 24 hours for single-page apps and 90 days in all other scenarios by default.

How it works

  1. You sign in and pass multi-factor authentication.
  2. The app receives an access token and a refresh token.
  3. The app presents the access token to read your mail or files.
  4. When it expires, the app sends the refresh token and silently gets a fresh pair. Microsoft notes refresh tokens replace themselves on each use, and says old ones should be deleted.
  5. Neither step asks for your password or MFA again.

This is convenient and it is also the risk. A stolen token is a pre-approved pass. Microsoft says refresh tokens need to be stored as safely as application credentials.

A stolen token skips the password and MFAYou sign inwith password + MFA>Service issuesaccess + refresh token>Token stolen fromdevice or app>Attacker reusestoken, no MFA promptWhy ‘we have MFA’ is not the whole answer. Controls: short lifetimes, revocation, device checks.

What tokens do not do: they do not prove the person using them is you. Anything holding the token is treated as you until it expires or is revoked.

Who it affects and how badly

Every business using cloud email, file storage or SaaS single sign-on.

  • Sole trader to 10 staff: a stolen token on one laptop can expose a mailbox, enabling invoice fraud.
  • 10 to 250 staff: tokens in browsers and automation scripts can reach shared drives and finance apps. Recovery means revoking sessions and investigating what was read.
  • Regulated businesses (accountancy, legal, fintech, healthcare): mailbox or file access may count as a personal data breach and trigger notification duties.

Real examples

Microsoft’s report on React2Shell attacks describes attackers who, after compromising servers, harvested cloud identity tokens from cloud instance metadata endpoints and used Azure command-line tools to obtain tokens. This shows tokens are a target, not a side effect. Source: Microsoft Security Blog, linked above.

What we check on a test

We look at where tokens and similar secrets can be found and reused, by hand, on a penetration test:

  • Whether apps and scripts store tokens or keys in files, environment variables or browser storage in a readable form.
  • Whether a web or API flaw would let an attacker read another user’s token or session.
  • Whether logout and password change actually end sessions.
  • Whether tokens are scoped narrowly or give broad access.
  • Whether sign-in policies check device and location when a token is reused.

Worked example (an illustration, not a real client)

A 25-person estate agency has a staff member whose laptop is infected by a password-stealing program. Their mailbox is protected by MFA, yet the attacker uses a stolen browser session to read email and send a fake change-of-bank-details message to a client.

Changing the password helps, but Microsoft’s table shows some token types survive a user password change. The right steps: revoke all refresh tokens, review mailbox rules, clean the laptop, and tighten sign-in policies.

How to detect it

  • Review Entra ID or Google sign-in logs for the same account from unusual places, devices or user agents shortly after a normal sign-in.
  • Look for new inbox rules and unexpected app consents.
  • Alert on token use from a different IP than where it was issued.
  • Check endpoint alerts for information-stealing malware; see infostealer logs and session cookie theft.

How to fix or prevent it

  1. Revoke tokens when compromise is suspected. Microsoft says to disable the user and revoke their refresh tokens (Revoke-MgUserSignInSession is the documented command).
  2. Remember access tokens last about an hour by default, so revocation is not instant. Plan for that window.
  3. Use Conditional Access to require compliant devices; see Conditional Access policies.
  4. Use phishing-resistant MFA, which makes the original sign-in harder to hijack.
  5. Remove old app consents and unused apps.
  6. Never put tokens or keys in code or chat; rotate any that leak; see secret rotation.
  7. Keep endpoints patched and protected from infostealer malware.

Rules and regulators

  • UK: the ICO’s security principle expects measures proportionate to risk.
  • EU: GDPR Article 32 requires measures ensuring ongoing confidentiality and integrity.
  • US: the FTC’s Start with Security guide covers protecting against authentication bypass and limiting access.

Frequently asked questions

How long does an access token last? Microsoft says one hour by default in Entra ID.

How long does a refresh token last? By default 24 hours for single-page apps and 90 days otherwise, per Microsoft.

Does changing a password cancel every token? Not always. Microsoft’s table shows some token types stay alive after a user password change, so revoke refresh tokens too.

Related terms

More in Credentials and exposure. Stolen tokens are one reason device code phishing matters.

Sources

How Wolfcore helps

Breachy checks whether your staff email addresses and passwords are already in known breaches and gives you the exact steps to close each exposure. See Breachy. To test how staff respond to phishing emails, see our phishing simulation software.

Wolfcore

Would your staff click a phishing email?

Run a real, safe phishing test on your team with Phishy. Free for 14 days, up to 10 staff, no card. We help you set it up.

Start a free phishing testFree website security scanor book a 30 minute call