| Recovery choice | Appropriate boundary | Main trade-off |
|---|---|---|
| Rotate refresh tokens; revoke one session family | A customer can prove control through an independent recovery path | Requires an atomic token transition and a trustworthy recovery ceremony |
| Reauthenticate and terminate all sessions | The scope of compromise is uncertain | Wider disruption, including devices the customer still controls |
TL;DR: For a fintech mobile app, use refresh token rotation with a server-side session family and authenticated revocation. Start with the smallest recovery operation that contains the theft: revoke the stolen device's family, then issue a new session only after appropriate authentication. Escalate to account-wide termination when the recovery evidence cannot establish a narrower boundary.
A mobile login endpoint is the easy part. The consequential decision is what a customer can still do after losing the phone that holds the credentials. A refresh token from that phone must not become proof that its holder is entitled to recover the account.
The implementation below sketches three transitions for a Node.js backend: login, refresh, and device revocation. They are application design choices, not a prescribed protocol or a complete authentication server. The recovery boundary drives the design; configuration should follow it.
How should a mobile backend revoke a session after device theft?
Start with recovery evidence. OWASP's Authentication Cheat Sheet calls for reauthentication after risk events, including account recovery, and discusses rotating tokens and invalidating sessions afterward. It also recommends generic authentication responses and controls against automated attacks. Those requirements belong in the recovery flow before a new credential is issued.
Possession isn't enough.
If the stolen phone receives the recovery challenge and supplies the refresh token, treating those two inputs as independent evidence would defeat the purpose of recovery. Require an appropriately verified path outside the compromised session. The exact ceremony depends on the account's enrolled authenticators and recovery policy; do not silently invent an alternate path when those are unavailable.
For the API contract, separate an authenticated account identifier from a session-family identifier. The former comes from verified authentication context. The latter selects a revocation target within that account. A device label is display data: a customer can recognize a phone by its label, but the server must authorize the operation against the account and session records.
That distinction deserves a test. Submit another account's family identifier to the revocation handler and require rejection without revealing whether that family exists. A useful SDK should make this behavior predictable without requiring callers to assemble authentication rules from a dozen flags.
Revocation has to reach the resource request
The second criterion is how quickly the stolen phone loses access. Revoking refresh credentials prevents future refreshes. It does not, by itself, make an already issued access token disappear. RFC 7009 discusses revocation and the relationship between access and refresh tokens; the application's resource servers still need a defined enforcement policy.
For this design, choose a server-side session check on protected fintech requests. The request must carry an access credential that is validated and bound to its session family; authorization then rejects a revoked family. This adds a state lookup to the request path. A design that accepts independently validated access tokens until expiry has a different boundary: the remaining access-token lifetime becomes part of the containment delay. State that boundary explicitly.
Don't fake immediacy.
Rotation needs equally explicit semantics. RFC 9700 describes refresh token rotation as issuing a new refresh token, invalidating the previous one, and retaining the relationship so reuse can reveal a possible compromise. For public clients, it requires sender-constrained refresh tokens or refresh token rotation to detect replay. A native mobile application is a relevant setting for this guidance.
A session family groups that rotation history. For this example, a replay causes the family to be revoked. The server cannot infer from the reused bearer token alone which presenter is the legitimate customer. That is why recovery needs its own proof.
The awkward case is a lost refresh response. The server may have consumed the old token while the phone never received its replacement. Blind retries now look like replay. Serialize refresh attempts in the client, and make the SDK surface an authentication-required result when the outcome cannot safely be recovered. This chooses stricter containment at the cost of occasional reauthentication. Any retry accommodation needs a separately specified threat model; a generic retry switch is too vague.
Three transitions, one storage contract
Keep the example small enough to review. These TypeScript handlers belong behind a Node.js HTTP adapter. They assume TLS, validated request bodies, safe error mapping, rate limits, and a credential service that generates and protects tokens. The interfaces describe requirements for that service; they do not implement cryptography or storage.
type Principal = { accountId: string }; type Session = { familyId: string; accessToken: string; refreshToken: string }; type Rotation = | { kind: "rotated"; session: Session } | { kind: "rejected" }; interface Credentials { // Verify credentials and apply the account's authentication policy. authenticate(input: unknown): Promise<Principal | null>; // Validate fresh proof independently of the target session. authorizeRecovery( actor: Principal, proof: unknown ): Promise<boolean>; } interface Sessions { create(accountId: string, deviceLabel: string): Promise<Session>; // Atomically consume, replace, and check family status. // Replay must commit family revocation before returning rejected. rotateOrRevoke(refreshToken: string): Promise<Rotation>; // Enforce account ownership and serialize against rotation. revokeOwnedFamily(accountId: string, familyId: string): Promise<void>; } type Reply = { status: number; body?: unknown }; function mobileAuth(credentials: Credentials, sessions: Sessions) { return { async login(input: unknown, deviceLabel: string): Promise<Reply> { const actor = await credentials.authenticate(input); if (!actor) return { status: 401 }; const session = await sessions.create(actor.accountId, deviceLabel); return { status: 200, body: session }; }, async refresh(refreshToken: string): Promise<Reply> { const result = await sessions.rotateOrRevoke(refreshToken); if (result.kind === "rejected") return { status: 401 }; return { status: 200, body: result.session }; }, async revoke( actor: Principal, familyId: string, proof: unknown ): Promise<Reply> { const allowed = await credentials.authorizeRecovery(actor, proof); if (!allowed) return { status: 403 }; await sessions.revokeOwnedFamily(actor.accountId, familyId); return { status: 204 }; } }; } The HTTP adapter must derive actor from validated authentication context. Never deserialize it from a customer-supplied account identifier. Map ownership failures to a generic response and ensure the adapter does not cache token responses or log their bodies. The status codes above are example contract choices.
The critical work is inside rotateOrRevoke. Two concurrent calls presenting the same token must not both obtain usable descendants. Rotation and revocation must serialize on the family state, so a revoked family cannot produce a replacement after the revocation commits. Token persistence should protect the refresh credential; raw bearer values do not belong in analytics events.
There is a less obvious transaction trap here. If replay detection updates the family to revoked and then throws an exception that rolls back the transaction, the apparent rejection has preserved the attacker's session. Return a rejected result only after the revocation has committed. The interface comment is a storage invariant, not an implementation detail to postpone.
Measure the recovery boundary before deployment
Benchmark the path the customer will actually take. Record time from login submission to the first successful protected call, refresh latency under contention, and the interval between revocation commit and rejection at each resource server. Use percentile distributions and a declared workload. No measured results are claimed here. A benchmark without concurrent refresh attempts would miss the storage decision that matters most.
The production acceptance cases are concrete:
- Race two refreshes with one credential. Verify replay handling and the usability of any returned descendant after family revocation.
- Revoke a family while refresh is in flight. Verify that committed revocation prevents later protected access under the chosen enforcement policy.
- Lose the refresh response. Verify the SDK stops automatic retries and reaches the documented reauthentication path.
- Attempt recovery and revocation with a different account's target identifier. Verify ownership enforcement and generic errors.
Then repeat those cases during a rolling deployment. Old and new application instances must agree on family state and token transitions. Watch rejection reasons internally, but never use token strings as metric labels. Monitor recovery failures as well as refresh success; an apparently healthy login endpoint can coexist with an unusable recovery flow.
The operational cost is state reads, serialized writes, and support work when recovery fails. Keep those costs visible. They are more useful design inputs than another configuration page.
When account-wide termination is the better choice
The runner-up is deliberately broad: terminate all existing sessions and require fresh authentication through the recovery policy. Prefer it when a customer cannot reliably identify the stolen session, or when the verified recovery event indicates a wider compromise. It reduces dependence on selecting the correct device record, while interrupting legitimate sessions too.
Targeted family revocation is the narrower choice only when account control and the affected family can be established. Either approach needs a recovery ceremony the customer can complete after losing the phone. Test that path first.
References
The Authentication Cheat Sheet supports the reauthentication, recovery, and generic-response guidance. RFC 9700 supplies the refresh-token replay and rotation requirements. RFC 7009 supplies revocation semantics and propagation considerations. The handlers, family-level request checks, and acceptance cases are proposed application design, not claims of measured performance.
Further reading
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- OAuth 2.0 Security Best Current Practice, refresh token protection: https://www.rfc-editor.org/rfc/rfc9700.html#section-4.14
- OAuth 2.0 Token Revocation: https://www.rfc-editor.org/rfc/rfc7009.html