Re: sandboxing untrusted code

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Noah Misch <noah(at)leadboat(dot)com>
Subject: Re: sandboxing untrusted code
Date: 2026-05-28 18:48:32
Message-ID: CA+TgmoYUsZ4wxD4U7PPRTm0X-KX0M+W8cVs2R6PbpoiK+Jzyww@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 23, 2026 at 8:47 PM Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> For instance, index expressions are pretty hard to avoid invoking
> accidentally, but a sandbox could be quite restrictive before it really
> started breaking index expressions.

Agreed. There are a bunch of contexts where we allow calling DML or
DDL that can do literally anything where that seems crazy. Like,
imagine a type default or an index predicate running ALTER USER ...
SUPERUSER. That is a supported scenario, but it's nuts: there's no
legitimate reason to allow it. We could certainly design a bespoke
mechanism to prevent that specific kind of problem and I do not think
that would be a terrible idea. However, if we implement a general
provenances solution like what I propose in the other email that I
just sent, it takes care of this stuff too for very little additional
cost. Extending the provenance chain down through these types of calls
is not especially difficult -- the difficult cases are actually in the
rewriter and the planner more than anything else, from what I have
seen so far. Once you have the provenance chain here, you can either
decide to block it only if it violates some general policy like "block
attempts by untrusted users to induce DDL execution" or you can add a
more specific rule like "block DDL from index expressions, index
predicates, type defaults, etc. categorically".

Or, again, if we decide against the provenances mechanism, then we can
still choose to enforce rules like this via some other route. However,
I think that approach cuts off much less of the attack surface area.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Corey Huinker 2026-05-28 19:03:26 Re: Is there value in having optimizer stats for joins/foreignkeys?
Previous Message Joel Jacobson 2026-05-28 18:47:50 Key joins