Skip to content

fix(plugin-auth): a session a password reset ends leaves a revocation trail - #29921

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/sec-hardening-j
Nov 3, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/sec-hardening-j

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:自助重置密码结束的会话,不再被直接删除,而是保留会话行并记下 revoked_at 与 revoke_reason: password_reset,与交互式撤销会话留下的记录同类;该会话照旧被拒(401)。
  • 为什么改:重置密码结束的会话此前不留任何撤销记录,审计查不到"这个会话是因重置密码而结束"。记录值与管理员强制重置的 admin_password_reset 不同,从记录即可分辨是谁结束了会话。
  • 风险与回滚:重置后会话行保留(与交互式撤销一样,sys_session 已有的保留方式),不改变哪些会话被结束,不撤销 API key,不写 logout 审计行。回滚 = 还原本 PR,无数据迁移。
  • 先看:packages/plugins/plugin-auth/src/session-tombstone.ts(INTERACTIVE_REVOKE_REASON 新增三行重置入口)、packages/plugins/plugin-auth/src/password-reset-ends-sessions.test.ts(新增的 describe)、packages/platform-objects/src/identity/sys-session.object.ts(revoke_reason 说明里的取值)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/password-reset-ends-sessions.test.ts,预期全部通过,其中 "a session a password reset ends leaves a revocation trail" 下三个用例通过。
  • 需要你做的:无,席位落地。

What changes

A session a password reset ends leaves a revocation trail.

  • INTERACTIVE_REVOKE_REASON (plugin-auth/src/session-tombstone.ts) gains every reset door with the value password_reset: /reset-password (the emailed link), /phone-number/reset-password (the phone OTP reset), and /email-otp/reset-password (better-auth's email-OTP reset door, on its own path; the platform does not mount that plugin today, so the entry is keyed on the plugin's declared path and pinned against it). A completed reset now keeps each session row it ends, stamped expires_at a second in the past, revoked_at, and revoke_reason: password_reset, instead of deleting it; the session is still refused.
  • The value differs from user_revoked (the owner revoking their own sessions) and from admin_password_reset, which an administrator's forced reset keeps writing itself (forced-reset-revocation.ts, not through this ledger), so the row still says who ended the session. The ledger's docblock and the password-reset-ends-sessions.ts header now say what is true.
  • The reset doors are revocations, not erasures: they are not in SESSION_ERASURE_PATHS, so their tombstones stay hidden from better-auth's session reads like every other.
  • sys_session.revoke_reason's description, the field's published vocabulary, names password_reset (platform-objects), with the four translated help strings (en regenerated, zh-CN / ja-JP / es-ES hand-written values extended the same way).
  • docs/HARDENING.md: the session table's revocation row said the reset path deletes the row; it now says sign-out deletes, and a revoke or a completed reset keeps the row stamped.
  • Out of scope by the ruling, and unchanged: no API key is revoked by a self-service reset, and no logout audit row is written.

Tests

  • password-reset-ends-sessions.test.ts, new top-level describe "a session a password reset ends leaves a revocation trail", over the file's existing real-engine harness (AuthManager.handleRequest, ObjectQL over better-sqlite3):
    • the emailed-link reset stamps every earlier session password_reset, and the session still answers 401 UNAUTHENTICATED;
    • the phone OTP reset does the same;
    • the control: an administrator's forced reset (runAdminSetUserPassword, with the deps auth-plugin.ts hands it, over the same engine) still stamps admin_password_reset.
  • session-tombstone.test.ts: every reset door records password_reset, and no ledger route writes the forced reset's value; the mounted-route check now also reads the phone-number family off a manager that mounts it; the email-OTP door is pinned to the vendor plugin's declared path, with a tripwire that it is not mounted today.
  • forced-reset-revoke-reason-vocabulary.test.ts: the published vocabulary names every value the interactive-revoke ledger writes.

