Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Feike Steenbergen <feikesteenbergen(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Date: 2025-05-24 13:42:31
Message-ID: CACJufxEcDR7S2Kyv0QG0GSkoHMtJ3Y=pM8dqXLhOTcCdBhAA+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, May 24, 2025 at 2:39 PM Feike Steenbergen
<feikesteenbergen(at)gmail(dot)com> wrote:
>
> The loophole is this:
>
> - the generated virtual column can use a user-defined function
> - when running SELECT against that column by a superuser
> the function is called within the context of a superuser
> - this in turn allows the regular user to run any code within
> the context of superuser

sorry, I am not fully sure what this means.
a minimum sql reproducer would be great.

you may check virtual generated column function privilege regress tests on
https://git.postgresql.org/cgit/postgresql.git/tree/src/test/regress/sql/generated_virtual.sql#n284
(from line 284 to line 303)

also see [1].
PostgreSQL grants EXECUTE privilege for functions and procedures to
PUBLIC *by default* when the objects are created.

[1]: https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGES-SUMMARY-TABLE

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2025-05-24 13:47:14 [PATCH] Extending FK check skipping on replicas to ADD FK and TRUNCATE
Previous Message Alexander Korotkov 2025-05-24 13:28:55 Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly