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 1oIYc9-0002qL-NO for pgsql-general@arkaria.postgresql.org; Mon, 01 Aug 2022 16:49:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIYc8-00070j-L8 for pgsql-general@arkaria.postgresql.org; Mon, 01 Aug 2022 16:49:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIYc8-00070a-AC for pgsql-general@lists.postgresql.org; Mon, 01 Aug 2022 16:49:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIYc6-00054N-9z for pgsql-general@lists.postgresql.org; Mon, 01 Aug 2022 16:49:55 +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 271GnppK1846619; Mon, 1 Aug 2022 12:49:51 -0400 From: Tom Lane To: =?UTF-8?Q?Marcin_Barczy=C5=84ski?= cc: pgsql-general@lists.postgresql.org Subject: Re: Inconsistent permission enforcement for schemas In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Marcin_Barczy=C5=84ski?= message dated "Mon, 01 Aug 2022 17:48:34 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1846617.1659372591.1@sss.pgh.pa.us> Date: Mon, 01 Aug 2022 12:49:51 -0400 Message-ID: <1846618.1659372591@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?Q?Marcin_Barczy=C5=84ski?= writes: > Why can a user access a table from a forbidden schema if the table is > explicitly specified in the definition of a view in an allowed schema? And > not if the table is accessed by a function used in the view. (1) Whether a view can access a table is determined by the ownership of the view, not of the user using the view. (2) It might be nice if the view's permissions were inherited by functions called by the view, but we've not made that happen. You might be able to approximate it by marking such functions SECURITY DEFINER; although that makes the function's permissions those of the function's owner not the view's owner. regards, tom lane