Skip to content

[SECURITY] Prevent user DDL from dropping StackQL control and unmanaged tables #823

Open

Description

@jeffreyaven

Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.

CWEs: CWE-284.

Finding and evidence

internal/stackql/primitivebuilder/ddl.go dispatches a user-supplied DROP target to the SQL system. DropPhysicalTable and DropMaterializedView delete catalog rows and issue physical DROP statements without first requiring a managed user-table/view entry (internal/stackql/sql_system/sqlite.go, internal/stackql/sql_system/sqlite.go). PostgreSQL has equivalent paths.

Current-build pgwire probe: DROP TABLE "__iql__.control.generation" succeeded against a disposable backend. A subsequent sqlite_master query confirmed the control table was gone. This required neither NATIVEQUERY for the deletion nor a SQL quoting breakout. New sessions then failed in the first reproduction because required control state was missing.

Required outcome

  • Restrict user DDL to catalog-managed user relations and protect internal/control/cache namespaces across DROP TABLE, DROP MATERIALIZED VIEW and replacement paths.
  • Validate before deleting catalog rows or physical objects; retain transaction consistency on failure.
  • Keep general per-client authorization separate from this engine invariant.

Validation and acceptance

Robot tests should attempt internal and unmanaged table drops without NATIVEQUERY, assert refusal and continued server liveness, and verify legitimate user table/materialized-view operations still work. Cover both backends, qualified/quoted names and CREATE OR REPLACE paths.

Scope and related work

#799 covers PURGE destroying user data; reuse that issue for purge semantics. #312 covers RBAC and shared view ownership. This issue specifically prevents ordinary DDL from deleting engine-owned relations.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions