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 1noKpP-0004Xp-0V for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 08:02:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1noKpN-0001yA-T0 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 May 2022 08:02:41 +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 1noKpN-0001y1-EB for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 08:02:41 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1noKpK-0000pe-LA for pgsql-hackers@lists.postgresql.org; Tue, 10 May 2022 08:02:40 +0000 Received: by mail-ej1-x62a.google.com with SMTP id m20so31266667ejj.10 for ; Tue, 10 May 2022 01:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:comments:mime-version :content-id:content-transfer-encoding:date:message-id; bh=0UfqleDIaQEDhyRI14NC5CjGxP5a9FdKKiCm0JDg64w=; b=d5k413S7wYbtAFDQhHK8wsd5LkBccbE1f30X8qrNyQkW+A6qQ2HbR9ic8cFz5NK75m q7GtyTZRhpeLciED6bvc5VtiMNzEqZp2ZW7cYiAwIBASMH/793o6P36+dKQVbaixKipR oKt2yEh7XP1JNY84v225IixxCBnMRJeE1AfocAoNH0KPywYGwXeXW61Qqm+hOYxEsHrP swrIPkQlY+k7RNn/xtxFdmCVkA1kHIxDyU8solPd1Z7vrQTVYlNgO8j8IkL7kJqIoJ0q mAWOAYbVaHf6H3o7qvgi19agN668W7BZlkS78RJnqCqG72AxVPHh7BOqKLjMrM59m8bw 7Xaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :comments:mime-version:content-id:content-transfer-encoding:date :message-id; bh=0UfqleDIaQEDhyRI14NC5CjGxP5a9FdKKiCm0JDg64w=; b=avvSZzkCYVAbl2kf0ua1kYP4gs14s+rX47kGLwhKDjIW4FzS6/NdelvAV6//GpGKFO +TUlb7Bb1XM9Hyyzb+BIsSo0CxX2BSU3OakNhV4IOFLuRQrQ6UH/8H6xzYqIsfD7sehD qAfXUgyraCvOMM0HXQifTWJyDTrW618W+ondu44bHXTRh7Nt/RrLsrbhwjQBo4Pc6BGv fWsf40fLXkkXHcRSUWcIY4WrDHZyv3Kn2KVOQMA4bsnPSlPYsACb7xj7X2QvGutghOAr EJuXbQjUmphxUjjSlsbj5g/8vkmQSTrS6y3PeCkWqfGatrcsj711HU6ssnt4q3Qf+rra 2o3g== X-Gm-Message-State: AOAM531sP+3zAtgcKOnKMANrquSUm//3xtPnUJVCuQuCOltOnZfqhHQ3 Z8X/HS1V/BNY3YH4+tRU15REPD4woop3mA== X-Google-Smtp-Source: ABdhPJzfSvKe6B5jLHzOkMYtgpi1WVGu+uacgCXX+VSBgGIlPBrw6uiT7VseUS6zQ7hU3x0CjQgbLg== X-Received: by 2002:a17:907:60cc:b0:6f4:ffba:489 with SMTP id hv12-20020a17090760cc00b006f4ffba0489mr18803100ejc.666.1652169756613; Tue, 10 May 2022 01:02:36 -0700 (PDT) Received: from antos (85-207-121-76.static.bluetone.cz. [85.207.121.76]) by smtp.gmail.com with ESMTPSA id jz11-20020a17090775eb00b006f3ef214e51sm5784783ejc.183.2022.05.10.01.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 01:02:36 -0700 (PDT) From: Antonin Houska To: "Euler Taveira" cc: pgsql-hackers@lists.postgresql.org Subject: Re: Privileges on PUBLICATION In-reply-to: <8a00e0e1-dc4e-422c-9dcf-664b16b18625@www.fastmail.com> References: <20330.1652105397@antos> <8a00e0e1-dc4e-422c-9dcf-664b16b18625@www.fastmail.com> Comments: In-reply-to "Euler Taveira" message dated "Mon, 09 May 2022 15:44:45 -0300." 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: <2387.1652169778.1@antos> Content-Transfer-Encoding: quoted-printable Date: Tue, 10 May 2022 10:02:58 +0200 Message-ID: <2388.1652169778@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Euler Taveira wrote: > On Mon, May 9, 2022, at 11:09 AM, Antonin Houska wrote: > = > Now that the user can specify rows and columns to be omitted from the l= ogical > replication [1], I suppose hiding rows and columns from the subscriber = is an > important use case. However, since the subscription connection user (i.= e. the > user specified in the CREATE SUBSCRIPTION ... CONNECTION ... command) n= eeds > SELECT permission on the replicated table (on the publication side), he= can > just use another publication (which has different filters or no filters= at > all) to get the supposedly-hidden data replicated. > = > The required privileges were not relaxed on publisher after the row filt= er and = > column list features. It is not just to "create another publication". Cr= eate > publications require CREATE privilege on databases (that is *not* grante= d to > PUBLIC).If you have an untrusted user that could bypass your rules about= hidden > data, it is better to review your user privileges. > = > postgres=3D# CREATE ROLE foo REPLICATION LOGIN; > CREATE ROLE > postgres=3D# \c - foo > You are now connected to database "postgres" as user "foo". > postgres=3D> CREATE PUBLICATION pub1; > ERROR: permission denied for database postgres > = > The documentation [1] says > = > "The role used for the replication connection must have the REPLICATION > attribute (or be a superuser)." > = > You can use role foo for the replication connection but role foo couldn'= t be a > superuser. In this case, even if role foo open a connection to database > postgres, a publication cannot be created due to lack of privileges. > = > Don't we need privileges on publication (e.g GRANT USAGE ON PUBLICATION= ...) > now? > = > Maybe. We rely on CREATE privilege on databases right now. If you say th= at > GRANT USAGE ON PUBLICATION is just a command that will have the same eff= ect as > REPLICATION property [1] has right now, I would say it won't. Are you ai= ming a > fine-grained access control on publisher? The configuration I'm thinking of is multiple replicas reading data from t= he same master. For example, consider "foo" and "bar" roles, used by "subscr_foo" and "subscr_bar" subscriptions respectively. (Therefore, both roles need the REPLICATION option.) The subscriptions "subscr_foo" and "subscr_bar" are located in "db_foo" and "db_bar" databases respectively. On the master side, there are two publications: "pub_foo" and "pub_bar", t= o be used by "subscr_foo" and "subscr_bar" subscriptions respectively. The publications replicate the same table, but each with a different row filte= r. The problem is that the admin of "db_foo" can add the "pub_bar" publicatio= n to the "subscr_foo" subscription, and thus get the data that his "pub_foo" wo= uld filter out. Likewise, the admin of "db_bar" can "steal" the data from "pub_foo" by adding that publication to "subscr_bar". In this case, the existing publications are misused, so the CREATE PUBLICA= TION privileges do not help. Since the REPLICATION option of a role is cluster-wide, but I need specific roles to be restricted to specific publications, it can actually be called fine-grained access control as you say. > [1] https://www.postgresql.org/docs/devel/logical-replication-security.h= tml -- = Antonin Houska Web: https://www.cybertec-postgresql.com