If refresh tokens are exposed to JavaScript or accepted from overly broad origins, an attacker who gains script execution or cross-site request capability can keep minting new access tokens. That turns a short-lived compromise into a persistent session takeover. Proper protection depends on httpOnly, Secure, SameSite cookies and tight CORS rules for refresh requests.
Why This Matters for Security Teams
refresh token are the long-lived bridge between a user’s current session and the ability to obtain new access tokens. If they are not locked down with session management controls such as httpOnly, Secure, and SameSite cookie handling, the refresh path becomes a durable reuse channel for attackers. That is what turns a one-time script injection or cross-site request weakness into repeatable account access.
The security problem is not just theft, but persistence. An access token may expire quickly, yet a stolen refresh token lets an attacker silently mint replacements and stay inside the trust boundary far longer than defenders expect. Tight origin controls matter for the same reason: if a refresh endpoint accepts requests from overly broad origins, the browser can be induced to send or exchange tokens in contexts the application did not intend.
In practice, many teams discover the weakness only after anomalous token refresh traffic or impossible session continuity has already appeared.
How It Works in Practice
A protected refresh flow should assume that the browser is a hostile execution environment. The browser can host third-party scripts, be manipulated by injected code, and initiate cross-site requests. Cookie attributes reduce what that environment can read or replay, while origin restrictions reduce where refresh requests are accepted from.
In a well-structured design, the refresh token is stored in a cookie that JavaScript cannot read, the browser sends it only over TLS, and the server rejects refresh calls unless the request originates from an approved site or application context. That combination limits three common failure paths: direct token exfiltration via script access, token replay over insecure transport, and cross-site abuse through permissive request handling.
Practitioners should think about the full chain, not just storage. A refresh token can be protected at rest in the browser and still fail if the endpoint accepts permissive CORS patterns, reflects origins incorrectly, or allows credentialed requests from unexpected front ends. Equally, a strict origin policy is weakened if the token is exposed to JavaScript, because script compromise then bypasses the browser boundary entirely.
- Use httpOnly so script cannot read the refresh token.
- Use Secure so the token is only sent over TLS.
- Use SameSite to reduce cross-site replay opportunities.
- Restrict CORS and allowed origins to the exact refresh clients.
- Keep access tokens short-lived so refresh abuse is easier to detect and contain.
These controls tend to break down in single-page apps and federated login flows when engineers relax origin checks to make cross-domain authentication “just work.”
Common Variations and Edge Cases
Tighter refresh-token handling often increases integration friction, so teams have to balance browser compatibility against session durability and abuse resistance. The right answer also depends on whether the refresh token is used in a first-party web app, a mobile client, or a server-side flow.
Public browser clients are the hardest case because they are exposed to script injection, extension risk, and cross-site traffic. In those environments, cookie attributes are necessary but not always sufficient, because the broader application still needs strong input handling, anti-CSRF design, and narrow origin allowlists. Mobile and native clients can use different token storage patterns, but they still need equivalent protection against replay and unauthorized exchange.
There is no universal standard for this yet, but current guidance suggests treating refresh tokens as high-value secrets with a short operational life, explicit binding to the intended client, and a clearly defined revocation path. If the application cannot enforce those properties consistently, the refresh mechanism should be redesigned rather than patched with looser browser rules.
Risk and Threat Considerations
The main risk is persistent session takeover. Refresh tokens are attractive because they outlive the access token they replenish, so any weakness in browser storage or origin policy can turn a brief foothold into repeated token minting.
Failure mechanism: An attacker who can run JavaScript in the page, abuse a cross-site request path, or exploit permissive CORS can obtain or replay the refresh token and continue exchanging it for fresh access tokens even after the original access token expires.
Impact: The attacker preserves authenticated access, bypasses normal session expiry expectations, and may remain active until the refresh token is revoked or rotated.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 address the attack and risk surface, while CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | A4 — Session and Token Handling | Refresh token abuse is a session persistence problem in browser-based auth. |
| A7 — Cross-Origin and Integration Security | Overly broad origins enable cross-site token refresh abuse. | |
| A10 — Credential Leakage and Secret Exposure | Exposed refresh tokens function as bearer credentials with long-lived value. | |
| Recommendation — Store refresh tokens in httpOnly, Secure, SameSite cookies and restrict replay paths. Lock refresh CORS and origin checks to approved clients only. Treat refresh tokens as high-value bearer secrets and rotate or revoke on suspicion. | ||
| CIS Controls v8 | 6 — Access Control Management | Refresh token protection depends on restricting who can obtain and reuse credentials. |
| Recommendation — Restrict token use paths to approved clients and revoke exposed refresh credentials. | ||
Practitioner Guidance
What to verify: Confirm that the refresh token is never readable to JavaScript, that the browser sends it only over HTTPS, and that the refresh endpoint rejects unexpected origins and credentialed cross-site requests. If any one of those checks fails, treat the session boundary as weak even if access tokens are short-lived.
Decision rule: If the refresh token can be replayed from another origin or script context, prioritise token rotation and origin tightening before tuning access-token expiry. Short access-token lifetimes do not meaningfully reduce risk when refresh abuse remains open.
Practitioner takeaway: The control objective is not just protecting a token, but preserving the trust boundary around renewal, because that is what prevents a single browser compromise from becoming durable account control.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org