Skip to content

security: apply the approved DDL permission policy mix - #513

Draft
EnRaiha wants to merge 15 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/ddl-permission-checks
Draft

EnRaiha wants to merge 15 commits into
NodeDB-Lab:mainfrom
EnRaiha:fix/ddl-permission-checks

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Applies the approved DDL policy mix: Create permission for creation, owner-or-admin for existing objects, tenant_admin for tenant-wide statements. Introduces the ddl_authorization node setting (default open, no behavior change) and routes every covered statement through one shared authorize_ddl check.

ddl: require the Create permission to create a collection (a20ce808c)

CREATE COLLECTION, CREATE TABLE and CREATE TIMESERIES now check the Create permission on the target database before any other work. A caller without it gets SQLSTATE 42501. Adds a shared helper module with a create check and an owner-or-admin check.

ddl: require the Create permission to create a search index (80990c79c)

CREATE VECTOR, SEARCH, FULLTEXT, SPARSE and SPATIAL INDEX now check the Create permission on the target database before they read or change anything. A caller without it gets SQLSTATE 42501.

ddl: require the Create permission to create a sorted index (a232e9016)

CREATE SORTED INDEX now checks the Create permission on the target database before it parses the collection or builds the index. A caller without it gets SQLSTATE 42501.

ddl: require ownership or admin to alter a collection (abfd1ab5a)

ALTER COLLECTION and ALTER TABLE now run one owner-or-admin check before every sub-command. The caller must own the collection, hold tenant_admin, or be a superuser. A refusal is SQLSTATE 42501.

ddl: require ownership or admin to alter a timeseries collection (503888809)

ALTER TIMESERIES now checks that the caller owns the collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.

ddl: require ownership or admin to set vector metadata (4fc15b5bf)

ALTER COLLECTION SET VECTOR METADATA now checks that the caller owns the collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.

ddl: require ownership or admin to change constraints and period locks (a6e5e84ca)

ADD CONSTRAINT, DROP CONSTRAINT, ADD PERIOD LOCK and DROP PERIOD LOCK now check that the caller owns the collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501. Typeguard statements are unchanged.

ddl: require ownership or admin for maintenance and history statements (0585b7fbb)

COMPACT, REINDEX, CREATE CHECKPOINT, DROP CHECKPOINT and COMPACT HISTORY now check that the caller owns the collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.

ddl: require ownership or admin to convert a collection (3cc357a10)

CONVERT COLLECTION now checks that the caller owns the collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.

ddl: require ownership or admin for materialized view create and drop (6da720192)

CREATE MATERIALIZED VIEW on the periodic path needs ownership of the source collection or an admin role. DROP MATERIALIZED VIEW needs the view owner, the owner of the same-named collection, or an admin role. A refusal is SQLSTATE 42501.

ddl: format the permission helper module (a82e9f83e)

Formatting only, no behavior change.

config: add the ddl_authorization node setting (7215f833f)

The [auth] key ddl_authorization takes open, tenant_admin, permission, owner or mix. The default is open, which adds no check. The node reads the value once at startup into SharedState. Every node of a cluster must carry the same value. The RBAC docs list what each value requires.

ddl: route schema DDL checks through authorize_ddl (25caab47d)

authorize_ddl reads the ddl_authorization mode and applies one table for every covered statement. The mode open and a superuser pass at once. The create, change, drop and tenant-wide helpers call it. A materialized view create now follows the create action and a view drop the drop action. DROP COLLECTION and CREATE INDEX keep their own checks in every mode.

ddl: apply the DDL authorization mode to tenant-wide statements (159ec1e28)

Sequence create, alter and drop, ALTER SCHEDULE, the rate gate functions and permission tree set and drop call require_tenant_wide. Under the default mode open they pass as before. The other modes need TenantAdmin, or the Admin permission under permission.

CREATE COLLECTION, CREATE TABLE and CREATE TIMESERIES now check the Create
permission on the target database before any other work.
A caller without it gets SQLSTATE 42501.
Add a shared helper module with a create check and an owner-or-admin check.
CREATE VECTOR, SEARCH, FULLTEXT, SPARSE and SPATIAL INDEX now check the
Create permission on the target database before they read or change anything.
A caller without it gets SQLSTATE 42501.
CREATE SORTED INDEX now checks the Create permission on the target database
before it parses the collection or builds the index.
A caller without it gets SQLSTATE 42501.
ALTER COLLECTION and ALTER TABLE now run one owner-or-admin check before every
sub-command. The caller must own the collection, hold tenant_admin, or be a
superuser. A refusal is SQLSTATE 42501.
ALTER TIMESERIES now checks that the caller owns the collection, holds
tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.
ALTER COLLECTION SET VECTOR METADATA now checks that the caller owns the
collection, holds tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.
ADD CONSTRAINT, DROP CONSTRAINT, ADD PERIOD LOCK and DROP PERIOD LOCK now check
that the caller owns the collection, holds tenant_admin, or is a superuser.
A refusal is SQLSTATE 42501. Typeguard statements are unchanged.
COMPACT, REINDEX, CREATE CHECKPOINT, DROP CHECKPOINT and COMPACT HISTORY now
check that the caller owns the collection, holds tenant_admin, or is a
superuser. A refusal is SQLSTATE 42501.
CONVERT COLLECTION now checks that the caller owns the collection, holds
tenant_admin, or is a superuser. A refusal is SQLSTATE 42501.
CREATE MATERIALIZED VIEW on the periodic path needs ownership of the source
collection or an admin role. DROP MATERIALIZED VIEW needs the view owner,
the owner of the same-named collection, or an admin role.
A refusal is SQLSTATE 42501.
The [auth] key ddl_authorization takes open, tenant_admin, permission, owner or mix.
The default is open, which adds no check.
The node reads the value once at startup into SharedState.
Every node of a cluster must carry the same value.
The RBAC docs list what each value requires.
authorize_ddl reads the ddl_authorization mode and applies one table for every covered statement.
The mode open and a superuser pass at once.
The create, change, drop and tenant-wide helpers call it.
A materialized view create now follows the create action and a view drop the drop action.
DROP COLLECTION and CREATE INDEX keep their own checks in every mode.
Sequence create, alter and drop, ALTER SCHEDULE, the rate gate functions and permission tree set and drop call require_tenant_wide.
Under the default mode open they pass as before.
The other modes need TenantAdmin, or the Admin permission under permission.
…L owner-or-admin check

CREATE/ALTER/DROP TYPEGUARD and ALTER VECTOR INDEX SEAL/COMPACT/SET
carried no permission check at all, under every ddl_authorization
mode including the strictest. Any tenant member, not only the
collection's owner, could add, replace or drop schema-validation
guards on someone else's collection, or force-compact, seal, or
retune another owner's vector index (m, ef_construction, pq_m,
ivf_cells, ivf_nprobe), degrading its search quality or availability.

Both now call the same require_owner_or_admin check ADD/DROP
CONSTRAINT and COMPACT/REINDEX already carry, before any read or
mutation. A caller who is not the collection's owner, tenant_admin, or
superuser gets SQLSTATE 42501.

Adds the ddl_authorization harness knob (TestServer::start_with_ddl_authorization)
needed to exercise any of this PR's permission checks under a non-open
mode -- none of the 14 commits so far had one.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant