0

Postgresql 9.6, if it matters.

We have an audit finding which says that the "postgres" role must not be used at all.

After creating a new SUPERUSER role, is it possible to disable role "postgres" (or do some jobs like autovacuum/autoanalyze require it)? If they are the only ones which need it, I could disable autovacuum/autoanalyze and rely on manual vacuums and analyze.

0

2 Answers 2

2

You can specify the name of the database superuser at the time of running initdb. It will default to the name of the user running the initdb command itself, but specifying --username or -U will change that. https://www.postgresql.org/docs/9.6/app-initdb.html

Let me highly suggest that you don't even for a second consider trying to take away any privileges from the database superuser role, regardless of its name. Many privilege checks within the database are coded in such a way that the superuser is always allowed to continue, no questions asked. It is, after all, the superuser role.

I can only assume that your auditors are either clueless or were referring to some use of the postgres role by applications or by developers. In the latter cases, it is definitely advisable to restrict access and create appropriate roles/users within the database for these tasks.

This is my recommendation: make sure that user postgres cannot login from anywhere (besides locally via unix sockets and localhost, and possibly via network for streaming replicas) via pg_hba (and use at least peer and md5 authentication).

Changing the superuser's name does in no way increase security.

0
1

We have an audit finding which says that the "postgres" role must not be used at all.

This statement could be viewed in two ways and I'll address both:

  1. The PostgreSQL cluster must be installed with no reference to an account/role called 'postgres'.

This would be utter nonsense, akin to trying to run a Linux machine without a root account or renaming the "root" account to some other name, like "fred". It relies on Security through Obscurity (another Bad Idea), adds nothing of value and confuses everyone when things they normally expect to find are not there or are called something "weird".
Save your sanity, go back to the Auditors and challenge this "finding", asking them for both justification for it and recommendations on how to make it work.

  1. The postgres role must not be used for anything other than the internal operation of the PostgreSQL cluster.

By this, I meant that no individual ever logs on directly with this role (and password) or has it granted to their own account and no Application ever makes use of it. DBAs, of course, connect implicitly as the installation owner, but only on from the database host itself.

I'd say that this one is quite a Good Idea.
You don't have to "leak" these highly-elevated credentials, or have to weaken your security to allow it and you keep control of the all-powerful postgres account.
Always keep the biggest and best tools in the box for yourself, to clean up the mess that everyone/everything else makes!

5
  • #2 is what they mean. Knowing about the SQL Server "sa" login, and how it can be disabled, even deleted after a new sysadmin login has been created and all references to "sa" have been replaced by that new login. They don't even want it used for " the internal operation of the PostgreSQL cluster".
    – RonJohn
    Commented Apr 23, 2021 at 14:55
  • I connect to the instance using peer auth after sudoing into the Linux postgres account.
    – RonJohn
    Commented Apr 23, 2021 at 14:57
  • So they really don't want a postgres account/role used anywhere? That's my Option #1 and, IMHO, you should push back hard on this because it's counter-productive and pointless. What do they expect you to do? Create a new superuser account called "mysql"? :-) If the Auditors really want to insist on this, then get them to tell you how to do it reliably, robustly and recoverably. Very few other people do this, so if you run into any difficulties with this, you're probably on your own! Not a Good Place to put yourself.
    – Phill W.
    Commented Apr 26, 2021 at 8:02
  • Option #1 says "don't exist"; they want "not used". Unless I'm really dense on a Monday morning, I don't see how they are the same.
    – RonJohn
    Commented Apr 26, 2021 at 10:55
  • What do they expect you to do? Create a new superuser account called "mysql"? Yes, actually (although they are gracious enough to let me choose the name). It's not as weird as you make it seem, since SQL Server allows it.
    – RonJohn
    Commented Apr 26, 2021 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.