pgsql: Check for USAGE privilege on types used by stored expressions. - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Check for USAGE privilege on types used by stored expressions.
Date
Msg-id E1wtQFp-00000000yA0-2cln@gemulon.postgresql.org
Whole thread
List 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@leadboat.com>
Author: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Security: CVE-2026-6470
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2780538433fc3b40b4e1e7bc7cbd350e37b6d550
Author: Nathan Bossart <nathan@postgresql.org>

Modified Files
--------------
src/backend/catalog/dependency.c         | 81 ++++++++++++++++++++++++++++++++
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/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 +++++++++++++++++
21 files changed, 316 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: Use value of scram_iterations in mock_scram_secret().
Next
From: Noah Misch
Date:
Subject: pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac