Join our Newsletter — 33% off our NHI Course
Home› FAQ› Authentication, Authorisation & Trust› How should security teams handle refresh tokens in…
Authentication, Authorisation & Trust

How should security teams handle refresh tokens in single-page applications that run in the browser?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 2, 2026 Domain: Authentication, Authorisation & Trust

Security teams should treat browser-based refresh tokens as high value credentials and reduce their exposure as much as possible. Use Authorization Code flow with PKCE, keep token lifetimes short, rotate refresh tokens on use, and store the most sensitive token handling server side when the application risk justifies it. For high sensitivity SPAs, a backend-for-frontend can centralise token exchange and limit browser access.

Why refresh tokens in a browser need stricter handling than ordinary session state

Refresh tokens are not just another browser artifact. They can outlive a page session, silently mint new access tokens, and preserve access long after the user thinks they are done. That makes them closer to a high-value credential than a convenience token, so the control objective is to limit where they exist, how long they remain valid, and how much can be done if one is stolen.

For browser-based applications, the main design choice is whether the browser should ever hold the refresh token directly. In lower-risk cases, a SPA can still use modern OAuth flows with tight lifetimes and rotation. In higher-risk cases, the better pattern is to move the most sensitive token handling out of the browser and into a server-side component that can mediate exchanges and reduce exposure.

What a safer browser token pattern usually looks like

The baseline is Authorization Code flow with PKCE, because it avoids older browser-friendly patterns that leave the application with weaker token handling choices. That should be paired with short-lived access tokens and refresh token rotation so each use narrows the window in which a stolen token remains useful. Rotation only helps if reuse is detected and treated as a signal of compromise, not as a normal retry condition.

When the browser must hold a refresh token, storage and transport details matter. Avoid treating browser storage as a vault, because XSS, malicious extensions, and token replay can all turn a stored token into persistent access. If the application has enough sensitivity or regulatory pressure to justify it, a backend-for-frontend can keep refresh tokens server side and issue the browser only the minimum material needed for the user experience.

That trade-off is practical, not ideological: the more sensitive the workflows, the less acceptable it is to expose long-lived bearer material to browser script, browser state, or client-side debugging surfaces. For this reason, guidance on OAuth for Browser-Based Applications and the BFF Pattern is especially relevant when the browser is acting as a thin front end rather than the trust boundary.

How to reduce blast radius if a refresh token is exposed

Start with the assumption that theft is possible and focus on making stolen tokens less durable and less reusable. Rotate on use, enforce idle and absolute expiry, and prefer sender-constrained or otherwise proof-of-possession capable designs where the ecosystem supports them. If a refresh token is suspected stolen, revoke the token family, invalidate related sessions where possible, and check whether the same client or user context is suddenly appearing from new IPs, devices, or concurrency patterns.

These controls are easiest to operate when you can observe the token lifecycle end to end. The operational detail matters, so use a runbook that covers rotation, reuse detection, revocation, and confirmation that the browser is no longer able to mint fresh access tokens. For implementation guidance, see OAuth Refresh Token Rotation and Expiry Guide and How to detect use of a stolen OAuth refresh token.

Risk and Threat Considerations

Browser refresh tokens create durable access risk because they are attractive targets for token theft, replay, and consent abuse. If an attacker gets one, they may not need the user’s password again, and they can often maintain access until the token is rotated, revoked, or expires.

Failure mechanism: The browser becomes the weakest link when long-lived bearer material is exposed to scriptable storage, untrusted extensions, or a compromised browser session. A stolen refresh token can then be replayed to mint fresh access tokens even after the user changes a password.

Impact: The result can be persistent account access, delayed detection, and broader data exposure than a single access token theft would normally allow. In higher-sensitivity apps, that persistence can also undermine incident containment because the attacker can keep renewing access until the refresh token family is invalidated.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS and NIST SP 800-63 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV9 — Self-contained TokensThe answer concerns token lifetime, storage and replay behaviour in a browser app.
V10 — OAuth and OIDCThe topic is OAuth flow selection for a browser-based SPA.
Recommendation — Verify token handling requirements that limit exposure, reuse and storage risk. Use the appropriate OAuth and OIDC flow for browser-based applications.
NIST SP 800-63SP 800-63B — Authentication and Lifecycle ManagementRefresh tokens are authentication material whose lifecycle and renewal need tight control.
Recommendation — Manage authentication material with short lifetimes, renewal limits and secure recovery paths.

Practitioner Guidance

What to prioritise: Decide first whether the browser should hold the refresh token at all. If the application protects sensitive data or privileged workflows, move token mediation server side before fine-tuning browser storage details.

What to verify: Confirm that rotation is real, reuse is detected, and revocation actually cuts off future token minting. A control that issues a new refresh token but does not reliably invalidate the previous one leaves a usable replay path.

Decision rule: If the refresh token can be used to reach production data or privileged functions, treat exposure as a credential incident, not a routine logout problem. If the browser is only a presentation layer, reduce its token authority accordingly.

Practitioner takeaway: The safest SPA design is the one that gives the browser the least durable credential material needed to function, while preserving strong rotation, revocation, and replay detection everywhere else.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org