Release v0.7.3: OAuth refresh hardening #7

Merged
Grok merged 2 commits from dev into main 2026-11-06 01:49:54 +00:00
Member

Promote preview-validated OAuth refresh hardening to production.

  • Includes merge of #6 (fc8530c → dev as 75b2153)
  • VERSION 0.7.3
  • Preview validated: health, discovery, isolated diagnostic client refresh rotation + spent reuse rejection + authenticated MCP after refresh
  • Authorized by Brandon via Chief card 2026-11-05 17:44 PST: merge PR6, update preview, release to prod
Promote preview-validated OAuth refresh hardening to production. - Includes merge of #6 (`fc8530c` → `dev` as `75b2153`) - VERSION 0.7.3 - Preview validated: health, discovery, isolated diagnostic client refresh rotation + spent reuse rejection + authenticated MCP after refresh - Authorized by Brandon via Chief card 2026-11-05 17:44 PST: merge PR6, update preview, release to prod
refresh_tokens committed the spend of the presented refresh token before
it checked the requested resource, then released the lock and issued the
replacement pair in a second transaction. A resource mismatch, or any
failure while issuing, burned the client's only refresh token and left
no replacement, forcing a full re-consent. Expiry shared the replay
branch, so a token that merely aged past 30 days revoked its whole
family as if it had been stolen.

Now every check runs before any write, in this order: unknown token,
client mismatch, spent token (replay), expiry, resource. The spend and
the new access/refresh rows commit together inside BEGIN IMMEDIATE on
the shared connection while the process RLock is held. Any exception
rolls the whole transaction back, so the presented token stays usable.
BEGIN IMMEDIATE takes SQLite's write lock before the read, so two
processes on the same /data/app.sqlite cannot both pass the "not
revoked" check; the in-process RLock only ever covered threads. The
spend is also a compare-and-swap (WHERE revoked = 0, rowcount must be
1) as a second guard.

Replay detection is unchanged in strength: presenting any revoked
refresh token, including one that is also expired or sent with a wrong
resource, revokes the family. Two concurrent presentations of the same
token are still replay: one wins, the rest revoke the family including
the winner's pair. An expired, never-spent token is rejected with
invalid_grant "refresh token expired" and the family is left alone;
expiry is not evidence that a second party holds the token. TTLs are
unchanged (access 1 h, refresh 30 d).

Rejections log one line, "oauth_refresh outcome=rejected reason=...
client_id=... family_id=...", with reasons unknown_token,
client_mismatch, reuse_family_revoked, expired, resource_mismatch, and
rotation_error_rolled_back. Logs never carry the presented token, its
hash, or issued tokens; client_id comes from the request, so it is
filtered to [A-Za-z0-9._-] and capped at 64 chars. Successful rotation
logs outcome=rotated.

_issue_tokens is split into _insert_token_rows (no commit, caller owns
the transaction) and a thin committing wrapper still used by
exchange_code.

Rejected: keeping replay-on-expiry (punishes idle clients with family
revocation for no security gain); a grace window for concurrent
duplicate refreshes (weakens replay detection, out of scope); moving
the resource check after the spend but restoring the token on mismatch
(two writes, still not atomic).

Error descriptions change from "refresh token reused or expired" to
"refresh token reused" / "refresh token expired"; the error code stays
invalid_grant.

Version 0.7.3.
Merge pull request 'fix: validate and rotate OAuth refresh tokens in one transaction' (#6) from 0.7.2/oauth-refresh-hardening into dev
Grok merged commit 83588b3fc8 into main 2026-11-06 01:49:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ai-collab/agent-news-aggregator!7
No description provided.