pgsql: Reject extnamespace if it's temporary or it's '$user'::regnamesp

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reject extnamespace if it's temporary or it's '$user'::regnamesp
Date: 2026-11-09 14:22:14
Message-ID: E1xQQGE-000000004BN-0TZQ@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reject extnamespace if it's temporary or it's '$user'::regnamespace.

Historical behavior was bizarre. 'CREATE EXTENSION tcn SCHEMA "$user"'
set extnamespace='$user'::regnamespace, but the extension's object
landed in the schema named after the bootstrap superuser if such a
schema existed, else in pg_temp. Many extension scripts failed, since
pg_temp is searched for only a subset of object types. In other
scenarios, a trusted-extension script located the wrong object and
executed arbitrary SQL of a non-superuser's choice. The prior commit's
locking additions could not cover this. Back-patch to v14 (all
supported versions).

Reported-by: Noah Misch <noah(at)leadboat(dot)com>
Reviewed-by: Greg Burd <greg(at)burd(dot)me>
Backpatch-through: 14
Security: CVE-2026-6467

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b049106516df15009a0e6348385f8833e0a2bf58

Modified Files
--------------
src/backend/catalog/namespace.c | 13 +++++
src/backend/commands/extension.c | 36 ++++++++++---
.../test_extensions/expected/test_extensions.out | 60 +++++++++++++++++-----
.../test_extensions/sql/test_extensions.sql | 44 +++++++++++++---
4 files changed, 126 insertions(+), 27 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-11-09 14:22:15 pgsql: Forbid changing type if the rowtype is used in a foreign table
Previous Message Noah Misch 2026-11-09 14:22:13 pgsql: Avoid use-after-free hazards in re-entrant use of pltcl.