pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Block ALTER SCHEMA RENAME attack on CREATE EXTENSION etc., via l
Date: Mon, 09 Nov 2026 14:22:02 +0000
Message-ID: <E1xQQG2-000000003mG-4AzU@gemulon.postgresql.org> (raw)

Block ALTER SCHEMA RENAME attack on CREATE EXTENSION etc., via locking.

Commands that run extension SQL scripts intentionally depart from a
standard, "Remove from search_path any schemas that permit untrusted
users to create objects."  While CVE-2020-14350 blocked most attacks,
one remained via ALTER SCHEMA extschema RENAME.  A user with
database-level CREATE privilege could execute arbitrary code as the
bootstrap superuser.  Block that attack by having ALTER SCHEMA RENAME,
CREATE EXTENSION, and ALTER EXTENSION UPDATE lock the schema.  This
makes schema rename locking more like that for object types
AlterObjectRename_internal() covers.

Also, make extension-mutating commands take self-exclusive locks.  Make
relevant commands take the same lock on each dependency extension.  This
doesn't stop a known attack against a specific extension, but
overlapping extension mutations are fragile and not useful.

Back-patch to v14 (all supported versions).

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

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/79f9793fc44c75d3096ef67677a729ad21a89c2c

Modified Files
--------------
contrib/ltree/.gitignore                        |   2 +
contrib/ltree/Makefile                          |   2 +
contrib/ltree/expected/schema-rename-attack.out |  80 ++++++++++++
contrib/ltree/meson.build                       |   5 +
contrib/ltree/specs/schema-rename-attack.spec   | 127 ++++++++++++++++++
src/backend/commands/extension.c                | 163 ++++++++++++++++++------
src/backend/commands/schemacmds.c               |  20 +--
7 files changed, 355 insertions(+), 44 deletions(-)



view thread (4+ messages)

Message-ID: <E1xQQG2-000000003mG-4AzU@gemulon.postgresql.org>
Permalink:  ../E1xQQG2-000000003mG-4AzU@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xQQG2-000000003mG-4AzU@gemulon.postgresql.org

 · 

reply

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: Block ALTER SCHEMA RENAME attack on CREATE EXTENSION etc., via l
  In-Reply-To: <E1xQQG2-000000003mG-4AzU@gemulon.postgresql.org>
  References: <E1xQQG2-000000003mG-4AzU@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