pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Dominique Devienne <ddevienne@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: public schema grants to PUBLIC role
Date: Thu, 09 Mar 2023 14:13:30 +0100
Message-ID: <24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at> (raw)
In-Reply-To: <CAFCRh--mT14Hj_FcbbrBVMMD7JoCQi29TKymrNXz2TYh_-53HQ@mail.gmail.com>
References: <CAFCRh--mT14Hj_FcbbrBVMMD7JoCQi29TKymrNXz2TYh_-53HQ@mail.gmail.com>

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 below).
> 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 access 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





view thread (4+ messages)  latest in thread

Message-ID: <24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at>
Permalink:  ../24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at/
Also on:    postgresql.org/message-id/24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, ddevienne@gmail.com
  Subject: Re: public schema grants to PUBLIC role
  In-Reply-To: <24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at>
  References: <CAFCRh--mT14Hj_FcbbrBVMMD7JoCQi29TKymrNXz2TYh_-53HQ@mail.gmail.com> <24e22a98cf1fb142eedfc0da2861ec0cceee7f29.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox