pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: In extensions, don't replace objects not belonging to the extens
Date: Mon, 08 Aug 2022 15:13:08 +0000
Message-ID: <E1oL4RI-000szN-TM@gemulon.postgresql.org> (raw)

In extensions, don't replace objects not belonging to the extension.

Previously, if an extension script did CREATE OR REPLACE and there was
an existing object not belonging to the extension, it would overwrite
the object and adopt it into the extension.  This is problematic, first
because the overwrite is probably unintentional, and second because we
didn't change the object's ownership.  Thus a hostile user could create
an object in advance of an expected CREATE EXTENSION command, and would
then have ownership rights on an extension object, which could be
modified for trojan-horse-type attacks.

Hence, forbid CREATE OR REPLACE of an existing object unless it already
belongs to the extension.  (Note that we've always forbidden replacing
an object that belongs to some other extension; only the behavior for
previously-free-standing objects changes here.)

For the same reason, also fail CREATE IF NOT EXISTS when there is
an existing object that doesn't belong to the extension.

Our thanks to Sven Klemm for reporting this problem.

Security: CVE-2022-2625

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/extend.sgml                           |  11 --
src/backend/catalog/pg_collation.c                 |  49 +++++--
src/backend/catalog/pg_depend.c                    |  77 +++++++++--
src/backend/catalog/pg_operator.c                  |   2 +-
src/backend/catalog/pg_type.c                      |   7 +-
src/backend/commands/createas.c                    |  16 ++-
src/backend/commands/foreigncmds.c                 |  19 ++-
src/backend/commands/schemacmds.c                  |  25 +++-
src/backend/commands/sequence.c                    |   8 ++
src/backend/commands/statscmds.c                   |   4 +
src/backend/commands/view.c                        |  16 ++-
src/backend/parser/parse_utilcmd.c                 |  10 ++
src/include/catalog/dependency.h                   |   2 +
src/test/modules/test_extensions/Makefile          |   5 +-
.../test_extensions/expected/test_extensions.out   | 153 +++++++++++++++++++++
.../test_extensions/sql/test_extensions.sql        | 110 +++++++++++++++
.../test_extensions/test_ext_cine--1.0--1.1.sql    |  26 ++++
.../modules/test_extensions/test_ext_cine--1.0.sql |  25 ++++
.../modules/test_extensions/test_ext_cine.control  |   3 +
.../modules/test_extensions/test_ext_cor--1.0.sql  |  20 +++
.../modules/test_extensions/test_ext_cor.control   |   3 +
21 files changed, 539 insertions(+), 52 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1oL4RI-000szN-TM@gemulon.postgresql.org>
Permalink:  ../E1oL4RI-000szN-TM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oL4RI-000szN-TM@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: In extensions, don't replace objects not belonging to the extens
  In-Reply-To: <E1oL4RI-000szN-TM@gemulon.postgresql.org>
  References: <E1oL4RI-000szN-TM@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