Acceptance notes

  • The vendor's bulk delete does not bypass the per-row reconcile on these doors, measured on better-auth 1.7.12: resetCredentialPassword calls internalAdapter.deleteUserSessions, which with no secondaryStorage is deleteManyWithHooks, which calls this adapter's deleteMany inside the endpoint's context; outside a SCIM request the adapter's transaction hands the callback this same adapter. The two door tests are the measurement.
  • Other vendor routes that bulk-end a user's sessions outside both ledgers still delete their rows, /change-password with revokeOtherSessions among them. Not touched; the ruling covers the reset doors only.

Verification

All readings below are on head c8b82289a5 (the branch with origin/main merged), unless a line names another commit. Heavy runs went through scripts/pm/os-verify-lock.sh on a shared box.

Tests: targeted, full suites, typecheck
  • Build state refreshed after the merge: pnpm install --frozen-lockfile exit 0; closure build (turbo run build over plugin-auth, platform-objects, the CLI and the i18n gate's packages) exit 0; pnpm --filter @objectstack/spec check:generated exit 0, "All 14 generated artifacts are up to date".
  • Targeted: pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/password-reset-ends-sessions.test.ts src/session-tombstone.test.ts src/forced-reset-revoke-reason-vocabulary.test.ts exit 0, Test Files 3 passed (3), Tests 34 passed (34).
  • @objectstack/plugin-auth full suite (vitest run --maxWorkers=2): exit 0, Test Files 219 passed (219), Tests 3766 passed, 10 skipped (3776).
  • pnpm --filter @objectstack/plugin-auth typecheck: exit 0 (check:test-typecheck OK, ledger held).
  • @objectstack/platform-objects suite: exit 0, Test Files 110 passed (110), Tests 1512 passed (1512); its typecheck: exit 0.
  • The same set was green before the merge too, on 78fd3bcf11.
One-shot ablation (on 78fd3bc)

Mutation: the three reset-door rows taken back out of INTERACTIVE_REVOKE_REASON (the ledger as origin/main has it), through scripts/ablation-replace.mjs (anchor hit 1 time, blob 7d3ba6a6d90b to d138b54ac6d4; 'password_reset' rows on disk 3 to 0). The subject is imported from src/ by relative path, so no build sits between the mutation and the run.

  • Expected direction: red. Observed: Test Files 3 failed (3), Tests 4 failed, 30 passed (34). Red: the emailed-link door and the phone OTP door (the earlier session row is gone: kept: false), the ledger's reset-door test, and the vocabulary test. The forced-reset control stayed green.
  • Restore: git checkout HEAD -- on the absolute path, blob back to 7d3ba6a6d90b equal to HEAD, git diff HEAD empty, rows on disk 3.
Derived gates (dispatch-gates, 64 commands)

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 64 commands, every one run on c8b82289a5 with its exit code captured before any pipe. 62 exit 0, including pnpm check:i18n ("all bundles in sync": the hand-written en help string matches the generator's output) and pnpm check:engine-double-contract. --ran reconciliation: 64 derived, 62 run, 2 NOT-MEASURED, 0 UNRUN.

  • NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: exit 3, PREREQUISITE NOT MET, it reads the built output of every workspace package and 10 have no dist/ in this worktree. CI's Lint & Repo Gates runs it.
  • NOT MEASURED: pnpm check:type-check-debt, reason: exit 3, its re-measure build never got a turn on the shared verify lock (another session's full dogfood run held it). Both changed packages' own typecheck (test layer included) is green above. CI runs the gate.

Generated by Claude Code

…n trail

Pins, per reset door at the plugin harness, that every session the
account held is still a sys_session row after a completed reset, stamped
revoked_at and revoke_reason password_reset, and still answers 401; the
control is an administrator's forced reset, which stamps
admin_password_reset. The ledger tests name every reset door.

Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj
Co-authored-by: Claude <noreply@anthropic.com>
… trail

Every reset door (/reset-password, /phone-number/reset-password, and the
email-OTP door on its own path) joins the interactive-revoke ledger with
the value password_reset, so a session a completed reset ends is stamped
in place (revoked_at, revoke_reason) instead of deleted, and stays
refused. The value differs from the forced reset's admin_password_reset.
sys_session.revoke_reason's published vocabulary names it.

Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj
Co-authored-by: Claude <noreply@anthropic.com>
…w says what a reset leaves

Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/plugin-auth, touching 4 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/plugins/plugin-auth/src/password-reset-ends-sessions.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/deployment/environment-variables.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/kernel/contracts/cache-service.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/kernel/runtime-services/audit-service.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/permissions/authentication.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/permissions/authorization.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-2.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/releases/v17/17-3.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))
  • content/docs/releases/v17/17-4.mdx (via sys_session (symbol, a field of const object enObjects; a field of const object esESObjects; a field of const object jaJPObjects; a field of const object zhCNObjects))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/plugins/plugin-auth/src/password-reset-ends-sessions.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 23 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a04e9d76c13363280bdd86950603f0e0e6deb6dd → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 9194786f3109a91c1c18b46ad15646a7002350c4 — the merge of head c8b82289a52972a6de3527192d8ae194f806f600 into base a04e9d76c13363280bdd86950603f0e0e6deb6dd, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 9194786f3109a91c1c18b46ad15646a7002350c4 && git checkout 9194786f3109a91c1c18b46ad15646a7002350c4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a04e9d76c13363280bdd86950603f0e0e6deb6dd c8b82289a52972a6de3527192d8ae194f806f600 && git checkout -B drift-repro a04e9d76c13363280bdd86950603f0e0e6deb6dd && git merge --no-ff c8b82289a52972a6de3527192d8ae194f806f600

node scripts/docs-audit/affected-docs.mjs --json a04e9d76c13363280bdd86950603f0e0e6deb6dd

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs a04e9d76c13363280bdd86950603f0e0e6deb6dd → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj

席位核对

ACCEPT · head c8b82289a52972a6de3527192d8ae194f806f600 · 2026-11-03T13:08Z

  • Shape: 12 files, +261/−21, not governed, under 3000. Patch for plugin-auth and platform-objects; Clause-②: no; Metadata-protocol: none.
  • Rule held (the maintainer's ruling, item 4 of the third batch: audit only): a session that a completed self-service password reset ends leaves a revocation trail. The reset doors are in INTERACTIVE_REVOKE_REASON with password_reset, which is distinct from the forced reset's admin_password_reset. The row is kept and stamped, and the session still answers 401. No API key is revoked. No logout audit row is written.
  • Review face: no contract-review face applies (no narrowing, no published schema, no governed text). Per contract-review.md, the seat's own read plus CI is the review. Diff read by the seat: the ledger rows, the two docblocks, the published revoke_reason vocabulary on sys_session (with its translated help), HARDENING.md, and the changeset. Everything is consistent with the ruling.
  • Measured by the dev: better-auth 1.7.12's bulk deleteUserSessions reaches the adapter's per-row reconcile. The door tests and the ablation confirm the stamp, and the forced-reset control stays green.
  • Check-runs at this head: 36 success, 13 skipped, 0 failed, all completed. Skips were judged by name. check-expected-skips.mjs NOT MEASURED. mergeable_state is clean.
  • Accepted deviations: the platform-objects vocabulary patch (precedent fix(platform-objects): sys_session.revoke_reason description names admin_password_reset #23518); the HARDENING.md row corrected; the unmounted email-OTP door ledgered on its own path with a not-mounted tripwire; two local gates NOT MEASURED (check:dual-build-cjs-loads, check:type-check-debt), both answered by CI.
  • Out of scope: other vendor routes that bulk-end sessions (e.g. change-password with revoke-others) still delete their rows. No contract promises a trail there; noted only.
  • Landing: ready, then auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant