Subject: Re: Password complexity/history - credcheck?

From: Tom Lane <[email-masked]>
Date: Sat, 22 Jun 2024 20:23:08 -0400

Martin Goodson <[email-masked]> writes:
> Recently our security team have wanted to apply password complexity 
> checks akin to Oracle's profile mechanism to PostgreSQL, checking that a 
> password hasn't been used in x months etc, has minimum length, x special 
> characters and x numeric characters, mixed case etc.

Don't suppose it would help to push back on whether your security
team knows what they're doing.

The really key reason why server-side password checks are not as
bright an idea as they sound is that they cannot be implemented
without forcing the client to transmit the password in cleartext.
It's widely considered best practice if the server *never* sees
the user's cleartext password, because then it can't leak, either
from sniffing the connection or scraping the postmaster log.

I believe that practices such as forcing a password change every
X amount of time are not viewed as favorably as they once were,
either.  (The argument is that that discourages users from putting
any serious thought into choosing an uncrackable password, and
might well encourage them to write down their current and last few
passwords somewhere.)

Anyway, considerations like these are why there's not features
of this sort in community PG.  You can use an extension that
applies some checks, but there's no good way around the "needs
cleartext password" problem for that.

			regards, tom lane

---

From: Martin Goodson <[email-masked]>
Date: Sun, 23 Jun 2024 10:30:17 +0100

On 23/06/2024 01:23, Tom Lane wrote:

> ...

I believe that our security team is getting most of this from our 
auditors, who seem convinced that minimal complexity, password history 
etc are the way to go despite the fact that, as you say, server-side 
password checks can't really be implemented when the database receives a 
hash rather than a clear text password and password minimal complexity 
etc is not perhaps considered the gold standard it once was.

In fact, I think they see a hashed password as a disadvantage.

credcheck seems to satisfy their requirements - password complexity, 
password history, etc but - and this is the crucial bit - only on 
cleartext passwords.

If I'm forced to go to cleartext passwords, which would be a nightmare, 
credcheck might be worth looking at, but I'm not sure whether or not it 
is well adopted, reliable, and without significant issues. I only heard 
about it a few days ago from a friend/colleague, so I was wondering if 
anybody else was using it and what experiences with it might be.

Regards,

Martin.

-- 
Martin Goodson.

"Have you thought up some clever plan, Doctor?"
"Yes, Jamie, I believe I have."
"What're you going to do?"
"Bung a rock at it."

---

From: Christoph Moench-Tegeder <[email-masked]>
Date: Sun, 23 Jun 2024 12:49:04 +0200

## Martin Goodson ([email-masked]):

> password checks can't really be implemented when the database receives
> a hash rather than a clear text password and password minimal
> complexity etc is not perhaps considered the gold standard it once
> was.

The current state of the art is documented (as in, "official", for
arguing with auditors) at
https://pages.nist.gov/800-63-3/sp800-63b.html#sec5

My advice would be to not use secrets stored in the database -
that is, do not use scram-sha-256 - but use an external authentication
system, like Kerberos (might be AD) or LDAP (might also be AD) and have
that managed by the security team: that way all these compliance
topics which they brought up also become their problem :) and a lot
of the processes of recovering and disabling accounts and changing
passords move into a central location, which is most often a good thing[tm].
Or maybe move to client certificates, but if you're managing more
than a few personal accounts rotating certificates might become a
hassle (depending on your user base).

Regards,
Christoph

-- 
Spare Space

---

From: Martin Goodson <[email-masked]>
Date: Sun, 23 Jun 2024 14:14:43 +0100

> that managed by the security team: that way all these compliance

