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 1msVAl-0005AS-1a for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Dec 2021 19:21: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 1msVAj-0000u5-Vd for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Dec 2021 19:21: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 1msVAj-0000tu-8U for pgsql-hackers@lists.postgresql.org; Wed, 01 Dec 2021 19:21:41 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1msVAg-0004TT-10 for pgsql-hackers@postgresql.org; Wed, 01 Dec 2021 19:21:40 +0000 Received: by mail-qt1-x832.google.com with SMTP id q14so25125144qtx.10 for ; Wed, 01 Dec 2021 11:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hHX4enuYvUmTXl0w1nRUfSiRaftwXy7Gl8lef2wQVFQ=; b=IPjrAKatLZoP9QG5WNMqWFFCA3DDRODpUU3tW1PkD1JknM3ov6zGSlBaWqDDPtCPmI sX36oU8mrQeHlE1RzKQi7wzC78XEHvqgsR1LCim8iIfHd3L+NRnN/RSLfCtcS6Scu4nn 82yuRX5F7xb6GHr/0dnOYt5h7ycxnhj/mi09+BGhkmvGknhMBE26WybX8rkYGR00tgWN JJ2UEjTSBp4aMzKkSkhu+Oso5q69+Esd/j4DAElrJa3L2JRE1ogNmlWfiM1hgZ0WyEPo +7cIlBrMNuY2iMrlQlEAuDH1+LVhiNMj3VYXK3rCO9vAKTGFK9Z+TRMEVAUwr3kHLKZJ tk/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hHX4enuYvUmTXl0w1nRUfSiRaftwXy7Gl8lef2wQVFQ=; b=jT9MyoqgVd40q0LOxUO8LurKXab7C3LygZZZlvV8vfpPwaU9og0YGcplpVHV+bLQ+v jCwHF0XJ4rWL3dBu+xdVkkMbFO8g7WjsEss+mPtBPe+z4/PG8Fn0ywrqUQW/lFuWd4ty ca1yEw4GuZx1Hl0Ya3GmEqGSuI/iBdctNpm/HuxMqESSZZqoMmYnPnhUvV9wpFdZPWHJ V1Hxq+WOrRcuzw1H4fJ75ELUzvLCKk3o4qR1C0ySgPuBjPf/WGLwqhCbotwu/qaJXtHi Mmuo2IskANlGwB0R31xndJgRAi9NjYw3Ep9qzKgKtTe+H6G1Eu6VmtDwFqZtEnTb/Y2O s6Eg== X-Gm-Message-State: AOAM530rilYx0kWXCmsfYqMKh9mx7uSlBEwmYnDKgGnSA4xJefzv0D3O kQ/Uqd8FMSTD3QYU9KW6X7DuV0RYA8vr9dFrors+nOyOVTT5qoN16SowcxUxWFtqkxurjKYzaq8 UBGvr10L46XrcLiZ2i04QeoUeLUkC0RTCLYCVIhnZtiOob0xuxL0B+7ZXiq4PaSke544WRTTxE3 ZMo8I2MwauNWNeuDLlVtMhYOq1Mj7fnKNzcxiS X-Google-Smtp-Source: ABdhPJy8EoK3hj2EEJmvIIIxsSWu85BTaLj9x3Vh8dJrGvom98bPMyd9eBUwKHXomCTNL6SBxFGmSg== X-Received: by 2002:ac8:7caf:: with SMTP id z15mr9271788qtv.20.1638386496953; Wed, 01 Dec 2021 11:21:36 -0800 (PST) Received: from ?IPv6:2600:1017:b80a:6a4b:6c2a:4cfc:7d47:bc88? ([2600:1017:b80a:6a4b:6c2a:4cfc:7d47:bc88]) by smtp.gmail.com with ESMTPSA id j124sm291409qkd.98.2021.12.01.11.21.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Dec 2021 11:21:36 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Non-superuser subscription owners From: Mark Dilger In-Reply-To: Date: Wed, 1 Dec 2021 11:21:35 -0800 Cc: Jeff Davis , Andrew Dunstan , PostgreSQL-development , Robert Haas Content-Transfer-Encoding: quoted-printable Message-Id: <4E93F649-C11A-40F0-BE34-6AB45507B807@enterprisedb.com> References: <9DFC88D3-1300-4DE8-ACBC-4CEF84399A53@enterprisedb.com> <6BB4451E-7B1B-474C-BD1F-DB7531E720C6@enterprisedb.com> <6A2B0FF6-CC86-48CE-B0D3-5401AA5CFEA9@enterprisedb.com> <1BB0A553-3FE9-4A91-A975-6F9D8C157FBD@enterprisedb.com> <7C62876F-5D19-4B5C-96AC-5590B10A49B2@enterprisedb.com> <66f55a6b9ff7bdd6bfd0d05e8fd8351690e69e23.camel@j-davis.com> <18b267939a9d1ae27e9b3643d53395f4e29ea6ce.camel@j-davis.com> <785e8b8ab06f123cf754862557bd3171aeba4d65.camel@j-davis.com> To: Amit Kapila X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Dec 1, 2021, at 5:36 AM, Amit Kapila = wrote: >=20 > On Wed, Dec 1, 2021 at 2:12 AM Jeff Davis wrote: >>=20 >> On Tue, 2021-11-30 at 17:25 +0530, Amit Kapila wrote: >>> I think it would be better to do it before we allow subscription >>> owners to be non-superusers. >>=20 >> There are a couple other things to consider before allowing non- >> superusers to create subscriptions anyway. For instance, a non- >> superuser shouldn't be able to use a connection string that reads the >> certificate file from the server unless they also have >> pg_read_server_files privs. >>=20 >=20 > Isn't allowing to create subscriptions via non-superusers and allowing > to change the owner two different things? I am under the impression > that the latter one is more towards allowing the workers to apply > changes with a non-superuser role. The short-term goal is to have logical replication workers respect the = privileges of the role which owns the subscription. The long-term work probably includes creating a predefined role with = permission to create subscriptions, and the ability to transfer those = subscriptions to roles who might be neither superuser nor members of any = particular predefined role; the idea being that logical replication = subscriptions can be established without any superuser involvement, and = may thereafter run without any special privilege. The more recent patches on this thread are not as ambitious as the = earlier patch-sets. We are no longer trying to support transferring = subscriptions to non-superusers. Right now, on HEAD, if a subscription owner has superuser revoked, the = subscription can continue to operate as superuser in so far as its = replication actions are concerned. That seems like a pretty big = security hole. This patch mostly plugs that hole by adding permissions checks, so that = a subscription owned by a role who has privileges revoked cannot (for = the most part) continue to act under the old privileges. There are two problematic edge cases that can occur after transfer of = ownership. Remember, the new owner is required to be superuser for the = transfer of ownership to occur. 1) A subscription is transferred to a new owner, and the new owner then = has privilege revoked. 2) A subscription is transferred to a new owner, and then the old owner = has privileges increased. In both cases, a currently running logical replication worker may finish = a transaction in progress acting with the current privileges of the old = owner. The clearest solution is, as you suggest, to refuse transfer of = ownership of subscriptions that are enabled. Doing so will create a failure case for REASSIGN OWNED BY. Will that be = ok? =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company