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 1ouXIf-0003em-I0 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Nov 2022 11:06:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ouXIe-0006Fm-A1 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Nov 2022 11:06:48 +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 1ouXId-0006Fd-Tx for pgsql-hackers@lists.postgresql.org; Mon, 14 Nov 2022 11:06:48 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ouXIc-0003c4-1d for pgsql-hackers@lists.postgresql.org; Mon, 14 Nov 2022 11:06:47 +0000 Received: by mail-ed1-x52d.google.com with SMTP id a5so16701927edb.11 for ; Mon, 14 Nov 2022 03:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=hNm+z9gtrYslmkVVlJvRrYkrqzTnvutGVPuh9gYDAHE=; b=bkr6zzOyHfYo4INK4vJ1j9EyJi6VnBqNi9AbwDTZ81EnIK5kskKss9Si6AZmc5NdBJ YQYtspWGrMeH+B8qfDeTelkp2MZW8qP/S7k2ZiowDW4DVjnT8b2w14BL0VJsZc9+Z7du AqbKosL45MRPJctNpZYs4wMXsMPzKcOelGpii2sREAIZnPRTzXlW33kuNYgchKwKIGGU EnUGzL99vPHL+A2SInPF/+hJ8eDU8MSQAGXv8NHQAEd1SaJJbHQzvNIyDmJ0pf0j/TG6 CSedXEjJpmGHGzZDRkkxitx3V1WcUy+LuXPtkwyxbvLlzf0iWVKqs98g96bhsvuwMwMN 1g2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hNm+z9gtrYslmkVVlJvRrYkrqzTnvutGVPuh9gYDAHE=; b=kvKsTotTYhwi8sv+9+Ur7Hb+5xTMjYyZa1/fX+2+8W3pNIZfCIFoiPXzzjn60HVqfY fosM2JNVrdnZOlXAkGo079SumryjTFKYHWCOzw4T0yr8PVryY89K9WcfywhvH8TT+HsF Fgin7tcRzhZaCVf+mTeevcDsPamHXXf5xeC8LC8sJLwWtRpi77Mpdqjrf5hYpaYSR81T RV+KEQKWGaGivhM/xpRbaJL9L8h+zfq2huLHkJNnqL+O1dWRLuWBXEYcs3DFRl1P7p5R 6t/NPNG3OdgW5HHINH4ZwARqm9A0HB86PdTmhJBwpotUvaIdhL1rRwCZAPcGHmaYiQsS RxUw== X-Gm-Message-State: ANoB5pnlYnawW3aeLP1Ro6iDCiXo6zicWVL8YhaKGsrUhwxpUmYXshla L496FpblxsM6qSrZ/sOOHfJ7jA== X-Google-Smtp-Source: AA0mqf5uTv/VqMCnZ+X8BB2ZcF/A0kws4dz1FM2Lz+gacthjl472/OCRKfdlDOCk34dJWBoHTGJh7w== X-Received: by 2002:a05:6402:7da:b0:466:4168:6ea7 with SMTP id u26-20020a05640207da00b0046641686ea7mr10244877edy.273.1668424004251; Mon, 14 Nov 2022 03:06:44 -0800 (PST) Received: from antos ([88.103.134.180]) by smtp.gmail.com with ESMTPSA id 10-20020a170906210a00b0078dce9984afsm3984915ejt.220.2022.11.14.03.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 03:06:43 -0800 (PST) From: Antonin Houska To: Peter Eisentraut cc: Euler Taveira , Amit Kapila , PostgreSQL Hackers Subject: Re: Privileges on PUBLICATION In-reply-to: <043c52a4-c001-0201-94fc-305dffb8313e@enterprisedb.com> References: <20330.1652105397@antos> <8a00e0e1-dc4e-422c-9dcf-664b16b18625@www.fastmail.com> <2810.1652171844@antos> <5859.1652423797@antos> <57022.1652867097@antos> <4c420c17-8570-4b52-b7f6-9ce3f53d7ef9@www.fastmail.com> <14292.1655733695@antos.home> <746c9a65-e2cc-2573-a50e-ab5ea884f680@enterprisedb.com> <1537.1667454192@antos> <2497.1667546930@antos> <043c52a4-c001-0201-94fc-305dffb8313e@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Fri, 11 Nov 2022 15:08:16 +0100." X-Mailer: MH-E 8.6+git; nmh 1.7+dev; GNU Emacs 27.2.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3861.1668424068.1@antos> Content-Transfer-Encoding: quoted-printable Date: Mon, 14 Nov 2022 12:07:48 +0100 Message-ID: <3862.1668424068@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut wrote: > On 04.11.22 08:28, Antonin Houska wrote: > > I thought about the whole concept a bit more and I doubt if the PUBLIC= ATION > > privilege is the best approach. In particular, the user specified in C= REATE > > SUBSCRIPTION ... CONNECTION ... (say "subscription user") needs to hav= e SELECT > > privilege on the tables replicated. So if the DBA excludes some column= s from > > the publication's column list and sets the (publication) privileges in= such a > > way that the user cannot get the column values via other publications,= the > > user still can connect to the database directly and get values of the = excluded > > columns. > = > Why are the SELECT privileges needed? Maybe that's something to think a= bout > and maybe change. I haven't noticed an explanation in comments nor did I search in the maili= ng list archives, but the question makes sense: the REPLICATION attribute of = a role is sufficient for streaming replication, so why should the logical replication require additional privileges? Technically the SELECT privilege is needed because the sync worker does actually execute SELECT query on the published tables. However, I realize = now that it's not checked by the output plugin. Thus if SELECT is revoked from= the "subscription user" after the table has been synchronized, the replication continues to work. So the necessity for the SELECT privilege might be an omission rather than a design choice. (Even the documentation says that th= e SELECT privilege is needed only for the initial synchronization [1], howev= er it does not tell why.) > > As an alternative to the publication privileges, I think that the CREA= TE > > SUBSCRIPTION command could grant ACL_SELECT automatically to the subsc= ription > > user on the individual columns contained in the publication column lis= t, and > > DROP SUBSCRIPTION would revoke that privilege. > = > I think that approach is weird and unusual. Privileges and object creat= ion > should be separate operations. ok. Another approach would be to skip the check for the SELECT privilege (= as well as the check for the USAGE privilege on the corresponding schema) if given column is being accessed via a publication which has it on its colum= n list and if the subscription user has the USAGE privilege on that publicat= ion. So far I wasn't sure if we can do that because, if pg_upgrade grants the U= SAGE privilege on all publications to the "public" role, the DBAs who relied on= the SELECT privileges might not notice that any role having the REPLICATION attribute can access all the published tables after the upgrade. (pg_upgra= de can hardly do anything else because it has no information on the "subscrip= tion users", so it cannot convert the SELECT privilege on tables to the USAGE privileges on publications.) But now that I see that the logical replication doesn't check the SELECT privilege properly anyway, I think we can get rid of it. [1] https://www.postgresql.org/docs/current/logical-replication-security.h= tml -- = Antonin Houska Web: https://www.cybertec-postgresql.com