You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: auth low-severity flow hardening and dead passkey/external-lookup code #465
main at d939969 (static source review; not executed against a deployment). Node/OS/deployment: not applicable.
Minimal reproduction
Reported by review, not independently reproduced. Grouped because each item is low severity. Exploit-level detail is intentionally omitted per SECURITY.md.
Raw session token stored in a flow record. The OIDC link flow stores the caller's session token (encrypted) in auth_flows (packages/auth/src/auth-flows.ts lines 101 and 133). packages/auth/SECURITY.md:17 says session tokens are stored only as hashes.
Fix: store a reference (session hash plus account id) and re-authenticate from the cookie on return, or narrow the SECURITY.md claim.
Flows consumed before the browser binding is checked.consumeFlow runs before checkBinding (auth-flows.ts lines 114-117; also 173, 188, 224), so a request from the wrong browser still burns the flow.
Fix: check the binding before consuming, or consume atomically only when the binding matches.
Email change reveals address availability before the second factor.email_unavailable is returned before the factor is consumed (packages/auth/src/auth-store.ts lines 1583-1584).
Fix: verify the factor first, then report availability.
Dead code.
advancePasskeyCounter (auth-core.ts:1380) and the store's advancePasskey case (auth-store.ts:1130, which updates a counter without an account check) are called only from tests.
findExternal (auth-core.ts:1325) is called only from tests.
Fix: remove them, or give advancePasskey an account check if it stays public.
Partial progress in #494 (merged): raw session tokens are no longer stored in auth_flows (session-hash-only storage), the browser binding is now checked before a flow is consumed, email-change availability is no longer disclosed ahead of the second factor, and the dead advancePasskeyCounter/store advancePasskey case was removed.
Not done, left open deliberately:findExternal (auth-core.ts:1325) was kept — it's a permission-gated read used by roughly 7 existing tests, with no security defect of its own (it doesn't mutate anything or leak data beyond what the caller is already authorized to see). Removing it would mean rewriting that test surface for no security benefit, so it wasn't touched. If it should still go, that's a small standalone cleanup: delete the export and inline/rewrite the ~7 call sites in its test file.
Closing out the deferred item from this issue: I re-verified whether findExternal (packages/auth/src/auth-core.ts) is safe to remove, and it is not — leaving it in place.
findExternal is declared as a member of the exported AuthService interface (auth-core.ts:400), and AuthService is re-exported as a public type from the package's entry point (packages/auth/src/index.ts: export type { AuthService, ... } from './auth-core.ts';). It sits alongside the other external-identity methods on that same interface (linkExternal, createExternalAccount, getExternalProof), so it's part of the package's documented public contract, not an orphaned internal helper — even though within this repository's own src/ tree only the 7 test call sites (across admin-account-operations.test.ts, manual-recovery-http.test.ts, mailbox-claim.test.ts, auth-core.test.ts, manual-recovery.test.ts) exercise it directly. Production code paths (admin account removal, mailbox-claim, manual recovery) don't need to call it themselves, but external integrators building on AuthService — e.g. checking whether a provider/subject pair is already linked before calling createExternalAccount, or building custom admin/support tooling — would reasonably use it, the same way they'd use getExternalProof or getUser.
It isn't listed in packages/auth/docs/JSON-API.md, but that page documents the HTTP contract, not the raw TypeScript AuthService surface — several of its interface siblings (getExternalProof, linkExternal) aren't listed there either, so absence from that page isn't a signal of dead code for this interface.
No security defect, no dead-code finding — leaving findExternal as-is. No code change in this pass; verified npm run typecheck stays green on the current state. Not closing this issue on this comment alone, in case a maintainer wants to reclassify it, but I'd consider the deferred findExternal question resolved.
Re-verified against current main: all three remaining hardening items are already fixed via #494.
Raw session token in OIDC link flow — packages/auth/src/auth-flows.ts (~95-106, 139-140) stores only sessionReference(actorToken) (a hash), never the raw token, with a comment citing SECURITY.md's "stored only as hashes" claim.
Consume-before-binding-check ordering — every flow-consuming call site (auth-flows.ts OIDC callback ~121-123, enroll ~185-187, complete ~201-203, passkey ceremonies ~238-240) now calls peekFlow/checkBinding before consumeFlow; auth-core.ts (~395-399) documents this ordering as part of the AuthService contract.
Email-availability disclosure before second factor — packages/auth/src/auth-store.ts (~1657-1672) calls consumeFactor before checking email_unavailable/email_unchanged.
findExternal was left untouched, consistent with the earlier decision on this issue that it's part of the public AuthService contract, not dead code.
Verification run: npm run typecheck green; packages/auth test suite 213/213 passing, including the binding-check-before-consume and email-availability-after-factor regression tests.
Activity
fix(auth): close account-enumeration, rate-limit and flow-binding gaps
fix(auth): close account-enumeration, rate-limit and flow-binding gaps
Fix account-enumeration, rate-limit, CSRF-binding and store-lock secu…
jimhoyd commentedon Sep 22, 2026
Partial progress in #494 (merged): raw session tokens are no longer stored in
auth_flows(session-hash-only storage), the browser binding is now checked before a flow is consumed, email-change availability is no longer disclosed ahead of the second factor, and the deadadvancePasskeyCounter/storeadvancePasskeycase was removed.Not done, left open deliberately:
findExternal(auth-core.ts:1325) was kept — it's a permission-gated read used by roughly 7 existing tests, with no security defect of its own (it doesn't mutate anything or leak data beyond what the caller is already authorized to see). Removing it would mean rewriting that test surface for no security benefit, so it wasn't touched. If it should still go, that's a small standalone cleanup: delete the export and inline/rewrite the ~7 call sites in its test file.jimhoyd commentedon Sep 22, 2026
Closing out the deferred item from this issue: I re-verified whether
findExternal(packages/auth/src/auth-core.ts) is safe to remove, and it is not — leaving it in place.findExternalis declared as a member of the exportedAuthServiceinterface (auth-core.ts:400), andAuthServiceis re-exported as a public type from the package's entry point (packages/auth/src/index.ts:export type { AuthService, ... } from './auth-core.ts';). It sits alongside the other external-identity methods on that same interface (linkExternal,createExternalAccount,getExternalProof), so it's part of the package's documented public contract, not an orphaned internal helper — even though within this repository's own src/ tree only the 7 test call sites (acrossadmin-account-operations.test.ts,manual-recovery-http.test.ts,mailbox-claim.test.ts,auth-core.test.ts,manual-recovery.test.ts) exercise it directly. Production code paths (admin account removal, mailbox-claim, manual recovery) don't need to call it themselves, but external integrators building onAuthService— e.g. checking whether a provider/subject pair is already linked before callingcreateExternalAccount, or building custom admin/support tooling — would reasonably use it, the same way they'd usegetExternalProoforgetUser.It isn't listed in
packages/auth/docs/JSON-API.md, but that page documents the HTTP contract, not the raw TypeScriptAuthServicesurface — several of its interface siblings (getExternalProof,linkExternal) aren't listed there either, so absence from that page isn't a signal of dead code for this interface.No security defect, no dead-code finding — leaving
findExternalas-is. No code change in this pass; verifiednpm run typecheckstays green on the current state. Not closing this issue on this comment alone, in case a maintainer wants to reclassify it, but I'd consider the deferredfindExternalquestion resolved.jimhoyd commentedon Sep 23, 2026
Re-verified against current
main: all three remaining hardening items are already fixed via #494.packages/auth/src/auth-flows.ts(~95-106, 139-140) stores onlysessionReference(actorToken)(a hash), never the raw token, with a comment citing SECURITY.md's "stored only as hashes" claim.auth-flows.tsOIDC callback ~121-123, enroll ~185-187, complete ~201-203, passkey ceremonies ~238-240) now callspeekFlow/checkBindingbeforeconsumeFlow;auth-core.ts(~395-399) documents this ordering as part of theAuthServicecontract.packages/auth/src/auth-store.ts(~1657-1672) callsconsumeFactorbefore checkingemail_unavailable/email_unchanged.advancePasskeyCounterand the store'sadvancePasskeycase no longer exist anywhere inpackages/auth/src(removed in Fix account-enumeration, rate-limit, CSRF-binding and store-lock security gaps #494 along with their test coverage).findExternalwas left untouched, consistent with the earlier decision on this issue that it's part of the publicAuthServicecontract, not dead code.Verification run:
npm run typecheckgreen;packages/authtest suite 213/213 passing, including the binding-check-before-consume and email-availability-after-factor regression tests.No further code change needed — closing.