Repository navigation
Fix account-enumeration, rate-limit, CSRF-binding and store-lock security gaps - #494
Merged
Merged
Conversation
jimhoyd
force-pushed
the
claude/fix-extension-security-bugs
branch
from
September 22, 2026 20:37
0d55f80 to
293c294
Compare
Fixes #461, #462, #463, #464, partially addresses #465 and the auth half of #467. - No enumeration signal on registration, waitlist and password-reset/email- code/factor-recovery delivery: duplicate-email registration now mirrors a genuine registration's shape/status via an unpersisted session, and every delivery path attempts delivery (with a decoy token/code when ineligible) instead of skipping it. The /signup/complete redirect target no longer varies by outcome. - Login attempt limiter is now namespaced per proof kind (password/passkey/ oidc/reauth) and, for password, scoped per client in addition to per account, so failed guesses from one client/method cannot deny a different proof or a different client for the same account. - Email sign-in and signup codes get a long-window (24h) per-account cap on top of the existing per-code ceiling. - Password hashing now queues briefly (bounded length and wait time) instead of refusing every caller immediately once two derivations are in flight. - OIDC link flow stores a session hash reference instead of the raw bearer token; flow binding is checked before a flow is consumed everywhere; email-change availability is no longer revealed before the second factor is consumed; the passkey-counter-only debug surface (dead code, no account check) is removed. - Documents the attempt-budget ceilings and password-hashing concurrency bound in SECURITY.md, and the enumeration-resistance contract in docs/JSON-API.md. findExternal (#465) is left in place: it is dead in production code but used across many existing tests as a verification helper, and removing it would require rewriting that test surface for no security benefit (it is a permission-gated read, not a mutation). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…t export Fixes #466, #467. - beforeRoleChange and onAccountStatusChanged now fire on every path that changes roles or lock/unlock status, not just /users/roles and /users/status: bulk role assignment through /account-operations (once per affected account, before anything is staged), /users/bulk lock/unlock (once per affected account), and a role/lock/unlock support case's creation (early veto feedback) and approval (the actual mutation point, since case approval applies atomically). docs/COMPOSING-A-SITE.md is updated to describe the full path coverage. - GET /audit/export now requires a reason and fresh authentication like other sensitive admin actions, and is itself audited (actor, range, count) via a new AuthService.adminAuditExport primitive — matching packages/admin/THREAT-MODEL.md's existing "audited reveal/export" claim, which this export previously did not satisfy. - The auth_audit retention cap (previously a silent, fixed 100000 rows) is now configurable (AuthOptions.auditRetention) and observable (AuthOptions.onAuditPruned) — bridged from the store's worker thread via a plain-data message, since a callback function cannot cross workerData's structured-clone boundary. Documented in packages/auth/SECURITY.md. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Fixes #468. - The CSRF token now embeds a purpose tag (urlcode-forms-csrf, domain- separated from other createSignedToken users sharing the host secret) and a random value carried in a new HttpOnly/Secure/SameSite=Strict/ __Host- double-submit cookie the extension sets on first render and reuses on later ones. A token minted for one browser (or a different flow) is refused for another; previously the signed payload was only {flow}, so any token minted for a flow admitted any caller. - An absent Origin header now falls back to Sec-Fetch-Site, then Referer, and is refused with neither rather than admitted by default. - Removed the unused `fields` parameter from `fail()`. - Non-single-use tokens within the TTL are an explicit, documented tradeoff (packages/forms/SECURITY.md) rather than a silent gap: the extension holds no per-token state (no store) to enforce single use. - Test coverage: a forged-CSRF-token test now runs against an unprotected mount (the existing "missing or forged" test only ever sent a missing token, and the one `csrf=forged` case targeted an auth-gated mount where 401 fired before forms code ran, so the rejection path was never exercised); added cross-flow and unbound-token cases, an explicit no-Origin/no-fallback-evidence refusal test, and an onSubmit test covering both the rejected and admitted paths. Also rebuilt packages/ui's dist/, which was stale relative to its already-fixed verifyHmac length guard (packages/ui/src/host/csrf.ts) — the forms test suite surfaced a 500 instead of 403 for a malformed signature until the rebuild. No source change in packages/ui. Co-Authored-By: Claude Sonnet 5 <[email protected]>
HEAD side effects, conditional writes, per-client idempotency Fixes #469. - The directory lock file now records a process-instance id alongside the PID, written atomically (temp file + link, closing the open/write TOCTOU window). A lock carrying our own PID but a different instance id is reclaimed as stale rather than refusing to start — a container restarted after an unclean exit routinely gets the same PID back, often PID 1. - A short-link's destination field must be declared `required: true`; activation refuses a collection that does not. Data written before that requirement existed can still be missing it (load() does not retroactively enforce required), so dispatchShortLink also checks at request time and answers 404 without counting a click, instead of a 302 to `Location: undefined`. - HEAD on a short link resolves the destination without counting a click; only GET does. - Single-record GET/HEAD, and the response to POST/PUT/PATCH, now carry a strong ETag; PUT, PATCH and DELETE honour an optional If-Match header and refuse a stale precondition with 412 instead of silently overwriting a concurrent writer's change. Omitting If-Match keeps the previous last-write-wins default. - Idempotency-Key retention is now scoped per network client (hashed together with the key into one opaque value), so two different callers choosing the same key no longer collide. docs/STORE.md and packages/store/SECURITY.md are updated in the same change. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
jimhoyd
force-pushed
the
claude/fix-extension-security-bugs
branch
from
September 22, 2026 20:41
293c294 to
c03a440
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes nine security/correctness bugs found by review across
packages/auth,packages/admin,packages/formsandpackages/store. Each fix includes a regression test that reproduces the original gap and proves it closed./signup/complete, forgot-password, send-email-code and factor-recovery all made account existence observable. Duplicate-email registration now returns a genuine-registration-shaped response backed by an unpersisted session; every delivery path now always attempts delivery (with a decoy token when ineligible) instead of skipping it conditionally.findExternalis left in place — see "Not fully addressed" below.beforeRoleChange/onAccountStatusChangednow fire on every path that changes roles or status (bulk/account-operations,/users/bulk, and support-case creation/approval), not just the single-account routes.GET /audit/exportnow requires a reason and fresh authentication and is itself audited; the audit-log retention cap is now configurable and observable instead of a silent fixed 100000 rows.Originfalls back toSec-Fetch-Site/Refererinstead of being admitted by default. Added a forged/cross-flow/unbound-token test that actually reaches the rejection path (the old test only ever sent a missing token).required; HEAD no longer counts a click; GET/PUT/PATCH/DELETE now supportETag/If-Match; idempotency keys are scoped per network client.Not fully addressed
findExternalis dead in production code (called only from tests) but is used across ~7 existing tests as a verification helper for unlink/recovery effects. Removing it would mean rewriting that test surface for no security benefit (it's a permission-gated read, not a mutation), so I left it in place rather than doing a shallow removal. Flagging this explicitly rather than silently dropping it.Test plan
npm run typecheck(root) — greennpm run lint— greennpm run check(code + docs, includes llms-full.txt/yaml-reference staleness checks) — greennpm run build(root) — greennpm test(root, core suite, 769 tests) — greennpm run verify:workspaces(ui/auth/admin/store/formsverify,audit:packages, workspace integration) — greennpm run test:package— not run; no packaging/CLI/starter changes in this PRFixes #461, Fixes #462, Fixes #463, Fixes #464, Fixes #466, Fixes #467, Fixes #468, Fixes #469
Partially addresses #465 (see "Not fully addressed" above; every item except
findExternalremoval is fixed).🤖 Generated with Claude Code