Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXuPf-0001Hb-It for pgsql-general@arkaria.postgresql.org; Tue, 13 Sep 2022 01:08:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oXuPe-0002JO-FP for pgsql-general@arkaria.postgresql.org; Tue, 13 Sep 2022 01:08:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oXuPd-0002JF-VW for pgsql-general@lists.postgresql.org; Tue, 13 Sep 2022 01:08:30 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oXuPb-0006JY-15 for pgsql-general@lists.postgresql.org; Tue, 13 Sep 2022 01:08:28 +0000 Received: by mail-pg1-x532.google.com with SMTP id t70so9859780pgc.5 for ; Mon, 12 Sep 2022 18:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date; bh=5na/udccuPw6rWPnG+KB9xA7PRZ1SXs3yQqa/26YS+A=; b=PdQMm+VivtSnx+sj5VwVeFWesKp1QTkmOSJr1o1AwXfp0VQZg2M4y+YnyQ0QxHuQI3 FcgU3X4noPhD8jMab9Sj+LFosNFQRIk4MafCZWOgEE/YiFpo9gX9xDbovOw9OEAWq7OM 3kI0rVg2liKHHanoXLfD5icfDP3BZbPh6yL5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date; bh=5na/udccuPw6rWPnG+KB9xA7PRZ1SXs3yQqa/26YS+A=; b=8COzhps+qtRCCAnNuny+lIMEhvD+Lg7CfdYMujLm00txgFGfxqDV/MVM87fsF3LiFA HjCBstGn7bIRf+hKY+6okxcgUPDTybQlx+o4eje1u+l23F2hV1TLbXR3ePslmOelWajP RpfEtblVAmQ53UpuHY+dtqUg+3ByHjYPe7J9xE1Lqaf+NlU1i+bt9oToGKJQb5OoHahZ gbXWjt1xDiqPDo4g6Kl+3hXlKP/Dzm4BND3xUi8de0wH8Q1cunzYvDm1gFyvXD11lWBj UuXFx5E2vgqO+kF3iwhB97D19PhXOsp2g/XD53LVjfOtdU9D3YODeqkYUE1j/6BXt+Ez V0ow== X-Gm-Message-State: ACgBeo2CiEIpA+fcmmOAyZTv871VuihoUVmiE+4fNHliECj6IdwJykVc J2hpry6DcUY/EbyTwXYM3EMtiA== X-Google-Smtp-Source: AA6agR5XJ+ow2Gms9JM8/7iS6V+ZJ0pABmBkdLHu+/GcoSu+WPY4k8+LCwg4yf8CtD1/IuZQ3pArDQ== X-Received: by 2002:a63:515d:0:b0:42a:cf33:4320 with SMTP id r29-20020a63515d000000b0042acf334320mr16756124pgl.21.1663031305915; Mon, 12 Sep 2022 18:08:25 -0700 (PDT) Received: from smtpclient.apple ([2601:646:101:7fda:7448:a193:be19:2d2c]) by smtp.gmail.com with ESMTPSA id 68-20020a620647000000b00545832dd969sm837123pfg.145.2022.09.12.18.08.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Sep 2022 18:08:24 -0700 (PDT) From: Bryn Llewellyn Message-Id: <2F078227-5EEF-4553-89FF-046A6AF12F25@yugabyte.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_71E61E3D-E978-46A6-AA10-60C85F2AF947" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Is it possible to stop sessions killing eachother when they all authorize as the same role? Date: Mon, 12 Sep 2022 18:08:23 -0700 In-Reply-To: Cc: pgsql-general list To: "David G. Johnston" References: <10F360BB-3149-45E6-BFFE-10B9AE31F1A6@yugabyte.com> X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_71E61E3D-E978-46A6-AA10-60C85F2AF947 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > david.g.johnston@gmail.com wrote: >=20 >> bryn@yugabyte.com wrote: >>=20 >> =E2=80=A6I'm troubled by the notion that (as it seems) one session = that authorizes as the role "r1" can easily list all other concurrent = sessions that are also authorized as "r1"=E2=80=94and kill them all = without restriction. (The doc does say "Use of these functions is = usually restricted to superusers, with noted exceptions." So I s'pose = that I'm talking about one of these noted exceptions.) >=20 > You can always choose to limit that function to explicitly granted = roles if you wish. And write security definer functions if you desire = some different rules=E2=80=A6 There are only a couple of relevant = functions so revoking default privileges and granting them explicitly = gives you the same outcome as adding the pg_signal_backend predefined = role=E2=80=A6 I'll agree it is an insecure default=E2=80=A6 This sounds like exactly what I want=E2=80=94and what I was asking = about. But how do I "limit pg_terminate_backend() to explicitly granted = roles?" Out of the box, any role can execute it. So yes=E2=80=A6 = "revoking default privileges and granting them explicitly" is what I = want. But how? I'd already tried authorizing as a superuser and doing = this: revoke execute on function pg_terminate_backend(int, bigint) from = public; It ran without error. But even so, a freshly created non-super role was = still able to kill sessions that had authorized as the same role. So I = assumed that there was something hard-wired about the accessibility of = "pg_terminate_backend()". In other words, where can I read about this and learn how to do what you = propose? (Of course I see that with this achieved, "security definer" = subprograms would then bring their usual value.) > having a login privilege for the database comes with power and = responsibility I can't accept that having a login privilege will give any session that = logs on unlimited power to act. The notions of object ownership, = privileges, "security definer" subprograms, and so on support my stance. --Apple-Mail=_71E61E3D-E978-46A6-AA10-60C85F2AF947 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
david.g.johnston@gmail.com wrote:

bryn@yugabyte.com wrote:

=E2=80=A6I'm troubled by the notion that (as it seems) one = session that authorizes as the role "r1" can easily list all other = concurrent sessions that are also authorized as "r1"=E2=80=94and = kill them all without restriction. (The doc does say "Use of these = functions is usually restricted to superusers, with noted = exceptions." So I s'pose that I'm talking about one of these noted = exceptions.)

You can always choose to limit that function to explicitly = granted roles if you wish. And write security definer functions if = you desire some different rules=E2=80=A6 There are only a couple of = relevant functions so revoking default privileges and granting them = explicitly gives you the same outcome as adding the = pg_signal_backend predefined role=E2=80=A6 I'll agree it is an = insecure default=E2=80=A6

This sounds like exactly what I want=E2=80=94and what I was = asking about. But how do I "limit pg_terminate_backend() to explicitly = granted roles?" Out of the box, any role can execute it. So yes=E2=80=A6 = "revoking default privileges and granting them explicitly" is what I = want. But how? I'd already tried authorizing as a superuser and doing = this:

revoke execute on function = pg_terminate_backend(int, bigint) from = public;

It ran without error. But even so, a freshly created = non-super role was still able to kill sessions that had authorized as = the same role. So I assumed that there was something hard-wired about = the accessibility of "pg_terminate_backend()".

In other words, where can I read = about this and learn how to do what you propose? (Of course I see that = with this achieved, "security definer" subprograms would then bring = their usual value.)

having a login privilege = for the database comes with power and = responsibility

I can't accept that having a login privilege will give = any session that logs on unlimited power to act. The notions of object = ownership, privileges, "security definer" subprograms, and so on = support my stance.

= --Apple-Mail=_71E61E3D-E978-46A6-AA10-60C85F2AF947--