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 1nIe2g-0000E0-T2 for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 22:05:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIe2f-00016b-KI for pgsql-general@arkaria.postgresql.org; Fri, 11 Feb 2022 22:05:25 +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 1nIe2f-00016R-AA for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 22:05:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIe2d-0001IK-12 for pgsql-general@lists.postgresql.org; Fri, 11 Feb 2022 22:05:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 21BM5K4w2188506; Fri, 11 Feb 2022 17:05:20 -0500 From: Tom Lane To: Bryn Llewellyn cc: "David G. Johnston" , jeremy@musicsmith.net, pgsql-general list Subject: Re: "grant usage on schema" confers the ability to execute all user-defined functions in that schema, with needing to grant "execute" In-reply-to: <46C22E9C-280C-446E-911F-6915702E554E@yugabyte.com> References: <0994D6C4-EDF0-4854-B528-88DDE429172E@yugabyte.com> <46C22E9C-280C-446E-911F-6915702E554E@yugabyte.com> Comments: In-reply-to Bryn Llewellyn message dated "Fri, 11 Feb 2022 13:44:23 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2188504.1644617120.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 11 Feb 2022 17:05:20 -0500 Message-ID: <2188505.1644617120@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn writes: > I confess that I'm surprised by the choice of the default behavior. It s= eems to be at odds with the principle of least privilege that insists that= you actively opt in to any relevant privilege. I'd be the first to agree that this behavior sacrifices security principles for convenience. However, it's not that big a deal in practice, because functions that aren't SECURITY DEFINER can't do anything that the caller couldn't do anyway. You do need to be careful about the default PUBLIC grant if you're making a SECURITY DEFINER function, but that's a minority use-case. (I wonder if it'd be practical or useful to emit a warning when granting permissions on an object that already has a grant of the same permissions to PUBLIC. That would at least cue people who don't understand about this behavior that they ought to look more closely.) regards, tom lane