Skip to content

relay: cap passkeys per account at 32, as Hosted does - #1920

Merged
nedtwigg merged 1 commit into
mainfrom
audit-relay-passkey-cap
Nov 30, 2026
Merged

nedtwigg merged 1 commit into
mainfrom
audit-relay-passkey-cap

Conversation

@nedtwigg

Copy link
Copy Markdown
Member

Nightly audit follow-up. Hosted refuses a 33rd passkey on an account, but the selfhost Relay appended to account.json without limit, so a holder of a Burrow token could keep adding rows to a durable file that every append rewrites in full.

  • MAX_PASSKEYS_PER_ACCOUNT (32) moves from hosted/server/relay-api.ts to remote-lib-common/src/remote/relay-common.ts, so both Relays read the same number.
  • AccountStore.appendPasskey in relay/src/state.ts refuses a full account inside its mutex, before the duplicate-credential check, the same order Hosted uses. /api/setup/finish answers 409 telling the user to remove a passkey from account.json. The refusal takes the existing failure path, so the setup token is restored and nothing is evicted.
  • docs/specs/relay.md -> "HTTP API" states the cap on the finish row. Its word budget is re-baselined from 5900 to 5950.

Tests: a new case in relay/test/setup.test.mjs fills an account to 32 and checks that the 33rd is refused, the file stays at 32, and the token still begins. It fails with the cap line deleted. Relay suite 323/323; Hosted's relay suite 38/38 (Docker); lint:specs and lint:md pass.

🤖 Generated with Claude Code

The selfhost Relay appended to account.json without a limit, so anyone
holding a Burrow token could loop setup-token -> begin -> finish and grow
the durable file without bound, each append rewriting the whole file.

The cap Hosted already enforced (32) moves to remote-lib-common so both
Relays share it. The selfhost refusal is a 409 naming account.json,
checked under the store's mutex; like every other finish failure it
restores the setup token, matching Hosted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b4b57d
Status: ✅  Deploy successful!
Preview URL: https://9cf190a7.mouseterm.pages.dev
Branch Preview URL: https://audit-relay-passkey-cap.mouseterm.pages.dev

View logs

@nedtwigg
nedtwigg merged commit 27cbe0c into main Nov 30, 2026
14 checks passed
@nedtwigg
nedtwigg deleted the audit-relay-passkey-cap branch November 30, 2026 04:15
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.

2 participants