Skip to content

fix(security): platform admins see all rows of better-auth-managed identity objects (ADR-0024 / cloud#551) - #2406

Merged
os-zhuang merged 1 commit into
mainfrom
adr-0024-betterauth-obj-visibility
Jun 27, 2026
Merged

fix(security): platform admins see all rows of better-auth-managed identity objects (ADR-0024 / cloud#551)#2406
os-zhuang merged 1 commit into
mainfrom
adr-0024-betterauth-obj-visibility

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Why

managedBy: 'better-auth' identity tables (sys_oauth_application, sys_account, sys_session, sys_sso_provider, …) are written by better-auth's own adapter with no tenant context, so organization_id is never stamped and member_default's wildcard tenant_isolation RLS denies every row — a platform admin's Setup lists (OAuth Applications, Identity Links, …) render empty. (This is the systemic root of the sys_sso_provider list-empty issue I patched per-object earlier.)

What

Extend the posture-gated superuser bypass (today: private / tenancy.enabled:false) to managedBy:'better-auth' objects, so a platform admin's viewAllRecords sees all identity rows env-wide.

Admin-only, no member leak:

  • Members never trigger the bypass → their _self carve-outs / tenant_isolation still apply (regression test asserts a member stays tenant-scoped).
  • The new flag is deliberately not used in the wildcard-policy drop, so it can't expose rows to non-admins.
  • Only the platform super-admin (admin_full_accessviewAllRecords) is affected; org-admins (no '*' viewAllRecords) are not.

This fixes the whole class without per-object tenancy changes — important because some of these objects (sys_oauth_application) are cross-env-isolated in the control plane, so a global tenancy flag would be unsafe; the admin-bypass is.

Verification

  • 145 security-plugin tests green (incl. 2 new: admin bypassed / member tenant-scoped).
  • Browser E2E: a platform admin sees allsys_session rows (own + another user's); a plain member sees only their own.

🤖 Generated with Claude Code

…entity objects (ADR-0024 / cloud#551)
managedBy:'better-auth' identity tables (sys_oauth_application, sys_account,
sys_session, sys_sso_provider, …) are written via better-auth's adapter with no
tenant context → organization_id never stamped → member_default's wildcard
tenant_isolation RLS hides every row from a platform admin (empty Setup lists).
Extend the posture-gated superuser bypass (currently private/tenancyDisabled) to
managedBy:'better-auth' objects — ADMIN-ONLY (members never trigger the bypass;
their _self carve-outs / tenant_isolation still apply; the flag is NOT used in
the wildcard-drop, so no member leak). +2 regression tests (admin bypassed,
member tenant-scoped). 145 security tests green; E2E: admin sees all sessions,
plain member sees own.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 27, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJun 27, 2026 7:21pm

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/s labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-security.

8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/implementation-status.mdx(via @objectstack/plugin-security)
  • content/docs/concepts/packages.mdx(via @objectstack/plugin-security)
  • content/docs/getting-started/cli.mdx(via @objectstack/plugin-security)
  • content/docs/guides/cheatsheets/permissions-matrix.mdx(via packages/plugins/plugin-security)
  • content/docs/guides/metadata/dashboard.mdx(via @objectstack/plugin-security)
  • content/docs/guides/packages.mdx(via @objectstack/plugin-security)
  • content/docs/guides/plugins.mdx(via @objectstack/plugin-security)
  • content/docs/guides/security.mdx(via @objectstack/plugin-security)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

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

Labels

documentationImprovements or additions to documentationsize/steststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@os-zhuang