Re: Fix bug with accessing to temporary tables of other sessions

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Soumya S Murali <soumyamurali(dot)work(at)gmail(dot)com>, Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: Stepan Neretin <slpmcf(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix bug with accessing to temporary tables of other sessions
Date: 2026-03-23 13:31:33
Message-ID: 1a32fc83-df78-4774-97dc-2bb06dbb16e9@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23/03/2026 11:22, Soumya S Murali wrote:
Overall the patch LGTM.

This is a step forward in really isolating contents of temp tables from
other sessions, but the more I think about it, the more I'm concerned
with the current approach -- I spent some time investigating this
problem a bit deeper last week.

My main concern is the usage of gram.y, as a parser is arguably fragile
for this kind of things. For instance, one can always change the
search_path and bypass this restriction:

(table t was created in a different session)

postgres=# SELECT * FROM pg_temp_81.t;
ERROR: cannot access temporary relations of other sessions
LINE 1: SELECT * FROM pg_temp_81.t;
^
postgres=# SET search_path = pg_temp_81, public;
SET
postgres=# SELECT * FROM t;
?column?
----------
(0 rows)

* See: if (relation->relpersistence == RELPERSISTENCE_TEMP) in
namespace.c for more details.

IMO, since it is an access control issue, I guess we better treat it as
such and modify aclchk.c instead.

Something like this the file attached. This breaks an unrelated test,
which is potentially a bug in REPACK ... but I'll describe it in another
thread.

Thoughts?

Best, Jim

Attachment Content-Type Size
v13-0001-Prevent-superusers-from-accessing-temp-tables-of.donotrun text/plain 7.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2026-03-23 13:39:28 Re: meson vs. llvm bitcode files
Previous Message shawn wang 2026-03-23 13:23:29 Re: Add logical_decoding_spill_limit to cap spill file disk usage per slot