fix(security): platform admins see all rows of better-auth-managed identity objects (ADR-0024 / cloud#551)#2406
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, soorganization_idis never stamped andmember_default's wildcardtenant_isolationRLS denies every row — a platform admin's Setup lists (OAuth Applications, Identity Links, …) render empty. (This is the systemic root of thesys_sso_providerlist-empty issue I patched per-object earlier.)What
Extend the posture-gated superuser bypass (today:
private/tenancy.enabled:false) tomanagedBy:'better-auth'objects, so a platform admin'sviewAllRecordssees all identity rows env-wide.Admin-only, no member leak:
_selfcarve-outs /tenant_isolationstill apply (regression test asserts a member stays tenant-scoped).admin_full_accessviewAllRecords) is affected; org-admins (no'*'viewAllRecords) are not.This fixes the whole class without per-object
tenancychanges — 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
sys_sessionrows (own + another user's); a plain member sees only their own.🤖 Generated with Claude Code