Repository navigation
fix(plugin-auth)!: a credential change ends access issued before it - #35664
Conversation
…rule module and its tests Claude-Session: https://claude.ai/code/session_012MmDsQg43GaB78K8X6U1sL Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012MmDsQg43GaB78K8X6U1sL Co-authored-by: Claude <noreply@anthropic.com>
…cal password; changeset and docs Claude-Session: https://claude.ai/code/session_012MmDsQg43GaB78K8X6U1sL Co-authored-by: Claude <noreply@anthropic.com>
…nge-ends-prior-access
… own code; its race case Claude-Session: https://claude.ai/code/session_012MmDsQg43GaB78K8X6U1sL Co-authored-by: Claude <noreply@anthropic.com>
…nge-ends-prior-access Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
… the narrowing is declared and the claim is as wide as the rule The changeset declares Clause-② no (narrowing) with its ADR-0087 disposition and BREAKING note; the changeset, the docs and the rule module name what the rule covers instead of claiming everything issued before the change; the after-hook's own docblock sits on the after-hook again, and the session re-end sits above the ADR-0069 D1 block. Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e3b79c3b21a0f453bbd8f4a44762342498a45fab && git checkout e3b79c3b21a0f453bbd8f4a44762342498a45fab
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c03a8a342805186e04e05d9903f7f1913b43dabe b5cbc6ad19fe850a64cb98c4bf553cbbb3d5a128 && git checkout -B drift-repro c03a8a342805186e04e05d9903f7f1913b43dabe && git merge --no-ff b5cbc6ad19fe850a64cb98c4bf553cbbb3d5a128
node scripts/docs-audit/affected-docs.mjs --json c03a8a342805186e04e05d9903f7f1913b43dabe
|
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract-review-claim: session_016WV4czt69hUUaG5XcgFNYL · head 4cb593b · 2026-11-19T23:08Z |
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract reviewServed-tier: Review face: narrowing ( Gate verdicts on this head (check-run conclusions): Test Core 1/10 to 10/10, TypeScript Type Check, Lint & Repo Gates, Check Changeset, PR-body guards, Governed Surface Queue Guard, Dogfood Regression Gate, Build Core, Build Docs, Spec property liveness: all ① Derived judgmentsThe rule: a credential change ends access issued before it. One predicate (
② Semver level
③ Boundary flags
④ Design judgment
Tests: thirteen cases through the real routes plus one on the one-step door; each of the four claims has a case and a control, and the staging moves the clock past the first-credential window before any change. S1 (should-fix) — S2 (should-fix) — the sign-in cases pin status and code only, and allow a S3 (should-fix) — "a check that cannot read its record refuses" is pinned for the clock as a unit only. No case drives a link, a challenge or a sign-in with an unreadable clock or a missing first reading, and none of the three ablation legs covers the N1 (nit) — in N2 (nit) — N3 (nit) — the changeset describes the refused link as the one mailed "to the new address"; the code judges every token carrying No must-fix. Implemented-by: VERDICT: PASS |
…pter; refusals that cannot read their record are pinned The clock behind "a credential change ends access issued before it" reads the account's credential row through better-auth's internal adapter, the seam its own password check reads, so a manager with no data engine judges links and challenges instead of refusing them all. New cases pin that a refused sign-in hands out no session token in its headers, that a link, a challenge and a sign-in whose record cannot be read are refused, and that the clock works on the vendor's in-memory adapter. The changeset names every email-change link the rule judges. Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
… through the vendor's adapter; the refusal cases pin what they claim The first reading of `/sign-in/phone-number` named its account through the data engine, so a manager without one took no reading and refused every phone sign-in. It now names the account with the lookup the vendor's phone door makes, through the vendor's adapter, as the email door already does. The case for a sign-in whose first reading cannot be taken compares the account's sessions before and after the refused sign-in (the session sign-up opened stands throughout), and a control sign-in afterwards adds one. The case for a manager without a data engine creates its account with the administrator's create-user called in-process, since no sign-up door admits an account without a data engine, and signs in at both password doors. Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
…le judges, at either step of the flow An email-change link is judged whichever step of the flow mailed it: the confirmation `POST /change-email` sends the current address, and the link to the new address, whether `/change-email` mails it directly or the confirmation step does. The changeset's parenthesis now says so. The predicate module's docblock paragraph on the clock is re-wrapped; no code moves. Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract-review-claim: session_016WV4czt69hUUaG5XcgFNYL · head b5cbc6a · 2026-11-20T01:50Z |
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract reviewServed-tier: This record replaces the one on Gate verdicts on this head (check-run conclusions, read once): 41 ① Derived judgmentsThe thirteen judgments of the prior record stand on this head. What the delta moves:
② Semver levelUnchanged and right: ③ Boundary flags
④ Design judgment
Prior findings on this head:
Fail-closed, path by path: no adapter, refuses; clock read throws, refuses; account lookup for a link throws, refuses; issue time missing, refuses once a change exists; challenge with no readable user, ended; first sign-in reading missing or unreadable, refused; second reading throws, refused. One arm answers the other way: N4 (nit) — a credential row that is read but carries no parseable No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Recorded 2026-11-20T04:47Z. Pre-landing notice for this PR's owner. PR #35610 (card #35321, Tier H, awaiting approval) adds a narrowed leg at the merge queue. Once #35610 merges, a pull that declares a narrowing, as this one does, is refused at the queue unless two things are on its head: an authorized approval (or the authorized account's own enqueue), and a standing PASS contract review at |
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract reviewServed-tier: This record replaces the one on Gate verdicts on this head (check-run conclusions, read once): 41 ① Derived judgmentsThe thirteen judgments of the prior record stand on this head. What the delta moves:
② Semver levelUnchanged and right: ③ Boundary flags
④ Design judgment
Prior findings on this head:
Fail-closed, path by path: no adapter, refuses; clock read throws, refuses; account lookup for a link throws, refuses; issue time missing, refuses once a change exists; challenge with no readable user, ended; first sign-in reading missing or unreadable, refused; second reading throws, refused. One arm answers the other way: N4 (nit) — a credential row that is read but carries no parseable No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
Requested by Elon · project thread
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under
skills/teaches these auth doors; the behaviour is documented incontent/docs/permissions/authentication.mdxin this diff维护者速读
What changes
One rule in
@objectstack/plugin-auth: a credential change ends access issued before it. One predicate (issuedBeforeCredentialChange) over one clock (readCredentialChangedAt: the last write over the account's local credential row, read through the vendor's owninternalAdapter.findCredentialAccount, the same row its password check reads, so the rule needs no data engine; the row's creation is the first password, not a change). Once an account's password changes, these, issued for that account before the change, no longer grant access:POST /api/v1/auth/change-emailmails, at either of its steps and to either address: the confirmation sent to the current address, and the link sent to the new one) minted before the change answers atGET /api/v1/auth/verify-emailexactly what a never-issued link answers:401 INVALID_TOKEN, or theerror=INVALID_TOKENredirect to its callback. The global before-hook hands the vendor's door a value no signer issued, so the vendor answers through its own path. Issue time is whole seconds, so a link minted in the same second as the change is refused too.POST /api/v1/auth/change-passwordwithrevokeOtherSessions: true(the session it installs is kept), and the one-step invitation acceptance (ahead of the session it opens).Every door that overwrites the credential row counts, an administrator's
POST /api/v1/auth/admin/set-user-passwordincluded. A check that cannot read its record refuses. Access issued after the change, and an account that never changed its local password, are untouched. No request, response or metadata shape changes.This PR resumes a branch that was built earlier and never opened. On top of it, this round:
mainonce (one conflict:invitation-one-step-acceptance-34257.test.ts, where both sides appended adescribeat the end of the file; both are kept, unchanged);mainchanged since the branch point: none of the touched doors moved. The operator's password reset thatmainadded writes the credential row'supdated_atand ends sessions after its write, so the same clock covers it with no change here;fix(plugin-auth)!,Clause-②: no (narrowing), the ADR-0087 disposition and a BREAKING note in the changeset);globalAfterHook(the new helpers had been inserted between them), and moved the session re-end above the ADR-0069 D1 comment block it had split from itsif.Read first (by risk)
packages/plugins/plugin-auth/src/credential-change-ends-prior-access.ts:readCredentialChangedAt(the clock overinternalAdapter.findCredentialAccount, and the one-second first-credential window),issuedBeforeChangeOf(refuses when the adapter is missing or throws) andrefuseSignInAcrossCredentialChange(ends the session it judged).packages/plugins/plugin-auth/src/auth-manager-after-hook.ts: the sign-in refusal at the top ofglobalAfterHook. It runs ahead of the impersonation and second-factor after-hooks, and its throw sits after the lockout settlement, so the attempt is counted as a wrong password.packages/plugins/plugin-auth/src/auth-manager-before-hook.ts: the/verify-emailtoken replacement returns early from the global before-hook (the request can only be refused from there).Two-minute check
After
pnpm --filter '@objectstack/plugin-auth^...' build:pnpm --filter @objectstack/plugin-auth exec vitest run src/credential-change-ends-prior-access.test.ts. ExpectTests 17 passed (17).Tests
credential-change-ends-prior-access.test.ts(new, 17 cases), driven through the real routes (a realAuthManagerover a realObjectQLengine on better-sqlite3, behindAuthPlugin.registerAuthRouteson Hono):/change-passwordand an administrator's/admin/set-user-passwordanswers what a never-issued link answers, with and without a callback; the address does not move and no session is opened. Control: a link minted after the reset verifies and moves the address;/change-passwordwithrevokeOtherSessions(the session it installs stands);dataEngine), a link for an account that never changed its password verifies, a link minted before/change-passwordgets the never-issued answer, and both password doors sign in;Datestamps).invitation-one-step-acceptance-34257.test.ts: one new case. A session opened before the one-step door writes the password is ended, and the session the door opens stands.Readings (local, final head
b5cbc6ad19f)All through
scripts/pm/os-verify-lock.sh(VERDICT command-exit 0).turbo run build --filter='@objectstack/dogfood^...' --concurrency=2): 70/70 tasks successful.pnpm --filter @objectstack/plugin-auth typecheck: exit 0 (check:test-typecheckOK).pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2:Test Files 288 passed (288),Tests 6050 passed | 10 skipped (6060).pnpm --filter @objectstack/dogfood test, no shard, no path):Test Files 482 passed | 3 skipped (485),Tests 4092 passed | 68 skipped (4160), no failures.scripts/ablation-replace.mjs(anchor hit once, mutation proven by blob hash, restore proven by blob == HEAD and an emptygit diff HEAD); the test file imports fromsrc:Tests 17 passed (17).2 failed | 15 passed(the link and challenge cases).1 failed | 16 passed(the first-reading case).2 failed | 15 passed(the phone control and the in-memory phone leg).4cb593b8cc0:4 failed | 13 passed(the in-memory case, the clock unit, both unreadable-clock cases).3 failed | 14 passed(each on "hands out no session token").4cb593b8cc0: the predicate answering "not before" turned 6 of 13 red; the sign-in refusal never refusing turned 2 of 13 red.Acceptance notes
Fixesline. This PR implements a seat order with no card.Verification
b5cbc6ad19f(node scripts/pm/dispatch-gates.mjs --commands, 101 commands): 99 exit 0; 2 NOT MEASURED locally (exit 3, PREREQUISITE NOT MET:check:skill-examples,check:dual-build-cjs-loads), both answered by CILint & Repo Gatessuccess.--ranreconciliation: 101 derived, 99 run, 2 NOT-MEASURED, 0 UNRUN.check:type-check-debtOK;check:nul-bytesOK;check-adr-0087-registration:not-required (no-migration-prescription);check-empty-changesetclean.b5cbc6ad19f: 40 success, 15 skipped, 0 failure (Test Core 1–10/10, type checks, all lint lanes, Dogfood Regression Gate, Check Changeset, PR-body guards, Governed Surface Queue Guard).Generated by Claude Code
🤖 Generated with Claude Code