pgsql: Check for USAGE privilege on types used by stored expressions.

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check for USAGE privilege on types used by stored expressions.
Date: 2026-08-10 13:41:20
Message-ID: E1wtQFk-00000000y1z-46D4@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check for USAGE privilege on types used by stored expressions.

This omission allowed roles without USAGE on a type to create
stored expressions that depend on it, which could prevent the owner
from changing the type later.

The checks deliberately live in the command paths rather than the
dependency-recording routines. Those routines also run whenever
the server re-derives an existing expression, and re-checking there
would break routine maintenance for an owner who has since lost
USAGE on a type its objects already reference. (Checking in the
dependency-recording routines would also require additional
CommandCounterIncrement() calls to avoid spurious errors.)

The addition of a parameter to AlterDomainAddConstraint() breaks
ABI compatibility, but we are unaware of any impacted third-party
code.

Reported-by: Noah Misch <noah(at)leadboat(dot)com>
Author: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Security: CVE-2026-6470
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4fac4c1085ab12a811f2285b189979e844ceb670
Author: Nathan Bossart <nathan(at)postgresql(dot)org>

Modified Files
--------------
src/backend/catalog/dependency.c | 76 ++++++++++++++++++++++++++++++++
src/backend/catalog/heap.c | 22 +++++++++
src/backend/catalog/index.c | 3 ++
src/backend/catalog/pg_attrdef.c | 3 ++
src/backend/catalog/pg_constraint.c | 3 ++
src/backend/catalog/pg_proc.c | 6 +++
src/backend/catalog/pg_publication.c | 4 ++
src/backend/catalog/pg_type.c | 6 +++
src/backend/commands/indexcmds.c | 16 +++++++
src/backend/commands/policy.c | 8 ++++
src/backend/commands/propgraphcmds.c | 7 +++
src/backend/commands/statscmds.c | 5 +++
src/backend/commands/tablecmds.c | 19 +++++++-
src/backend/commands/trigger.c | 5 +++
src/backend/commands/typecmds.c | 33 +++++++++++---
src/backend/parser/parse_utilcmd.c | 10 +++++
src/backend/rewrite/rewriteDefine.c | 2 +
src/backend/tcop/utility.c | 3 +-
src/include/catalog/dependency.h | 4 ++
src/include/commands/typecmds.h | 3 +-
src/test/regress/expected/privileges.out | 46 +++++++++++++++++++
src/test/regress/sql/privileges.sql | 43 ++++++++++++++++++
22 files changed, 318 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-08-10 13:41:21 pgsql: Replace fixed-size, too-short array with a palloc'd one.
Previous Message Noah Misch 2026-08-10 13:41:19 pgsql: pg_dump: avoid assuming how long pg_proc.protrftypes can be.