Crikey, that would be  quite a lot of  lot of SSL/TLS to set up. We have 
quite a few (massive understatement :( ... ) PostgreSQL database 
clusters spread over quite a lot (another understatement) of VMs.

The last time I suggested LDAP there was a lot of enthusiasm ... until 
they went down and looked at what might have to be done, after which it 
all became very quiet ...

Regards,

Martin.

---

From: Greg Sabino Mullane <[email-masked]>
Date: Sun, 23 Jun 2024 11:09:26 -0400

> In fact, I think they see a hashed password as a disadvantage.

Wow, full stop right there. This is a hill to die on.

Push back and get some competent auditors. This should not be a DBAs
problem. Your best bet is to use Kerberos, and throw the password
requirements out of the database realm entirely.

Also, the discussion should be about 2FA, not password history/complexity.

Cheers,
Greg

---

From: Laurenz Albe <[email-masked]>
Date: Mon, 24 Jun 2024 10:20:56 +0200

On Sun, 2024-06-23 at 14:14 +0100, Martin Goodson wrote:
> Crikey, that would be  quite a lot of  lot of SSL/TLS to set up. We have quite a
> few (massive understatement :( ... ) PostgreSQL database clusters spread over 
> quite a lot (another understatement) of VMs.
> 
> The last time I suggested LDAP there was a lot of enthusiasm ... until they went
> down and looked at what might have to be done, after which it all became very quiet ...

Yes, LDAP is not perfect for that - for one, every connection to the database would
also hit the LDAP server.

Kerberos or certificate authentication is probably better.

For many PostgreSQL clusters and clients, that might be a lot of work.
But not all your PostgreSQL databases will contain equally sensitive data.
You could start with the important ones, try to automatize as much as possible,
and roll out the changes over time.

Yours,
Laurenz Albe

---

From: o1bigtenor <[email-masked]>
Date: Mon, 24 Jun 2024 07:59:31 -0500

> Also, the discussion should be about 2FA, not password history/complexity.
Hmmmmmmm - - - - 2FA - - - - what I've seen of it so far is that
authentication is most often done
using totally insecure tools (emailing some numbers or using SMS). Now if
you were espousing
the use of security dongles and such I would agree - - - - otherwise you
are promoting the veneering
of insecurity on insecurity with the hope that this helps.

IMO having excellent passwords far trumps even 2FA - - - - 2FA is useful
when simple or quite
easily broken passwords are required.  Now when you add the lack of SMS
possibilities (due to lack of signal) 2FA is an usually potent PITA because
of course SMS 'always' works (except it doesn't(!!!!!!!!!!!!!!!!)).

(Can you tell that I've been bitten in the posterior repeatedly with this
garbage?)

Regards

---

From: Chris Travers <[email-masked]>
Date: Mon, 24 Jun 2024 20:30:44 +0700

> (Can you tell that I've been bitten in the posterior repeatedly with this

For 2FA, a simple solution is to require a password plus
clientcert=sameuser.  This allows you to authorize devices/user accounts
for specific remote database connections and provides that second factor --
i.e. something you have as well as something you know.

-- 
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor
lock-in.
http://www.efficito.com/learn_more

---

From: Christoph Moench-Tegeder <[email-masked]>
Date: Mon, 24 Jun 2024 17:01:47 +0200

## Martin Goodson ([email-masked]):

> Crikey, that would be  quite a lot of  lot of SSL/TLS to set up. We
> have quite a few (massive understatement :( ... ) PostgreSQL database

No matter what: you'll have to touch all your instances anyways.
The good thing is that all the options (including TLS) can be
automatically deployed iff you're set up for that - and you should
be, especially when you have "many" databases.

> they went down and looked at what might have to be done, after which
> it all became very quiet ...

With "many" databases and personal accounts, you should have some
sort of central management (else even an inventory of the accounts
("who can access what") is a nightmare). Finding the best ways towards
that goal for your organization could be beyond the scope of an email
list - but I'd start with looking at what you already have. I mentioned
LDAP because all too often that's the system which you can most easily
get access to (but depending on your environment, that might mot be
the best solution).

Regards,
Christoph

-- 
Spare Space.