Summary
Pocket ID's token refresh logic issues new access tokens based solely on the cryptographic validity of a refresh token without re-checking the user's current authorization state.
As a result, revoked, disabled, or de-scoped users may continue to obtain valid tokens indefinitely, enabling unauthorized access even after administrators believe access has been removed.
Affected context
This vulnerability affects deployments of the Pocket ID OIDC provider where refresh tokens are used to obtain new access and ID tokens.
The issue arises in the createTokenFromRefreshToken logic, which:
- Verifies the refresh token's cryptographic integrity
- Does not re-check whether the user is still authorized, active, or in the required groups
It becomes particularly risky in environments that:
- Rely on account disablement or group membership changes for access revocation
- Allow long-lived refresh tokens
- Depend on OIDC claims for access enforcement across multiple services.
Exploit preconditions
- Attack surface: OIDC token endpoint (typically
/token) exposed to clients that possess refresh tokens. - Required access: A valid refresh token that was originally issued to a user (e.g., from a previously legitimate login).
- Trigger point: Calling the token endpoint with the refresh token after:
- The user's authorization has been revoked, or
- The account has been disabled, or
- The client has been removed from the relevant group.
- Why exploitation is possible: The refresh endpoint trusts the existing refresh token as the sole source of truth and does not re-query authorization state (user status, group memberships, or client permissions) before minting new tokens.
Why this happens
The root cause is a mismatch between authorization state and token lifecycle management, mapping primarily to CWE-285: Improper Authorization and related to CWE-613: Insufficient Session Expiration.
Instead of treating a refresh request as a new authorization decision, the implementation:
- Only validates the token's signature and integrity
- Assumes previous authorization remains valid for the lifetime of the refresh token
This pattern creates a stale-authorization problem: once a refresh token is issued, subsequent changes to the user's account status or group memberships are not reflected in token issuance, leading to continued access beyond intended revocation.
Potential impact
- Continued access to protected APIs and services by users whose access was revoked
- Disabled accounts still able to obtain fresh tokens and interact with reliant applications
- Users or clients retaining permissions after removal from groups or roles
- Violation of access control policies and regulatory requirements (e.g., offboarding, least privilege)
- Increased blast radius if a refresh token is compromised and cannot be effectively revoked
General mitigation guidance
Effective mitigation focuses on binding token refresh to current authorization state and ensuring timely session invalidation:
- Re-evaluate user and client authorization on each refresh:
- Confirm that the user account is active
- Check current group memberships, roles, and scopes
- Ensure the client and its consent are still valid
- Implement centralized revocation checks:
- Maintain revocation lists or versioned session records
- Invalidate associated refresh tokens when accounts are disabled or group memberships change
- Shorten token lifetimes:
- Use modest refresh token lifetimes where appropriate
- Align token TTLs with organizational revocation needs and risk appetite
- Apply least privilege:
- Restrict scopes tied to long-lived refresh tokens
- Separate high-privilege operations from tokens that may persist beyond a single session
- Design for revocation:
- Treat refresh endpoints as full authorization decision points, not mere signature validators
- Ensure downstream services are prepared for and expect token invalidation and re-authentication.
How teams detect issues like this
Detection generally involves examining both code and runtime behavior:
- Static analysis / code review:
- Identify token refresh flows that:
- Validate signatures but do not query user status, groups, or client state
- Lack checks against revocation lists or session state
- Look for refresh logic that reuses claims from the old token directly without re-resolving from an authoritative store.
- Policy and unit tests:
- Add tests to ensure:
- Disabled accounts cannot refresh tokens
- Removed group memberships are reflected in new tokens
- Revocation events propagate to refresh logic.
- Runtime monitoring:
- Log token refresh events with user ID, client ID, and resulting scopes/claims
- Alert on suspicious patterns, like:
- Token refreshes for disabled users
- Access tokens being minted long after revocation events
- Automated tooling:
- Use API security scanners or identity-flow testing tools to simulate account disablement and group changes, then attempt token refresh to verify enforcement.

