Skip to content

docs(adr): ADR-0092 修订 — D2 通用化为 registry 驱动的身份表写守卫#2808

Merged
os-zhuang merged 1 commit into
mainfrom
claude/sys-user-field-delegation-4p8l20
Jul 11, 2026
Merged

docs(adr): ADR-0092 修订 — D2 通用化为 registry 驱动的身份表写守卫#2808
os-zhuang merged 1 commit into
mainfrom
claude/sys-user-field-delegation-4p8l20

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

概要

按维护者评审意见修订 ADR-0092(首版 #2787 已合并):守卫机制从 sys_user 单表通用化为覆盖整个 managedBy: 'better-auth' 家族。仍为文档-only,状态保持 Proposed。

修订动机

首版调研发现的裸写漏洞(admin_full_access 可经 data API 直写任意列)对全部 11 张身份表成立,不只 sys_user —— 平台管理员今天同样可以裸插 sys_member 行(自授组织成员身份)、裸改 sys_api_key、裸删 sys_session,全部绕过 better-auth 的副作用。首版 D2 只堵了一张表;逐表复制守卫正是"第十二张表裸奔上线"的路径。

修订内容

  • D2 通用化before{Insert,Update,Delete} 守卫按 schema registry 的 managedBy 标志判定(无硬编码表清单),对全家族的用户上下文写入默认拒绝;唯一开口是按对象注册的 update 白名单(registerManagedUpdateWhitelist),首个条目 sys_user → {name, image}。内部写入(better-auth adapter、isSystem)照旧直通。
  • 范围说明:字段决策(D1)仍是 sys_user 专属;机制(D2)天然覆盖全家族 —— 未来"org admin 可编辑 sys_organization.name"只是一行白名单注册引用本 ADR,无需新 ADR。
  • Alternatives 增加"sys_user-only 守卫(首版方案)"条目,标记为被取代。
  • Risks / Rollout 相应更新:合并前需全量扫描调用点 + dogfood 验证(default-deny 可能暴露未知的合法用户上下文写路径);实现 issue 的测试矩阵扩展为逐表守卫用例。

D1 / D3–D6(字段分层、白名单同源派生、affordance 时序、权限拓扑、会话缓存失效)均保持首版不变。

相关

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21


Generated by Claude Code

… write guard

Review feedback on the merged first draft (#2787): the raw-write hole
that D2 closes is not sys_user-specific — every managedBy:'better-auth'
table relies on the same deny-by-permission-set + hide-by-affordance
combination, so admin_full_access can raw-write sys_member/sys_session/
sys_api_key rows through the generic data API just the same.

Revision keeps the sys_user field-tier decision (D1) unchanged and
generalizes the mechanism:

- D2 is now a generic before{Insert,Update,Delete} guard keyed off the
  schema registry's managedBy flag (no hardcoded table list), default-
  deny for user-context writes across the whole identity family, with a
  per-object update whitelist as the only opening — sys_user {name,
  image} is the first entry
- sys_user-only guard recorded under Alternatives as superseded
- risks + rollout updated accordingly (call-site sweep before merge,
  guard tests per table)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YGAN5VvvBi4YRGwpNT6e21
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 11, 2026 1:27am

Request Review

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation labels Jul 11, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review July 11, 2026 01:33
@os-zhuang
os-zhuang merged commit c3554e7 into main Jul 11, 2026
15 checks passed
@os-zhuang
os-zhuang deleted the claude/sys-user-field-delegation-4p8l20 branch July 11, 2026 01:34
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants