From: Noah Misch <noah@leadboat.com>
To: annika.ruohtula@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17616: Silently skipping to update data to the database with owner privileges using flyway scripts
Date: Wed, 5 Oct 2022 04:02:09 -0700
Message-ID: <20221005110209.GB2255375@rfd.leadboat.com> (raw)
In-Reply-To: <17616-195bac997f5bac61@postgresql.org>
References: <17616-195bac997f5bac61@postgresql.org>
On Fri, Sep 16, 2022 at 10:00:24AM +0000, PG Bug reporting form wrote:
> About a week ago I found that one update script was silently ignoring
> updating data to a table.
> I found a workaround which seemed to fix the issue: I added grant-statement
> "GRANT USAGE ON SCHEMA <our schema> TO "<owner of the db>"" after adding the
> column to the table and before the actually updating the data to the new
> column. After that, the update-statement was working ok.
Lacking USAGE on a schema does not cause "silently ignoring updating data to a
table". If the same table name exists in multiple schemas, it can cause you
to update a different schema's table. Example:
===
create user alice;
create schema a;
create schema b;
grant usage on schema b to alice;
create table a.x (c int);
create table b.x (c int);
grant insert on table b.x to alice;
set session authorization alice;
set search_path = a, b;
insert into x values (1); -- updates b.x
\dt x
===
It's also possible to write a trigger that silently stops the update due to
the missing USAGE privilege.
> Currently it has been working ok, but of course we are
> a bit worried about the situation, because in theory this should not be
> needed for the owner of the database.
The database owner doesn't broadly bypass privilege checks. It's normal that
"GRANT USAGE ON SCHEMA <our schema> TO "<owner of the db>"" could increase the
database owner's effective privileges.
> Is it possible there is some bug here
> related to some timing how the default privileges and the instantiated
> privileges are generated?
It's not impossible, but we'd need a self-contained test
(https://www.postgresql.org/docs/current/bug-reporting.html).
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-bugs@postgresql.org
Cc: noah@leadboat.com, annika.ruohtula@gmail.com
Subject: Re: BUG #17616: Silently skipping to update data to the database with owner privileges using flyway scripts
In-Reply-To: <20221005110209.GB2255375@rfd.leadboat.com>
References: <17616-195bac997f5bac61@postgresql.org> <20221005110209.GB2255375@rfd.leadboat.com>
* 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