Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soraH-00EMcD-3B for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2024 21:42:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1soraG-000zVo-RJ for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2024 21:42:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soraG-000zU5-CN for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2024 21:42:36 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1soraD-000rcl-8z for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2024 21:42:35 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-27806115eafso832983fac.3 for ; Thu, 12 Sep 2024 14:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726177353; x=1726782153; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zGbgKl05FrbWOBIywzdNAjx9EKLGZ/T0Q51jU4sOWnM=; b=B26fXsF2sYQ/5qAU3R8kGbd7Io55Mh/HHtyV6SgeV74s/uI9lmQzIkh+YcNMHeE8t2 R+Oxyybl++UuKyrS5Wa6/JUnGpIoGDIGyP1++bu8de0kPj31wIi+r67+m6XWXFJp7C48 Svnqd9m2yfq/Qma5PKvRB2Smza9xj5igp+sF3usozTdXgHtKfCOT9BfvQMSyMlwBR1+O ycgW0RNkOJkEeujV7tGXHEjTLgHejnZ3jBICd/X5VMtxl+Kj7MqmzavPPNh7vqFuWgKl KfWViJdXkJJ0yOVzhYq3/9YmRAcaqrCM1NQLK20vJoyZS9pHnyyj84WHXwsApNrZq1N6 JV3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726177353; x=1726782153; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zGbgKl05FrbWOBIywzdNAjx9EKLGZ/T0Q51jU4sOWnM=; b=VIdTGQesJ5iCwx7WMLwACsBrtm24FD1JUgaTiErDQ60dJOUoPQ/CJhkFrBm8ECL8/i 6GBr1h5hhv+/vETnTdBoIKX42N9O5ulPECCHT8M1VWSgnI3iSi2gvcWnRADzLgIvXeuv /tUkfB3ebFViZPXYIt0hDGmutrgybt/q5KV1XE674GW9p2u3epDycj4NB66h4yxHrd14 Hm0GbFnF9es88N7Q6BJT/4VLax6X1o6UL3PK0FnRXE3nMzV/Vaz1+m5TTw2uC/+B70L1 03GPiXJSs3KMUz+Okyqs3L8VL/7gD07YlQ0/rrraqGAfylVIWzeikzC0S0NtTMDmsobB r+OQ== X-Forwarded-Encrypted: i=1; AJvYcCU+4GQjLY4FZW8XNlfeDmNUuKewr5GNLpSB1iWLVuxaCUN1fBYoNKZD9HJkX/pnGByB+p5hHbaAX5MQ+JPZ@lists.postgresql.org X-Gm-Message-State: AOJu0YzX/x9IoiZjIDu0wLt3ZRxljX4eLaydADhcXvB10KbUtdEIEQDK 1O6xv+N02ncQMAKattm+j6xjoI0jDPgvAAC/wLFKZBOqy9lE3D/AdDlP1dXpmwKjTzFnDD4aZMw 3CZJ0z7zs+g76GcD1ZDTHzrH3wfo= X-Google-Smtp-Source: AGHT+IFVJDOcyxKapSOPGihth/nsSujd6tSeJePA+pBUiINxJSNBnvgpr7BptvtqrR0DqWa7l+q7+VjHaeh/LBh2quU= X-Received: by 2002:a05:6870:fb8e:b0:277:d8a7:f63b with SMTP id 586e51a60fabf-27c3f69fd97mr4330479fac.39.1726177352770; Thu, 12 Sep 2024 14:42:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:e0e:0:b0:557:c384:fb61 with HTTP; Thu, 12 Sep 2024 14:42:32 -0700 (PDT) In-Reply-To: References: <4308abb3-269e-4cee-a48f-c95d49ede6c2@postgrespro.ru> From: "David G. Johnston" Date: Thu, 12 Sep 2024 14:42:32 -0700 Message-ID: Subject: Re: Backward compat issue with v16 around ROLEs To: Robert Haas Cc: Dominique Devienne , Pavel Luzanov , Wolfgang Walther , "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000ee6cce0621f2fb90" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ee6cce0621f2fb90 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thursday, September 12, 2024, Robert Haas wrote: > On Thu, Sep 12, 2024 at 3:40=E2=80=AFPM Dominique Devienne > wrote: > > > > Any existing ROLE graph which had "back-edges" (GRANTs) from a ROLE > > back to the ROLE that created it, valid in pre-v16, becomes invalid in > v16+. > > And there's no work-around. Tough luck, take a hike... > > > > > So I guess I would respectfully disagree with > the idea that this works on v14 and v16 broke it. It doesn't really > work on v14, or at least not any better than just using SUPERUSER > everywhere that you're currently using CREATEROLE. And if you choose > to do that, I think your example will work pretty much the same way on > v16 as it does on v14. After false-starting on a few replies and pondering a bit more that is basically what I=E2=80=99ve come to conclude as well. We basically changed= things because this model was deemed dangerous. I suppose we took little effort to make it safer in the new regime had anyone decided to use it anyway, instead figuring that most would separate the main DAG of application roles from the object owners and role creators. At least that=E2=80=99s always b= een my base design principle. > > However, it seems like we might be able to fix this by just making the > code smarter. Maybe there's a problem that I'm not seeing, but if the > boss grants a privilege to alice and alice grants it to bob and bob > grants it back to alice and then the boss revokes the privilege, why > can't we figure out that alice no longer has a source for that > privilege *aside from the one involved in the cycle* and undo the > reciprocal grants that bob and alice made to each other? Right now I > believe we just ask "is the number of sources that alices has for this > privilege still greater than zero" which only works if there are no > cycles but maybe we can do better. We'd probably need to think > carefully about concurrency issues, though, and whether pg_dump is > smart enough to handle this case. Also, there are separate code paths > for role grants and non-role grants, and since I went to a lot of > trouble to make them work the same way, I'd really prefer it if we > didn't go back to having them work differently... > > I=E2=80=99m definitely not keen on trying to deal with circularities in the= graph. I get that we broke a working model here but I=E2=80=99m still not seeing w= hy that model is one we would strive to accommodate in a green-field situation. A user can delegate away some ability to a role they create but cannot make it so roles they create can pretend to be their creator. The main thing I haven=E2=80=99t looked into is if alice delegates createrole to bob and the= n removes bob does she assume all of the roles bob created or must there be an explicit reassigned owned executed? David J. --000000000000ee6cce0621f2fb90 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thursday, September 12, 2024, Robert Haas <robertmhaas@gmail.com> wrote:
On Thu, Sep 12, 2024 at 3:40=E2=80=AFPM Dominique Devienne <<= a href=3D"mailto:ddevienne@gmail.com">ddevienne@gmail.com> wrote: >
> Any existing ROLE graph which had "back-edges" (GRANTs) from= a ROLE
> back to the ROLE that created it, valid in pre-v16, becomes invalid in= v16+.
> And there's no work-around. Tough luck, take a hike...
>


