Repository navigation
Conversation
…n-superuser CREATE USER ... ROLE superuser and ALTER USER SET ROLE superuser now apply the same guard as GRANT superuser. A caller without the superuser flag receives SQLSTATE 42501.
ALTER USER, DROP USER, GRANT and REVOKE role, CREATE API KEY, REVOKE API KEY, DROP ROLE and ALTER ROLE now resolve the target inside the caller's tenant. LIST API KEYS returns only keys of the caller's tenant. A superuser keeps access to every tenant. A target of another tenant answers 42704.
COPY (BACKUP TENANT n) and COPY tenant_restore(n) compare n with the caller's tenant before the BACKUP permission check. A caller without the superuser flag receives SQLSTATE 42501 for another tenant.
LIST AUTH KEYS drops keys whose tenant differs from the caller's tenant. A superuser still lists every tenant.
…tenant SHOW DELEGATIONS, REVOKE DELEGATION, SHOW ORGS, SHOW MEMBERS OF ORG, SHOW SCOPE GRANTS, SHOW SCOPES FOR, SHOW USAGE and SHOW QUOTA resolve the owning auth user or org and compare its tenant with the caller's tenant. An id with no record is not visible to a non-superuser. A superuser keeps access to every tenant.
…okup A caller with neither the superuser flag nor the tenant_admin role receives SQLSTATE 42501 before the entry is read.
The entry gate and the delta collection gate refuse an authenticated sync session whose tenant is unset. Frames no longer reach the tenant 0 fallback in the engine handlers. Existing handler tests set a tenant on their authenticated sessions.
The static and single-vshard builders compare each task tenant with the class tenant. A task of another tenant returns BadRequest before any key set is built.
register_table_identity returns an error when a table key already names another database, tenant or collection. Write, atomic, restore and undo paths propagate it. Index and checkpoint registration paths register nothing on a conflict. KvWriteRefusal and AtomicError gain an identity conflict variant, mapped to an internal error.
PlanCacheKey carries the tenant and database of the caller. Two callers share a cached plan only when both match.
…grantees GRANT SCOPE accepts ORG, USER, ROLE and TEAM as the grantee type. grantee_visible() only special-cased org, falling through to the auth-user lookup for everything else. A role or team id is never an auth user id, so the lookup always missed, and a non-superuser's own role-type and team-type scope grants were silently dropped from SHOW SCOPE GRANTS, even inside their own tenant. Fails closed (no leak), but breaks a legitimate same-tenant admin query with no error. A role grantee now resolves through the existing role_in_caller_tenant check, the same one role assignment already uses. No team registry exists yet, so a team grantee has no tenant to compare and stays visible to a superuser only, same as before.
This branch has not been deployed
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.
Fixes 11 operations across gateway, kv, sync, calvin, ddl and backup that skipped the caller's tenant-boundary check, letting a caller read, list, or act on another tenant's rows, keys, sessions, tasks, or auth records.
ddl: refuse the superuser role in CREATE USER and ALTER USER for a non-superuser(d89c5a161)CREATE USER ... ROLE superuserandALTER USER SET ROLE superusernow apply the same guard asGRANT superuser. A caller without the superuser flag receives SQLSTATE42501.ddl: compare the target user's tenant with the caller's tenant(f00ed895d)ALTER USER,DROP USER,GRANTandREVOKErole,CREATE API KEY,REVOKE API KEY,DROP ROLEandALTER ROLEnow resolve the target inside the caller's tenant.LIST API KEYSreturns only keys of the caller's tenant. A superuser keeps access to every tenant. A target of another tenant answers42704.backup: refuse a tenant id other than the caller's tenant(a3f2941c4)COPY (BACKUP TENANT n)andCOPY tenant_restore(n)comparenwith the caller's tenant before the BACKUP permission check. A caller without the superuser flag receives SQLSTATE42501for another tenant.ddl: list only the caller's tenant in LIST AUTH KEYS(e90e7df3b)LIST AUTH KEYSdrops keys whose tenant differs from the caller's tenant. A superuser still lists every tenant.ddl: limit delegation, org, scope and quota listings to the caller's tenant(0a7b66ad4)SHOW DELEGATIONS,REVOKE DELEGATION,SHOW ORGS,SHOW MEMBERS OF ORG,SHOW SCOPE GRANTS,SHOW SCOPES FOR,SHOW USAGEandSHOW QUOTAresolve the owning auth user or org and compare its tenant with the caller's tenant. An id with no record is not visible to a non-superuser. A superuser keeps access to every tenant.ddl: require tenant_admin for REQUEUE TRIGGER DLQ before the entry lookup(bdcc0ed84)A caller with neither the superuser flag nor the
tenant_adminrole receives SQLSTATE42501before the entry is read.sync: refuse a session that has no tenant(301589a6d)The entry gate and the delta collection gate refuse an authenticated sync session whose tenant is unset. Frames no longer reach the tenant 0 fallback in the engine handlers. Existing handler tests set a tenant on their authenticated sessions.
calvin: refuse a static task set that mixes tenants(221ab98e7)The static and single-vshard builders compare each task tenant with the class tenant. A task of another tenant returns
BadRequestbefore any key set is built.sync: format the tenant lines in the handler tests(00c67a305)Test-only formatting, no behavior change.
kv: refuse a second identity for one table key(8cff3156e)register_table_identityreturns an error when a table key already names another database, tenant or collection. Write, atomic, restore and undo paths propagate it. Index and checkpoint registration paths register nothing on a conflict.KvWriteRefusalandAtomicErrorgain an identity conflict variant, mapped to an internal error.gateway: key the plan cache by tenant and database(4222ab63e)PlanCacheKeycarries the tenant and database of the caller. Two callers share a cached plan only when both match.