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

From: Feike Steenbergen <feikesteenbergen(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, 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-26 14:51:51
Message-ID: CAK_s-G2060Z1VZUkfspyrCHbmfp+dtUevQuDwt2G-zFxXp5pCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 26 May 2025 at 16:17, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> calling exploit_generated.exploit by normal user or superuser the
> effects are different,
> that by definition is not IMMUTABLE.

Yeah, i know this is *wrong* usage of IMMUTABLE, the point is that a rogue
regular user *can* use this pattern to become superuser.

> I think I understand what you mean.
> but still that is not related to the generated column.

It is, as before this feature, it was safe to, as a superuser:

SELECT * FROM untrusted_table

However, as of now, in pg18 this may lead to any code defined by a
regular user to run in the context of a superuser.

I'm aware that this already exists (pg17) for:

- superuser selecting from a user defined view
- superuser executing a user defined function
- superuser inserting into a user defined table

However, this is *new* behavior, increasing the possibility of exploits.

Certain db clients (I checked DBeaver and pgAdmin4) allow a user to
peek into the table details using their GUI. When connected as a superuser,
that would trigger this exploit.

As a sidenote: It may be useful for the pgAdmin4/DBeaver and other clients
to somehow block this behavior when connected as a superuser anyway?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vitaly Davydov 2025-05-26 15:34:07 Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly
Previous Message Joe Conway 2025-05-26 14:20:08 Re: PG 18 release notes draft committed