So I guess I would respectfully disagree with
the idea that this works on v14 and v16 broke it. It doesn't really
work on v14, or at least not any better than just using SUPERUSER
everywhere that you're currently using CREATEROLE. And if you choose to do that, I think your example will work pretty much the same way on
v16 as it does on v14.

After false-starting= on a few replies and pondering a bit more that is basically what I=E2=80= =99ve come to conclude as well.=C2=A0 We basically changed things because t= his model was deemed dangerous.=C2=A0 I suppose we took little effort to ma= ke it safer in the new regime had anyone decided to use it anyway, instead = figuring that most would separate the main DAG of application roles from th= e object owners and role creators.=C2=A0 At least that=E2=80=99s always bee= n my base design principle.
=C2=A0

However, it seems like we might be able to fix this by just making the<= br> code smarter. Maybe there's a problem that I'm not seeing, but if t= he
boss grants a privilege to alice and alice grants it to bob and bob
grants it back to alice and then the boss revokes the privilege, why
can't we figure out that alice no longer has a source for that
privilege *aside from the one involved in the cycle* and undo the
reciprocal grants that bob and alice made to each other? Right now I
believe we just ask "is the number of sources that alices has for this=
privilege still greater than zero" which only works if there are no cycles but maybe we can do better. We'd probably need to think
carefully about concurrency issues, though, and whether pg_dump is
smart enough to handle this case. Also, there are separate code paths
for role grants and non-role grants, and since I went to a lot of
trouble to make them work the same way, I'd really prefer it if we
didn't go back to having them work differently...


I=E2=80=99m definitely not keen on trying = to deal with circularities in the graph.=C2=A0 I get that we broke a workin= g model here but I=E2=80=99m still not seeing why that model is one we woul= d strive to accommodate in a green-field situation.

A user can delegate away some ability to a role they create but cannot ma= ke it so roles they create can pretend to be their creator.=C2=A0 The main = thing I haven=E2=80=99t looked into is if alice delegates createrole to bob= and then removes bob does she assume all of the roles bob created or must = there be an explicit reassigned owned executed?

Da= vid J.

--000000000000ee6cce0621f2fb90--