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 <[email protected]> Reviewed-by: Greg Burd <[email protected]> Security: CVE-2026-116316 Backpatch-through: 14 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/44ebef3b5ddda43bf7e706c8d071b9ee50c11737 Author: Nathan Bossart <[email protected]> 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(+)
