Re: Extension pg_trgm, permissions and pg_dump order

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>
Cc: Noah Misch <noah(at)leadboat(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Extension pg_trgm, permissions and pg_dump order
Date: 2022-05-25 17:02:35
Message-ID: 1961551.1653498155@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

[ redirecting to -bugs ]

=?iso-8859-1?Q?F=E4rber=2C_Franz-Josef_=28StMUK=29?= <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de> writes:
> My minimal example goes like this: On the fresh container, execute

> ```sql
> CREATE ROLE limitedrole;
> CREATE SCHEMA ext_trgm;
> CREATE EXTENSION pg_trgm SCHEMA ext_trgm;
> GRANT USAGE ON SCHEMA ext_trgm TO limitedrole;

> SET ROLE limitedrole;
> CREATE TABLE x(y text);
> CREATE INDEX ON x USING gist(y ext_trgm.gist_trgm_ops);
> ```

> Dump the database with `pg_dump > /tmp/x`, then do
> ```sql
> DROP SCHEMA ext_trgm CASCADE; DROP TABLE x;
> ```
> (or alternatively create a fresh database and do a ` CREATE ROLE limitedrole;`)

> Then try to restore the dump with `cat /tmp/x | psql`.

> On version 14.2, this succeeds.
> On version 14.3, this fails with "ERROR: permission denied for schema ext_trgm".

I think what is happening here is that parse analysis of the index
expression is now being done as the owner of the table (already assigned
as limitedrole), as a consequence of the patch for CVE-2022-1552.

So basically, that patch has completely broken pg_dump's scheme for
when it can issue GRANTs. I'm not sure there is a simple fix :-(.
We could issue the GRANTs earlier but that is going to break some
other use-cases, if memory serves.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2022-05-25 17:08:21 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY
Previous Message Alvaro Herrera 2022-05-25 16:43:22 Re: BUG #17485: Records missing from Primary Key index when doing REINDEX INDEX CONCURRENTLY

Browse pgsql-general by date

  From Date Subject
Next Message Bryn Llewellyn 2022-05-25 17:24:38 "Join Postgres on Slack" ?
Previous Message Aleš Zelený 2022-05-25 16:17:37 Re: Pg14 possible index corruption after reindex concurrently