Antonio Braccolino, Identity & Access, home
EN · Language: English

IAM interview questions · Protocols

How should refresh tokens be protected?

In plain wordsThe day pass expires every hour; a special voucher gets you a new one, and every voucher can be used only once.

How it works

A refresh token lets a client get new access tokens without user interaction, so it is long-lived and very valuable. It must be stored securely: server side for web apps, in the OS secure storage (Keychain, Keystore) for mobile.

Rotation issues a new refresh token on every use and invalidates the old one; if an old one shows up again, the server revokes the whole family because it means two parties hold it. Sender-constraining (DPoP or mTLS) binds the token to a key the client holds, so a stolen copy is useless.

Add absolute and idle lifetimes, revoke on password reset, logout and offboarding, and limit scopes.

A concrete example

Malware copies a refresh token from a laptop. The attacker uses it at 10:00 and gets a new pair. At 10:05 the real app uses its copy, which is now old: the IdP detects reuse, revokes the family, and both the attacker and the user are logged out. The user logs in again; the attacker cannot.

Mistakes to avoid

  • Refresh tokens in browser localStorage.
  • Not revoking them when an employee leaves.

They may also ask you

  • What is DPoP and when would you use it?
  • How long should a refresh token live?