Skip to content

Dispatch routine allowlist: isolated experiment

Status: test-only prototype, not a production allowlist or deployment. Run tests/dispatch_routine_allowlist_poc.sh. It uses disposable PostgreSQL and a temporary Rails copy, with no development database changes.

The fixture’s single reviewed SQL file is a fixed test manifest and reconciliation procedure. It verifies the only permitted schema routine by exact signature, exact fixture body, function kind, return type, language, SECURITY DEFINER, configured search path and permitted initial/current owner. It checks the schema owner and basic NOLOGIN role flags. In one transaction it then transfers the function to the restricted writer role and grants the app only EXECUTE on the allowed signature. The same test procedure succeeds twice.

The test uses Rails SQL dump and restore, verifies restoration starts with app execution denied, then confirms an unknown additional routine, a modified search path and a modified function body are rejected before the first grant. It verifies the test writer has only the fixture’s required table INSERT, cannot log in or bypass RLS, the app cannot assume that role or write directly, and missing/mismatched tenant context is rejected. Current production provisioning still rejects the app-executable fixture; the test explicitly expects that failure. It does not implement a unified production provisioner.

  • This is hard-coded fixture SQL, not a production manifest, and it does not create a real dispatch or implement graph validation or delivery. A role that owns a function or its schema can change it; runtime deployment boundaries and who can run ALTER FUNCTION must be separately enforced.
  • The test rejects tampering before the first grant. If a previously granted function is modified and later reconciliation fails, a transaction rollback also rolls back revocations performed inside that transaction. It would leave any earlier committed grant in place. A safe process must address disabling access, detecting drift and avoiding unsafe availability during reconciliation; the prototype does not solve this.
  • The advisory lock only serializes actors that voluntarily acquire it; it does not itself prevent an owner or administrator altering a routine concurrently. A production procedure needs a real concurrency and administrative trust model. Tests do not cover every role membership, object dependency, overload, grant, owner drift, routine body normalization or database version.
  • The fixture’s source-body comparison is a literal, not a robust cross-version signature or a tamper-proof manifest. The test verifies a narrow example; manifest protection, reviewed rollout and version compatibility are open.
  • Tenant context can be set by the app role. RLS and the function do not prove actor authorization, trusted assessment, or safety after app compromise.

Before connecting to provisioning or restore

Section titled “Before connecting to provisioning or restore”

Design the real trusted/versioned manifest, owner and routine lifecycle, matching of signatures and definitions, exact app/worker grants, controlled migration and rollback, and a failure path that cannot leave an unsafe old grant available. Integrate the same policy into provisioning and restore, then exercise those actual paths, including interrupted operations and adversarial role/DDL races. Until then, existing provisioning and restore remain fail-closed and no production routine should be enabled.