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 1paG5S-00075C-5p for pgsql-general@arkaria.postgresql.org; Thu, 09 Mar 2023 13:13:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1paG5Q-0005Ls-S2 for pgsql-general@arkaria.postgresql.org; Thu, 09 Mar 2023 13:13:36 +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 1paG5Q-0005Li-Fa for pgsql-general@lists.postgresql.org; Thu, 09 Mar 2023 13:13:36 +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 1paG5N-0002Kr-4Y for pgsql-general@lists.postgresql.org; Thu, 09 Mar 2023 13:13:35 +0000 Received: by mail-ed1-x52d.google.com with SMTP id s11so6756755edy.8 for ; Thu, 09 Mar 2023 05:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; t=1678367612; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=kVZrW94s7H/Ss8H/KaSSLnApiU9Rm+6kQaSENi9wr8o=; b=tq6FiM8i5a2v1WE2zojkkpj/yAwcP56EFIkXkSSezUsnxOCI029c+HE9YVPPv3wsOS MicLfUdiZQgNqMxhWqT8mNost/SAbn+fsvm3BxzGfrIoqLw+tl7lcP7/e+HfTF1T/R+d gLiRaL3v5IkFJQPSV0RnrEzNJOSXJ+DFThUYAq3RTaefS3b1yyliXk3vodfSGT0RKYez SlXZRhzW2is+kMHa8Hl+pDkQEgY0B/VFVYfxoXm/5CzLkkIRQiNLAw9Xj+F3EKUfD2+Z pwGITSsZcYkbclshSnOQymITmDcZfVW7mBwwIy61V7+Ur7baRAQAzLSBdh6J7hy28fDz wIYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678367612; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kVZrW94s7H/Ss8H/KaSSLnApiU9Rm+6kQaSENi9wr8o=; b=eWFSY2vl6PF9sxyO/DMCb8TK605mQ/YMXASMdYb+RFBOTv1wtMdVkAHZZaltLBHvT8 dOFIDCFdAfOkLeKZA2jTU13Ml9QPaeugM5y3mPlqoBFMFIBMOQRlP4gcuR5pprh160kv tzgLAiW/AEEjVATZMn24axJ/sm0ZF5IT3FVfp/OCMwTWBWf7RqTjuyEikGhfcl5lTG7V piH56x+2tICcA02atVGlG1gL+JOjnTN+EWTSCMqlhVM7+J6xfCO7CITiVRuQWIUBWfbF jwLc9DxHnvuBrQP1UAgMEQUInsWI/lG5HQTQpbtMNXjqcCO/5FLwvfJBcoSF/UAiSJYJ sefA== X-Gm-Message-State: AO0yUKUiIlll2F3Okie2wQqWIAdU9loKI4st2dyap/a1KKO8tz+Y5vFx b5JYjHnBlXft5EDpylrHMVt8vQ== X-Google-Smtp-Source: AK7set/KakDHymMEY5E/WBhHqTsQ68XR9Eojx0LuE8mcd91mtthzRHHS/j0DqEXxMNLbM0XRXD4zrQ== X-Received: by 2002:a17:907:5cd:b0:90b:53f6:fd8a with SMTP id wg13-20020a17090705cd00b0090b53f6fd8amr30569740ejb.10.1678367611765; Thu, 09 Mar 2023 05:13:31 -0800 (PST) Received: from localhost.localdomain ([2001:871:5e:539:1b2c:c52a:475d:310c]) by smtp.gmail.com with ESMTPSA id cx9-20020a170906c80900b008cf6f8798e1sm8857460ejb.54.2023.03.09.05.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 05:13:31 -0800 (PST) Message-ID: <24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at> Subject: Re: public schema grants to PUBLIC role From: Laurenz Albe To: Dominique Devienne , pgsql-general@lists.postgresql.org Date: Thu, 09 Mar 2023 14:13:30 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2023-03-09 at 10:34 +0100, Dominique Devienne wrote: > Hi. I've recently realized via a post (or article?) from Laurenz that the= PUBLIC > role has CREATE privilege on the 'public' schema by default (see query be= low). > I guess it can't be avoided? It can be avoided if you connect to "template1" and REVOKE CREATE ON SCHEMA public FROM PUBLIC; there *before* you create a new database. Or, as Christoph said, if you use v15 or better. > OK, then I'll REVOKE that privilege when creating a new DB. > Like I already revoked the default CONNECT to PUBLIC on the DB. Excellent. > But I'm wondering about unexpected side-effets. > In particular, we need extensions, which are loaded in public by default. > Will USAGE of public be enough for LOGIN users having access to the DB to= use extensions? Yes, that is enough. > More broadly, we want to secure the DB so that all DB access and schema a= ccess are explicit. > Anything else to be aware of please, beside the two mentioned above? Avoid SECURITY DEFINER functions with no "search_path" set: https://www.cybertec-postgresql.com/en/abusing-security-definer-functions/ Yours, Laurenz Albe