From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent creating types in pg_temp from restricted code.
Date: Mon, 09 Nov 2026 14:21:58 +0000
Message-ID: <E1xQQFy-000000003de-49BX@gemulon.postgresql.org> (raw)
Prevent creating types in pg_temp from restricted code.
Commit 62aba76568 taught security-restricted operations to refuse
temporary table creation, since the calling session might not
expect untrusted objects to appear at the front of its search
path, but the same hazard exists for types. This oversight
allowed code running within such an operation to create domains,
enum types, and range types in the session's temporary schema,
potentially leading to privilege escalations. To fix, refuse to
create these types in a temporary schema within a
security-restricted operation, as we already do for tables.
The checks live in the command paths rather than in TypeCreate(),
which also creates the rowtypes of the transient relations that
REFRESH MATERIALIZED VIEW CONCURRENTLY and rewrites of temporary
tables legitimately place in pg_temp within a security-restricted
operation. Composite types are already covered by the existing
check in DefineRelation(), and creating base or shell types
requires superuser. Other object kinds are left alone, since
unqualified names never resolve to them in pg_temp.
Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Co-authored-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Security: CVE-2026-116316
Backpatch-through: 14
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/448db14518504c789554f2e1be5a1efa6a9b155c
Author: Nathan Bossart <nathan@postgresql.org>
Modified Files
--------------
src/backend/commands/typecmds.c | 24 ++++++++++++++++++++++++
src/test/regress/expected/privileges.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/privileges.sql | 18 ++++++++++++++++++
3 files changed, 67 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Prevent creating types in pg_temp from restricted code.
In-Reply-To: <E1xQQFy-000000003de-49BX@gemulon.postgresql.org>
References: <E1xQQFy-000000003de-49BX@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox