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 <[email protected]>
Reviewed-by: Greg Burd <[email protected]>
Backpatch-through: 14
Security: CVE-2026-6467

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/60341198b18142d5b5f9358379229b11457400ab

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(-)

Reply via email to