Skip to content

Gate OAuth token refresh on credential store writability - #1377

Merged
RhysSullivan merged 5 commits into
mainfrom
repro-vault-write-outage
Aug 28, 2026
Merged

Gate OAuth token refresh on credential store writability#1377
RhysSullivan merged 5 commits into
mainfrom
repro-vault-write-outage

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

A secret-store write failure while persisting a refreshed OAuth token could permanently invalidate the connection: the refresh grant had already consumed the single-use refresh token at the authorization server, so the rotated replacement was lost and the next refresh was rejected with invalid_grant, forcing a reconnect over what was only a transient storage error.

The refresh path now rewrites the stored refresh token in place before consuming it, so a store outage fails the request before the grant and the connection recovers once the store does. Includes an e2e scenario that stages the outage against the WorkOS emulator's vault and pins both the surfaced error and the recovery contract.

A vault write failure while persisting a refreshed OAuth token lost the
rotated refresh token: the grant had already consumed the single-use stored
token at the authorization server, so once the vault recovered the next
refresh replayed the revoked token, got invalid_grant, and the connection
demanded a re-auth over what was only a storage blip.

Before consuming the refresh token, rewrite the stored value in place as a
writability probe. A store outage now fails the resolve before the grant,
leaving the stored token valid so the connection recovers with the store.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing b02cb53 Commit Preview URL

Branch Preview URL
Aug 28 2026, 06:28 AM

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1377

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1377

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1377

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1377

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1377

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1377

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1377

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1377

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1377

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1377

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1377

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1377

executor

npm i https://pkg.pr.new/executor@1377

commit: b02cb53

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud b02cb53 Aug 28 2026, 06:29 AM

Main now persists the rotated refresh token before the access token, so the
ordering half of this failure is fixed. The writability half is not: when the
store refuses writes outright, the grant has already spent the stored token
and there is nowhere to put its successor.

Keep the pre-flight rewrite that proves the store is writable before the
grant, move its scenario into the existing credential-write-durability suite
rather than standing up a second file, and drop the prose that still claimed
the persist ordering was wrong.

Skip the persist's own refresh-token write when the authorization server hands
back an unrotated token, so the probe removes a vault write on the common path
instead of adding one.
The writability gate proved the store by rewriting the refresh token with
the value it had just read. That is a read-then-write with no
compare-and-set, so two instances refreshing one connection lose the newer
token: one reads the stored token, the other spends it and stores the
rotated replacement, and the first then writes the spent one back over it.
The in-flight refresh gate is per instance and cannot see the peer.

The gate now writes a fixed value to an item of its own, derived from the
refresh item's id so it lands in the same store partition and proves the
same thing. It holds no credential, so nothing is at risk when two
refreshers race on it.
@RhysSullivan
RhysSullivan marked this pull request as ready for review August 28, 2026 07:44
@RhysSullivan
RhysSullivan merged commit 98615b4 into main Aug 28, 2026
44 checks passed
This was referenced Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant