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 1oss5D-0000uc-Jz for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 20:54:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oss5C-0008D2-H7 for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 20:54:02 +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 1oss5B-00084I-Bq for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 20:54:02 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oss54-0002o9-0D for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 20:54:00 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 319EA5C01A4; Wed, 9 Nov 2022 15:53:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 09 Nov 2022 15:53:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1668027233; x= 1668113633; bh=KISiAC6idgHx53ppsHWGU1A6mNwQ0bCfYEgBdgArfUo=; b=Y rlzAqGugVCi5q8E6FPZxvK0pDFB3qaXQUndxaiVpFKdlNUQYjVZZHpiWYPziS0JQ 6KPEdkUbsibXR2Ea94vSo2i4mCU3vMzNkbzdS/4UAcXouWKNoFsrgSG00yKr0kXf tGZgM0u9Mz3guIm+t1u+C82BgFJ431j3eB5b+hCOWipAfGuMCL4cHM3AdHabcYna pfj4yEj87hBRtjdC3ULcIc0E3DHTRpFO7+3fVCVU4q1Op2tvMTvvl396/zeLyk/F k2ven36ceEQHIUs1HT+cXwNJqv092IOYt0KLXmr39I6+SVBV08bAI/tTmg7HjaAa 2x4Wv06cV6QqCkDIGA6gA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1668027233; x= 1668113633; bh=KISiAC6idgHx53ppsHWGU1A6mNwQ0bCfYEgBdgArfUo=; b=M jEUbUlEZvTbxo1VZ6/s9uYJNRxDQ0KU94mbV2VpdfgMe/WtXFdGPASFD+QYslggE zVSmW6iHOtgmWG3Pdq/oGG8PtPiwW9DubVF6aWSQNR+nrFuIL5l3rOfL+e8eoZdm giJE5Rv87aAScMoHOKsBdES9gMv9wPF+jUR6wVRWvzvtChuLU1tQSBDfGIZu32ND yxVB5Vn/tV+8jJhXmklH6mLZc+ldsXBgTBSDD7pUJ2X0MKCSGCYqwEjRgaEbc0hs o+hzPtd2yChriQ6DuhapbojVxhjULOQ729eB0RTVJUSWNzdTAMEhTImHsi35BJ1u jGDOLyGr2Rn20joThEBRQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrfedvgddugeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhephfegveekfeelffdvgfdvfefftdeujeehheeuieff hfefiefhvdfhgfetgfdvuefgnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Nov 2022 15:53:52 -0500 (EST) Message-ID: <343d00c6-afee-3416-ee43-b3f9efa5bc0e@aklaver.com> Date: Wed, 9 Nov 2022 12:53:51 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: "set role" semantics To: Bryn Llewellyn , "David G. Johnston" Cc: pgsql-general list References: <7F67C2B7-B054-408A-A2B4-2A9BF31B1855@yugabyte.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <7F67C2B7-B054-408A-A2B4-2A9BF31B1855@yugabyte.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/9/22 12:31, Bryn Llewellyn wrote: > Thanks. If nobody thinks that ending up as I showed is possible brings any kind of risk, then I’m happy to accept that. More generally, I’m a huge fan of the principle of least privilege, and (as far as it concerns what I asked about in this thread), its following aspect: > > If you consider these two alternatives: > > Alt. #1: Some ability that you do not need (and therefor don’t want) is simply not available. > > Alt. #2: That unwanted ability is available, but reasoning shows that it’s harmless. > > then Alt. #1 is preferable. > > But I do see that I can’t get Alt #1 here. > > In my actual use case, every role apart from "postgres", and its non-superuser deputy with "create role" and "createdb", will be confined at "connect time" to exactly one database. And those of these that will be able to "set role" will be able to do this only to other roles that are also confined (at "connect" time) to the same database. Moreover, I cannot worry about what sessions that authorize as "postgres" or its deputy can do because the former is unstoppable" and the latter is dangerously powerful in the wrong human hands. There's always a need for trusted humans who, if they betray that trust, can do untold harm. In this case, they must understand the design of the "multitenancy by convention" scheme and must be committed to honoring it. So, sure enough, reasoning tells me that my plan is sound. > > Nevertheless, it does seem to be unfortunate to take the mechanics of "connect" as salient rather than the resulting state of the session that either "connect" or "set role" can bring about. There could be (in a future PG version) a privilege that governed "set role" in the present scenario. But I'm sure that there never will be. Connecting to database and the role that is in play inside a session are two different things. Making them the same would make things like from here: https://www.postgresql.org/docs/current/sql-createfunction.html [EXTERNAL] SECURITY INVOKER [EXTERNAL] SECURITY DEFINER SECURITY INVOKER indicates that the function is to be executed with the privileges of the user that calls it. That is the default. SECURITY DEFINER specifies that the function is to be executed with the privileges of the user that owns it. The key word EXTERNAL is allowed for SQL conformance, but it is optional since, unlike in SQL, this feature applies to all functions not only external ones. go sideways. > > Have you actually done that and tried to run SQL statements? They are called system catalogs because they are used by the system to get the information necessary to do things. Throwing restrictions on their access would be akin to pouring sand in a gearbox, lots of strange behavior and then nothing. -- Adrian Klaver adrian.klaver@aklaver.com