pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Zhihong Yu <zyu@yugabyte.com>
Cc: Alexey Kondratov <a.kondratov@postgrespro.ru>
Cc: Hou, Zhijie <houzj.fnst@cn.fujitsu.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
Date: Mon, 25 Jan 2021 22:50:06 +0900
Message-ID: <64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com> (raw)
In-Reply-To: <CALj2ACUJtiCjnqcfQDT5q0C7O=PanN_rtgjkuh7mMh4uuzXf7w@mail.gmail.com>
References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com>
	<CALj2ACWVy_PGERjsZW+nTKBNKoEWPnRVoc=Bw0M7TorYuoquFQ@mail.gmail.com>
	<0e61fbcc-fca2-18f8-758c-4ed61c664fd7@oss.nttdata.com>
	<CALj2ACVx0+iOsrAA-wXbo3RLAKqUoNvvEd7foJ0vLwOdu8XjXw@mail.gmail.com>
	<153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com>
	<CALj2ACUVGO=KL2meDins3Mhseus4Hpke-TiiaZvVDJkFmbo6hg@mail.gmail.com>
	<9f6a69cd-3e4c-1703-a829-331dd9b660a0@oss.nttdata.com>
	<CALj2ACVcpU=wB7G=zT8msVHvPs0-y0BbviupiT+f3--bGYaOMA@mail.gmail.com>
	<646119f3-fd27-7fd7-5377-b72310af5d21@oss.nttdata.com>
	<62431587-ed3a-f333-51a9-967ccf2a78db@oss.nttdata.com>
	<CALj2ACWFrQAQGSQfaa-rY0YwY3yicqiPELN7tuN9T05uPDnzeg@mail.gmail.com>
	<1c643738-6e52-565d-0261-740d490b550e@oss.nttdata.com>
	<CALj2ACWG6Cqy1Ye5WYEhK3YnBURKk7QsXXmVpPK1xVPwcj7cyw@mail.gmail.com>
	<09b3f740-896d-7507-95e1-d2afd87daf2e@oss.nttdata.com>
	<CALj2ACUJtiCjnqcfQDT5q0C7O=PanN_rtgjkuh7mMh4uuzXf7w@mail.gmail.com>



On 2021/01/25 19:28, Bharath Rupireddy wrote:
> On Mon, Jan 25, 2021 at 3:17 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
>>> Yes, if required backends can establish the connection again. But my
>>> worry is this - a non-super user disconnecting all or a given
>>> connection created by a super user?
>>
>> Yes, I was also worried about that. But I found that there are other similar cases, for example,
>>
>> - a cursor that superuser declared can be closed by non-superuser (set by SET ROLE or SET SESSION AUTHORIZATION) in the same session.
>> - a prepared statement that superuser created can be deallocated by non-superuser in the same session.
>>
>> This makes me think that it's OK even for non-superuser to disconnect the connections established by superuser in the same session. For now I've not found any real security issue by doing that yet. Thought? Am I missing something?
> 
> Oh, and added to that list is dblink_disconnect(). I don't know
> whether there's any security risk if we allow non-superusers to
> discard the super users connections.

I guess that's ok because superuser and nonsuperuser are running in the same session. That is, since this is the case where superuser switches to nonsuperuser intentionally, interactions between them is also intentional.

OTOH, if nonsuperuser in one session can affect superuser in another session that way, which would be problematic. So, for example, for now pg_stat_activity disallows nonsuperuser to see the query that superuser in another session is running, from it.


> In this case, the super users
> will just have to re make the connection.
> 
>>> For now I'm thinking that it might better to add the restriction like pg_terminate_backend() at first and relax that later if possible. But I'd like hear more opinions about this.
>>
>> I agree. If required we can lift it later, once we get the users using
>> these functions? Maybe we can have a comment near superchecks in
>> disconnect_cached_connections saying, we can lift this in future?
> 
> Maybe we can do the opposite of the above that is not doing any
> superuser checks in disconnect functions for now, and later if some
> users complain we can add it?

+1

> We can leave a comment there that "As of
> now we don't see any security risks if a non-super user disconnects
> the connections made by super users. If required, non-supers can be
> disallowed to disconnct the connections" ?

Yes. Also we should note that that's ok because they are in the same session.

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION





view thread (175+ messages)  latest in thread

Message-ID: <64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com>
Permalink:  ../64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com/
Also on:    postgresql.org/message-id/64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com

 · 

reply

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-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com, bharath.rupireddyforpostgres@gmail.com, zyu@yugabyte.com, a.kondratov@postgrespro.ru, houzj.fnst@cn.fujitsu.com
  Subject: Re: [PATCH] postgres_fdw connection caching - cause remote sessions linger till the local session exit
  In-Reply-To: <64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.com>
  References: <CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com> <0e61fbcc-fca2-18f8-758c-4ed61c664fd7@oss.nttdata.com> <CALj2ACVx0+iOsrAA-wXbo3RLAKqUoNvvEd7foJ0vLwOdu8XjXw@mail.gmail.com> <153fba15-1e9d-c2f7-2b4d-3fafa8d4621b@oss.nttdata.com> <CALj2ACUVGO=KL2meDins3Mhseus4Hpke-TiiaZvVDJkFmbo6hg@mail.gmail.com> <9f6a69cd-3e4c-1703-a829-331dd9b660a0@oss.nttdata.com> <CALj2ACVcpU=wB7G=zT8msVHvPs0-y0BbviupiT+f3--bGYaOMA@mail.gmail.com> <646119f3-fd27-7fd7-5377-b72310af5d21@oss.nttdata.com> <62431587-ed3a-f333-51a9-967ccf2a78db@oss.nttdata.com> <CALj2ACWFrQAQGSQfaa-rY0YwY3yicqiPELN7tuN9T05uPDnzeg@mail.gmail.com> <1c643738-6e52-565d-0261-740d490b550e@oss.nttdata.com> <CALj2ACWG6Cqy1Ye5WYEhK3YnBURKk7QsXXmVpPK1xVPwcj7cyw@mail.gmail.com> <09b3f740-896d-7507-95e1-d2afd87daf2e@oss.nttdata.com> <CALj2ACUJtiCjnqcfQDT5q0C7O=PanN_rtgjkuh7mMh4uuzXf7w@mail.gmail.com> <64ee084b-1368-e044-debd-69cc156276c6@oss.nttdata.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