RFC-0053 view security contract proposal
Versioned draft snapshot
RFCs, reference catalogs, and evidence reflect Spec 3b2e3e7a114fb826b1445d39a48756b8fff629cd. Counts and pending/status notes belong to that snapshot. Read the dated project update for later progress.
Source repositories are private during staging. Links marked “repository access required” need access to the linked repository.
This is a trace and gap record from the pinned draft specification. It does not establish proof or implementation conformance.
Status: proposed, awaiting owner decision. Owners: Storage, Security, Compiler. No normative contracts changed. The PostgreSQL probe reproduces failures in the current contract on PostgreSQL 14.24.
Recommended first-release contract
Ordinary views
Require PostgreSQL 15 or later for this view-mapping feature. Emit entity and
join views with both security_barrier = true and security_invoker = true.
The latter makes PostgreSQL use the caller’s base-relation privileges and RLS
policy context, as specified in the
PostgreSQL 15 documentation.
Reject feature installation on older servers before emitting DDL. This is a
feature support floor, not a claim that the complete adapter works on every
later version; the release matrix must test the supported versions explicitly.
Grant callers the minimum SELECT privileges needed on views, base relations, and policy dependencies. Caller roles MUST NOT be owners, superusers, holders of BYPASSRLS, or members able to assume those roles. Preserve graph principal and session authorization in the base-table policy; SQL role context alone does not replace the Gnomon principal model. Verify privileged maintenance access separately from ordinary application access.
For Phase 1, revoke INSERT, UPDATE, DELETE, and TRUNCATE on views and underlying storage from application roles, including inherited and PUBLIC grants. Grant only SELECT. Absent INSTEAD OF triggers is not the enforcement mechanism. When Phase-2 writes are enabled, grant only the approved view operations after installing validated write-through triggers; retain the prohibition on direct base-table DML. Define and test the trigger execution principal and privileges before granting these writes.
Cached results
Use a maintained ordinary cache table when cached results require per-row RLS. Do not emit ENABLE ROW LEVEL SECURITY or CREATE POLICY on native PostgreSQL materialized views. Own the table with a dedicated maintenance role that application callers cannot assume; enable RLS and provide application callers only the approved read path.
Each cache row must retain enough source resource identity to authorize its read against current grants and current authoritative session state. Any permission-cache optimization must respect the approved invalidation contract; it cannot authorize a row using stale grants after revocation. Cache refresh must publish a complete generation atomically so reads do not see a partially replaced result set.
Reject cached cross-resource aggregates for the first release unless a specified dependency/authorization rule proves that every contributing source is readable by the caller. A kind-only permission check is insufficient for resource-specific access. This requirement preserves the ordinary view’s authorization semantics; it does not promise an unimplemented aggregate mode.
Exact source changes after approval
| Source | Change |
|---|---|
| RFC-0053 §§1–3, §5.1–5.2, §8 | Add feature version floor, invoker option, caller/owner constraints, and base-relation grants. |
| RFC-0053 §6.1, §7 | Replace absent-trigger rejection claim with explicit Phase-1 privilege policy; define Phase-2 grant transition. |
| RFC-0053 §2, §5.3, §9, §10.2 | Replace native materialized-view RLS examples with policy-bearing ordinary cache tables and refresh semantics. |
| RFC-0051 permissions/adapter contract | Map caller role constraints, principal/session checks, and cache maintenance ownership to actual grants. |
| Lean, reference catalogs, RDF | Regenerate approved facts and summaries, retaining logical/storage identity distinctions. |
Acceptance
- Run PostgreSQL conformance on every supported release-matrix version; fail installation on an unsupported feature version.
- Compare base-table, entity-view, and joined-view visibility for two principals with disjoint grants, including a view owned by a privileged installer.
- Attempt all Phase-1 write commands on simple and computed view columns; check effective privileges through inherited roles and PUBLIC.
- Verify Phase-2 triggers enforce validation, current authorization, hooks, audit, and provenance; prohibit application direct-table mutation.
- Test cache reads before and after grant/session revocation, refresh failure, concurrent reads during refresh, and aggregate rejection without a proven dependency authorization rule.
- Run source/generated drift and artifact-fed consumer gates. Documentation and the existing PostgreSQL-14 failure probe are insufficient evidence that this proposed implementation passes.
Alternative: support PostgreSQL 14 with explicitly constrained non-bypass view-owner roles and policy-context rules. This requires a separate tested owner model rather than the caller-context contract above. Keeping native materialized views behind a separately authorized API is also possible, but does not satisfy the current promise of directly queryable per-row RLS SQL.