How an application should invalidate sessions after a credential reset
Changing a password or authenticator does not necessarily end sessions that an application has already issued. If an attacker copied an old session cookie, refresh token, or API token, access may continue after the secret changes. An application should connect the reset event to the account, invalidate existing sessions, tokens, and recovery artifacts on the server side, then verify that later requests are actually rejected.
How an application should invalidate sessions after a credential reset
Changing a password or authenticator does not necessarily end sessions that an application has already issued. If an attacker copied an old session cookie, refresh token, or API token, access may continue after the secret changes. An application should connect the reset event to the account, invalidate existing sessions, tokens, and recovery artifacts on the server side, then verify that later requests are actually rejected.
What needs to be invalidated?
| Access asset | Action to check | Possible limitation |
|---|---|---|
| Web and mobile app sessions | Invalidate the user's active server-side sessions and expire session cookies. | Clearing a browser cookie alone does not stop reuse if the server still accepts that session. |
| Remember-me and long-lived login tokens | Revoke stored tokens or increment a token version, then require a new login. | Device tokens may be stored across several services. |
| OAuth refresh tokens | Use a supported revocation endpoint and handle related tokens from the same grant according to policy. | A resource server may not support immediate access-token revocation. |
| Self-contained access tokens/JWTs | Add a deny list, online introspection, or account token-version check; otherwise bound exposure with short expiry. | An API that checks only signature and expiry offline may not learn of central revocation immediately. |
| Password-reset links and recovery codes | After use, invalidate that code and any outstanding recovery flow. | Links in other services or already-open tabs may need separate cleanup. |
| Sessions at external services | Use the linked service's own logout or token-revocation flow, or revoke access there directly. | The original application may not be able to end another service's session. |
Clearing a browser cookie with Set-Cookie helps remove a token from that device; it is different from making the server reject a copied cookie. The server needs its own validation mechanism, such as deleting the session record or checking a per-account session_version. Decide whether a reset ends every session or lets the user keep selected devices based on risk and product needs.
Implementation sequence
**Record the reset event reliably.** After a password change, account recovery, lost-authenticator report, or administrator-forced reset, create an internal event with the account ID and event ID.
**Choose the invalidation policy.** Distinguish a routine user change from a suspected-compromise recovery. Decide which account sessions, device sessions, refresh tokens, and external sessions end. Decide in advance whether a suspected compromise also ends the session currently used by the user.
**Change server-side state.** Revoke session records or token-store entries, or increment the user's session version, and make request validators check the change. If caches are involved, verify that invalidation reaches every application server.
**Handle OAuth tokens separately.** Revoke refresh tokens at the RFC 7009 endpoint and revoke access tokens when the authorization server supports it. The RFC requires refresh-token revocation support but only recommends access-token revocation. If your API validates signed JWTs offline until expiry, add a way to distribute or query revocation status, or limit the maximum exposure with token lifetime.
**Prevent recovery artifacts from being reused.** Invalidate the reset link or one-time code used, check whether new authenticators were enrolled and whether notification addresses remain trustworthy, and issue a new session ID after the credential change to reduce session-fixation and privilege-transition risks.
**Notify the user and offer a recovery path.** Send notice through previously registered trusted channels. For suspicious changes, provide a way to lock the account, contact support, and report compromise.
**Test rejection.** Reuse a browser cookie, mobile refresh token, API access token, and recovery link issued before the reset. Confirm each is denied. Measure how long invalidation takes to reach every resource server and region, and document any limits.
Common implementation choices
**Server-side sessions:** Delete the account's session records or mark them revoked. Check cache expiration and replication delay.
**Session-version checks:** Store a session generation number on the user record and include it in issued tokens. Reject tokens whose version differs from the current value. The resource server's source and refresh rate for the current version determine revocation delay.
**Short-lived access tokens plus refresh-token revocation:** Revoking refresh tokens stops new access-token issuance; short access-token lifetimes bound remaining exposure. Immediate blocking requires the API to check revocation state.
**Per-device sessions:** Show active devices or sessions and allow one to be ended. For an account-wide reset, make the default and notice clear so sessions on other devices are not missed.
OWASP Session Management guidance recommends reauthentication after risk events and server-side session termination on logout or expiry. OWASP Forgot Password guidance says to invalidate existing sessions and outstanding recovery links or codes after successful recovery. RFC 7009 explains that revocation effects depend on token type and resource-server validation. Do not assume that one “password reset succeeded” event ended every session in a distributed system; test rejection for each asset you control.
For example, if a browser app uses a server-side session cookie and a mobile app obtains access tokens from a refresh token, the account-recovery event should revoke the browser session on the server and revoke the refresh token at the authorization server according to its grant-revocation behavior. Whether a token family is also revoked depends on the implementation. If your API validates JWT access tokens locally, an old token may work until expiry; the emergency-recovery policy should state this exposure window and provide an additional blocking mechanism. This is a design example, not a test of a real application.
References
[OWASP Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html) — server-side session invalidation, session ID renewal, and reauthentication after high-risk events.
[OWASP Forgot Password Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html) — invalidate existing sessions and reset/recovery links or codes after recovery.
[RFC 7009: OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html) — OAuth token revocation and the limits of self-contained access tokens.