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: Reject substituting extension schemas or owners matching ["$'\].
Date: Mon, 07 Aug 2023 13:07:32 +0000
Message-ID: <E1qSzxL-000sDv-LZ@gemulon.postgresql.org> (raw)

Reject substituting extension schemas or owners matching ["$'\].

Substituting such values in extension scripts facilitated SQL injection
when @extowner@, @extschema@, or @extschema:...@ appeared inside a
quoting construct (dollar quoting, '', or "").  No bundled extension was
vulnerable.  Vulnerable uses do appear in a documentation example and in
non-bundled extensions.  Hence, the attack prerequisite was an
administrator having installed files of a vulnerable, trusted,
non-bundled extension.  Subject to that prerequisite, this enabled an
attacker having database-level CREATE privilege to execute arbitrary
code as the bootstrap superuser.  By blocking this attack in the core
server, there's no need to modify individual extensions.  Back-patch to
v11 (all supported versions).

Reported by Micah Gate, Valerie Woolard, Tim Carey-Smith, and Christoph
Berg.

Security: CVE-2023-39417

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/commands/extension.c                   | 21 +++++++++++++++
src/test/modules/test_extensions/Makefile          |  2 ++
.../test_extensions/expected/test_extensions.out   | 30 ++++++++++++++--------
.../test_extensions/sql/test_extensions.sql        | 17 +++++++++---
.../test_extensions/test_ext_extschema--1.0.sql    |  5 ++++
.../test_extensions/test_ext_extschema.control     |  3 +++
6 files changed, 63 insertions(+), 15 deletions(-)



view thread (7+ messages)

Message-ID: <E1qSzxL-000sDv-LZ@gemulon.postgresql.org>
Permalink:  ../E1qSzxL-000sDv-LZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qSzxL-000sDv-LZ@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: noah@leadboat.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Reject substituting extension schemas or owners matching ["$'\].
  In-Reply-To: <E1qSzxL-000sDv-LZ@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