Public: anyone can read this; the crew can change it.
Suspending or dropping an account ends its OAuth refresh tokens and codes #14996
Check · Review · Land · Live done — Landed and live in production.
Suspending or removing an account now deletes its OAuth refresh tokens and authorization codes, so restoring the account doesn't bring them back. This closes the #14765 finding tracked in #14960. The gap: dropCredentials deleted only session and token rows.
shipped production is serving it deploy 6dfa34b
Suspending or removing an account now deletes its OAuth refresh tokens and authorization codes, so restoring the account doesn't bring them back. This closes the #14765 finding tracked in #14960.
The gap: dropCredentials deleted only session and token rows. refreshGrant refuses a refresh token while the account is suspended, but it only ends the token family if someone actually tries it during the suspension. So an account could be suspended, a client could stay quiet, and once the account was unsuspended its refresh token would mint a fresh access token. A code issued before the suspension could still be exchanged afterwards in the same way.
What changed
src/core/accounts.ts:dropCredentialsnow deletessession,token,oauth_refreshandoauth_coderows byuser_id. Suspending, retiring and removing an account all call it, andscrubAccountcalls it too, so every one of those paths picks up the fix.test/oauth-suspend-ends-refresh.test.ts(new) has two tests:- One gives bob a refresh token and a code he hasn't exchanged yet, then suspends and unsuspends him through the real
suspendAccount/unsuspendAccountactions. Afterwards, both a refresh and the code exchange at/oauth/tokengetinvalid_grant. - The other calls
dropCredentialsdirectly and checks it deletes only that account's rows and leaves another account's alone. - Both tests fail on main and pass with the fix.
- One gives bob a refresh token and a code he hasn't exchanged yet, then suspends and unsuspends him through the real
Not done: src/core/oauth.ts is untouched, as the issue asked; listing grants by refresh family is #14904.
Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts named 2780 test files for the two changed files, too many to run here. I ran the 12 suites covering OAuth and account suspension and removal instead (the new one, oauth-refresh, oauth-flow, oauth-revoke, oauth-grants, accounts, accounts-retire, mcp-account-suspend, sole-owner-suspend, tui-people-suspend, account-remove-refusals, suspended-hidden): all 112 tests pass. The forge's full check on this push covers the rest.
To try it: bun test test/oauth-suspend-ends-refresh.test.ts
🤖 Generated with Claude Code
Clean, minimal fix. dropCredentials now also deletes oauth_refresh and oauth_code by user_id; the table names are a constant list, so no user text reaches the SQL. All callers (suspend, retire, remove, scrub) pick it up. The tests suspend and unsuspend through the real actions, check both refresh and code exchange get invalid_grant, and check another account is untouched. No page, TUI, README or dependency change.
Suspending or removing an account now deletes its OAuth refresh tokens and authorization codes, so restoring the account doesn't bring them back. This closes the #14765 finding tracked in #14960.
The gap:
dropCredentialsdeleted onlysessionandtokenrows.refreshGrantrefuses a refresh token while the account is suspended, but it only ends the token family if someone actually tries it during the suspension. So an account could be suspended, a client could stay quiet, and once the account was unsuspended its refresh token would mint a fresh access token. A code issued before the suspension could still be exchanged afterwards in the same way.What changed
src/core/accounts.ts:dropCredentialsnow deletessession,token,oauth_refreshandoauth_coderows byuser_id. Suspending, retiring and removing an account all call it, andscrubAccountcalls it too, so every one of those paths picks up the fix.test/oauth-suspend-ends-refresh.test.ts(new) has two tests:suspendAccount/unsuspendAccountactions. Afterwards, both a refresh and the code exchange at/oauth/tokengetinvalid_grant.dropCredentialsdirectly and checks it deletes only that account's rows and leaves another account's alone.Not done:
src/core/oauth.tsis untouched, as the issue asked; listing grants by refresh family is #14904.Checks:
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean.scripts/fast.tsnamed 2780 test files for the two changed files, too many to run here. I ran the 12 suites covering OAuth and account suspension and removal instead (the new one,oauth-refresh,oauth-flow,oauth-revoke,oauth-grants,accounts,accounts-retire,mcp-account-suspend,sole-owner-suspend,tui-people-suspend,account-remove-refusals,suspended-hidden): all 112 tests pass. The forge's full check on this push covers the rest.To try it:
bun test test/oauth-suspend-ends-refresh.test.ts🤖 Generated with Claude Code
Closes #14960