pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedsunsetting md5 password support
32+ messages / 14 participants
[nested] [flat]
* sunsetting md5 password support
@ 2024-10-09 19:55 Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 4 replies; 32+ messages in thread
From: Nathan Bossart @ 2024-10-09 19:55 UTC (permalink / raw)
To: pgsql-hackers
In this message, I propose a multi-year, incremental approach to remove MD5
password support from Postgres.
The problems with MD5 password hashes in Postgres are well-understood, so I
won't discuss them in too much detail here. But suffice it to say that MD5
has been considered to be unsuitable for use as a cryptographic hash
algorithm for some time [0], and cracking MD5-hashed passwords is trivial
on modern hardware [1]. Furthermore, MD5 password hashes in Postgres are
vulnerable to pass-the-hash attacks [2] [3], i.e., knowing the username and
hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these problems and
AFAIK is generally considered far superior. Since v14, this method has
been the default for the password_encryption parameter, which determines
the algorithm to use to store new passwords on disk (unless the password
has already been hashed by the client, as is recommended).
Given there is a battle-tested alternative to MD5, I propose we take the
following steps. I am not wedded to the exact details, but I feel that
this would be a reasonably conservative path forward.
1. In v18, continue to support MD5 passwords, but place several notes in
the documentation and release notes that unambiguously indicate that
MD5 password support is deprecated and will be removed in a future
release.
2. In v19, allow upgrading with MD5 passwords and allow authenticating
with them, but disallow creating new ones (i.e., restrict/remove
password_encryption and don't allow setting pre-hashed MD5 passwords).
3. In v20, allow upgrading with MD5 passwords, but disallow using them
for authentication. Users would only be able to update these
passwords to SCRAM-SHA-256 after upgrading.
4. In v21, disallow upgrading with MD5 passwords. At this point, there
should be no remaining MD5 password support in Postgres.
With this plan, the first version with all MD5 password support removed
would be released in 2028. Considering SCRAM-SHA-256 was first introduced
in 2017 and has been the default for password_encryption since 2021, users
will have had several years to migrate.
Thoughts?
[0] https://en.wikipedia.org/wiki/MD5#Security
[1] https://www.postgresql.org/docs/devel/pgcrypto.html#PGCRYPTO-HASH-SPEED-TABLE
[2] https://hashcat.net/misc/postgres-pth/postgres-pth.pdf
[3] https://www.postgresql.org/docs/devel/auth-password.html
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-09 20:30 Jelte Fennema-Nio <postgres@jeltef.nl>
parent: Nathan Bossart <nathandbossart@gmail.com>
3 siblings, 1 reply; 32+ messages in thread
From: Jelte Fennema-Nio @ 2024-10-09 20:30 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers
On Wed, 9 Oct 2024 at 21:55, Nathan Bossart <nathandbossart@gmail.com> wrote:
> In this message, I propose a multi-year, incremental approach to remove MD5
> password support from Postgres.
+many for the general idea
I think it makes sense to also remove the "password" authentication
option while we're at it (this can currently be used with SCRAM stored
passwords).
> 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> for authentication. Users would only be able to update these
> passwords to SCRAM-SHA-256 after upgrading.
This step sounds like a great way to stress out DBAs who don't read
the release notes carefully. I imagine the following situation: DBA
upgrades to v20. The upgrades succeed, but suddenly half the
applications cannot connect.
It seems much nicer to have the upgrade fail hard in the check phase,
to force all users and thus applications to upgrade their hash to the
new format, i.e. go right from step 2 to step 4.
> Thoughts?
I don't know what a reasonable deprecation cycle is. But I believe all
clients have supported SCRAM auth for quite a long time, so honestly
even disallowing upgrading with md5 passwords in v18/v19 might be
acceptable. I guess my main question is: Who's life do we make easier
by postponing the removal? Is the pain going to be significantly less
for some people by doing a spread out deprecation, instead of just
saying: We stop supporting it next release.
If the pain is going to be the same amount for users anyway, only
postponed a few years, then I don't see much of a reason to wait.
Side-thought: What about the deprecation cycle for md5/password auth
for libpq? I think we'd want to keep it at least 5 years after we
remove it from the server. Probably even longer. But I think we at
least might want to change the default of require_auth to
"!md5,!password" after 5 years.
On Wed, 9 Oct 2024 at 21:55, Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> In this message, I propose a multi-year, incremental approach to remove MD5
> password support from Postgres.
>
> The problems with MD5 password hashes in Postgres are well-understood, so I
> won't discuss them in too much detail here. But suffice it to say that MD5
> has been considered to be unsuitable for use as a cryptographic hash
> algorithm for some time [0], and cracking MD5-hashed passwords is trivial
> on modern hardware [1]. Furthermore, MD5 password hashes in Postgres are
> vulnerable to pass-the-hash attacks [2] [3], i.e., knowing the username and
> hashed password is sufficient to authenticate.
>
> The SCRAM-SHA-256 method added in v10 is not subject to these problems and
> AFAIK is generally considered far superior. Since v14, this method has
> been the default for the password_encryption parameter, which determines
> the algorithm to use to store new passwords on disk (unless the password
> has already been hashed by the client, as is recommended).
>
> Given there is a battle-tested alternative to MD5, I propose we take the
> following steps. I am not wedded to the exact details, but I feel that
> this would be a reasonably conservative path forward.
>
> 1. In v18, continue to support MD5 passwords, but place several notes in
> the documentation and release notes that unambiguously indicate that
> MD5 password support is deprecated and will be removed in a future
> release.
>
> 2. In v19, allow upgrading with MD5 passwords and allow authenticating
> with them, but disallow creating new ones (i.e., restrict/remove
> password_encryption and don't allow setting pre-hashed MD5 passwords).
>
> 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> for authentication. Users would only be able to update these
> passwords to SCRAM-SHA-256 after upgrading.
>
> 4. In v21, disallow upgrading with MD5 passwords. At this point, there
> should be no remaining MD5 password support in Postgres.
>
> With this plan, the first version with all MD5 password support removed
> would be released in 2028. Considering SCRAM-SHA-256 was first introduced
> in 2017 and has been the default for password_encryption since 2021, users
> will have had several years to migrate.
>
> Thoughts?
>
> [0] https://en.wikipedia.org/wiki/MD5#Security
> [1] https://www.postgresql.org/docs/devel/pgcrypto.html#PGCRYPTO-HASH-SPEED-TABLE
> [2] https://hashcat.net/misc/postgres-pth/postgres-pth.pdf
> [3] https://www.postgresql.org/docs/devel/auth-password.html
>
> --
> nathan
>
>
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-09 20:31 Greg Sabino Mullane <htamfids@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
3 siblings, 0 replies; 32+ messages in thread
From: Greg Sabino Mullane @ 2024-10-09 20:31 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers
Big +1 to the idea, but it's not going to be pretty; there is a lot of
baked-in MD5 stuff around.
> 2. In v19, allow upgrading with MD5 passwords and allow authenticating
> with them, but disallow creating new ones (i.e., restrict/remove
> password_encryption and don't allow setting pre-hashed MD5 passwords).
>
Certainly not remove it, that would break lots of things. Perhaps one
release with a strong warning when md5 is used, that cannot be disabled,
then disallow new ones?
> 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> for authentication.
Again, maybe a release that complains real loudly but still allows it?
> 4. In v21, disallow upgrading with MD5 passwords.
You mean having pg_upgrade refuse to go on? Or maybe have it empty the
passwords out?
Cheers,
Greg
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-09 20:44 Jonathan S. Katz <jkatz@postgresql.org>
parent: Nathan Bossart <nathandbossart@gmail.com>
3 siblings, 1 reply; 32+ messages in thread
From: Jonathan S. Katz @ 2024-10-09 20:44 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 10/9/24 3:55 PM, Nathan Bossart wrote:
> In this message, I propose a multi-year, incremental approach to remove MD5
> password support from Postgres.
+100; thanks for a concrete proposal. Cutting out the "well-understood"
problems bit.>
> Given there is a battle-tested alternative to MD5, I propose we take the
> following steps. I am not wedded to the exact details, but I feel that
> this would be a reasonably conservative path forward.
>
> 1. In v18, continue to support MD5 passwords, but place several notes in
> the documentation and release notes that unambiguously indicate that
> MD5 password support is deprecated and will be removed in a future
> release.
+1. Should we also add something in the logs? I've mixed feelings on
this, as this could end up leaking information about what auth methods
are used. But - maybe we can pick and choose what we log on, e.g. if
"md5" is set as an auth method in pg_hba.conf, we complain at
pg_hba.conf load/reload time that this is being deprecated.
> 2. In v19, allow upgrading with MD5 passwords and allow authenticating
> with them, but disallow creating new ones (i.e., restrict/remove
> password_encryption and don't allow setting pre-hashed MD5 passwords).
>
> 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> for authentication. Users would only be able to update these
> passwords to SCRAM-SHA-256 after upgrading
> 4. In v21, disallow upgrading with MD5 passwords. At this point, there
> should be no remaining MD5 password support in Postgres.
I wonder if we can compress this down into the v20 release. With v18
(2025), we've already had a year of warning (and I think as soon as we
commit to a plan, we start broadcasting it, so maybe more than a year).
With v19 (2026), we've started adding the inconveniences, and there's a
last chance to flip the password. With v20 (2027), we can then block
upgrades until they're rehashed. That's effectively 3 years from today -
we can also say it's within the 10 years since SCRAM was introduced,
which somewhat aligns with other deprecation timelines :)
Given the problems with the md5 method, I think we can be carefully
aggressive here with the deprecation, particularly given there's overall
wide support for SCRAM.
(The larger question, which I will pose at least to think on, is how do
we handle any future password method deprecations, e.g. say
SCRAM-SHA-512 comes out and we want to remove SCRAM-SHA-256? Not an
issue today, but we'd likely want to have a similar process in place).
Jonathan
[1] https://wiki.postgresql.org/wiki/List_of_drivers
Attachments:
[application/pgp-signature] OpenPGP_signature.asc (839B, ../../a19ed13d-f69e-4644-9c96-1e18aa7d6550@postgresql.org/2-OpenPGP_signature.asc)
download
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-09 22:14 Jacob Champion <jacob.champion@enterprisedb.com>
parent: Jonathan S. Katz <jkatz@postgresql.org>
0 siblings, 0 replies; 32+ messages in thread
From: Jacob Champion @ 2024-10-09 22:14 UTC (permalink / raw)
To: Jonathan S. Katz <jkatz@postgresql.org>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Wed, Oct 9, 2024 at 1:44 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
> On 10/9/24 3:55 PM, Nathan Bossart wrote:
> > 1. In v18, continue to support MD5 passwords, but place several notes in
> > the documentation and release notes that unambiguously indicate that
> > MD5 password support is deprecated and will be removed in a future
> > release.
>
> +1. Should we also add something in the logs?
I also think we should start logging warnings as soon as we agree to
deprecate MD5.
> I've mixed feelings on
> this, as this could end up leaking information about what auth methods
> are used.
Leak it to whom? The client and server both know MD5 is being used.
> > 2. In v19, allow upgrading with MD5 passwords and allow authenticating
> > with them, but disallow creating new ones (i.e., restrict/remove
> > password_encryption and don't allow setting pre-hashed MD5 passwords).
> >
> > 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> > for authentication. Users would only be able to update these
> > passwords to SCRAM-SHA-256 after upgrading
>
> > 4. In v21, disallow upgrading with MD5 passwords. At this point, there
> > should be no remaining MD5 password support in Postgres.
>
> I wonder if we can compress this down into the v20 release.
I'd like an accelerated schedule for this too. Your three-step
"complain, restrict, disallow", with strict pg_upgrade failure as part
of step 3, seems right to me.
> (The larger question, which I will pose at least to think on, is how do
> we handle any future password method deprecations, e.g. say
> SCRAM-SHA-512 comes out and we want to remove SCRAM-SHA-256? Not an
> issue today, but we'd likely want to have a similar process in place).
In general I like the three-step method for the server side. The
client side needs to be considered separately, though, like Jelte
pointed out; we have wire compatibility to maintain.
(For the exact example you provided, I think we'd only need a similar
process if the -256 variant turns out to be broken. Otherwise, the
cost of maintaining -256 and -512 together is probably going to be
very close to the cost of maintaining -512 alone, thanks to the past
work generalizing the hashing code. And there may be
security/performance tradeoffs for DBAs to make.)
Thanks,
--Jacob
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-09 23:11 Heikki Linnakangas <hlinnaka@iki.fi>
parent: Nathan Bossart <nathandbossart@gmail.com>
3 siblings, 3 replies; 32+ messages in thread
From: Heikki Linnakangas @ 2024-10-09 23:11 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 09/10/2024 22:55, Nathan Bossart wrote:
> In this message, I propose a multi-year, incremental approach to remove MD5
> password support from Postgres.
+1
> 2. In v19, allow upgrading with MD5 passwords and allow authenticating
> with them, but disallow creating new ones (i.e., restrict/remove
> password_encryption and don't allow setting pre-hashed MD5 passwords).
This is a bit weird state. What exactly is "upgrading"? I guess you mean
pg_upgrade, but lots of people use pg_dump & restore or logical
replication or something else entirely for upgrading. That's
indistinguishable from setting a pre-hashed MD5 password.
I think it's bad if you cannot pg_dump & restore your database.
> 3. In v20, allow upgrading with MD5 passwords, but disallow using them
> for authentication. Users would only be able to update these
> passwords to SCRAM-SHA-256 after upgrading.
This step makes more sense. Notably, if we disallow using the passwords
for authentication, there would be little harm in still allowing them to
be dumped & restored.
It seems pointless though. What's the point of "upgrading" with the MD5
passwords, if you can't use them? You might as well set all the MD5
passwords to null.
My feeling is that it would be less confusing to users to just disallow
md5 passwords in one release. I'm not sure these intermediate steps are
really doing anyone any favors.
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 12:27 Christoph Moench-Tegeder <cmt@burggraben.net>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
2 siblings, 0 replies; 32+ messages in thread
From: Christoph Moench-Tegeder @ 2024-10-10 12:27 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
## Heikki Linnakangas (hlinnaka@iki.fi):
> This is a bit weird state. What exactly is "upgrading"? I guess you
> mean pg_upgrade, but lots of people use pg_dump & restore or logical
> replication or something else entirely for upgrading. That's
> indistinguishable from setting a pre-hashed MD5 password.
Password hashes are only in the "globals" dump (pg_dumpall -r/-g),
not in standard pg_dump (and I don't see anything about passwords
in the binary-upgrade mode of pg_dump).
Finally it might be a good thing that we separated data and roles.
Maybe that even is a plan for pg_upgrade: understand md5-password
when they appear in pg_authid, but do not apply special treatment
in CREATE ROLE/ALTER ROLE, thus preventing the setting of md5
password as pre-hashed passwords.
Regards,
Christoph
--
Spare Space.
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 12:40 Andrew Dunstan <andrew@dunslane.net>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
2 siblings, 1 reply; 32+ messages in thread
From: Andrew Dunstan @ 2024-10-10 12:40 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 2024-10-09 We 7:11 PM, Heikki Linnakangas wrote:
> On 09/10/2024 22:55, Nathan Bossart wrote:
>> In this message, I propose a multi-year, incremental approach to
>> remove MD5
>> password support from Postgres.
>
> +1
>
>> 2. In v19, allow upgrading with MD5 passwords and allow
>> authenticating
>> with them, but disallow creating new ones (i.e., restrict/remove
>> password_encryption and don't allow setting pre-hashed MD5
>> passwords).
>
> This is a bit weird state. What exactly is "upgrading"? I guess you
> mean pg_upgrade, but lots of people use pg_dump & restore or logical
> replication or something else entirely for upgrading. That's
> indistinguishable from setting a pre-hashed MD5 password.
>
> I think it's bad if you cannot pg_dump & restore your database.
Hmm, yeah. It would be easy enough to prevent MD5 passwords in things
like CREATE ROLE / ALTER ROLE, but harder to check for MD5 if there are
direct updates to pg_authid. Maybe we need to teach pg_dumpall a way to
do that as a workaround?
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 20:13 Nathan Bossart <nathandbossart@gmail.com>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
2 siblings, 0 replies; 32+ messages in thread
From: Nathan Bossart @ 2024-10-10 20:13 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-hackers
On Thu, Oct 10, 2024 at 02:11:53AM +0300, Heikki Linnakangas wrote:
> My feeling is that it would be less confusing to users to just disallow md5
> passwords in one release. I'm not sure these intermediate steps are really
> doing anyone any favors.
As I'm reading the various responses in this thread, I do find myself
leaning in this direction. My intent with the incremental approach was to
provide gentle reminders to migrate for a few years before removing support
completely, but I suppose there will always be a subset of users that will
wait until we actually follow through. If we went this route, we could
still do step 1 (add deprecation notices), but there would just be one more
step along the lines of "after X years, remove all support." (Or maybe we
would remove server support after X years and then remove libpq support
after Y more years.)
In general, it seems like folks are generally onboard with removing MD5
password support. For v18, the only thing I'm hoping to accomplish is to
get the deprecation notices added, so I will start writing a patch for
that. Perhaps we should also consider adding WARNINGs whenever folks use
MD5 passwords in any fashion (with a corresponding GUC to turn those off).
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 21:03 Bruce Momjian <bruce@momjian.us>
parent: Jelte Fennema-Nio <postgres@jeltef.nl>
0 siblings, 1 reply; 32+ messages in thread
From: Bruce Momjian @ 2024-10-10 21:03 UTC (permalink / raw)
To: Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Wed, Oct 9, 2024 at 10:30:15PM +0200, Jelte Fennema-Nio wrote:
> On Wed, 9 Oct 2024 at 21:55, Nathan Bossart <nathandbossart@gmail.com> wrote:
> > In this message, I propose a multi-year, incremental approach to remove MD5
> > password support from Postgres.
>
> +many for the general idea
>
> I think it makes sense to also remove the "password" authentication
> option while we're at it (this can currently be used with SCRAM stored
> passwords).
I remember "password" as being recommended for SSL connections where
there is no risk of the password contents being seen.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
When a patient asks the doctor, "Am I going to die?", he means
"Am I going to die soon?"
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 21:45 Heikki Linnakangas <hlinnaka@iki.fi>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 32+ messages in thread
From: Heikki Linnakangas @ 2024-10-10 21:45 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 11/10/2024 00:03, Bruce Momjian wrote:
> On Wed, Oct 9, 2024 at 10:30:15PM +0200, Jelte Fennema-Nio wrote:
>> On Wed, 9 Oct 2024 at 21:55, Nathan Bossart <nathandbossart@gmail.com> wrote:
>>> In this message, I propose a multi-year, incremental approach to remove MD5
>>> password support from Postgres.
>>
>> +many for the general idea
>>
>> I think it makes sense to also remove the "password" authentication
>> option while we're at it (this can currently be used with SCRAM stored
>> passwords).
>
> I remember "password" as being recommended for SSL connections where
> there is no risk of the password contents being seen.
I wouldn't recommend it if SCRAM is available, but yeah, with TLS and
sslmode=verify-full, it's secure enough.
Note that some authentication methods like LDAP and Radius use
"password" authentication on the wire.
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 21:59 Jelte Fennema-Nio <postgres@jeltef.nl>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
1 sibling, 0 replies; 32+ messages in thread
From: Jelte Fennema-Nio @ 2024-10-10 21:59 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Bruce Momjian <bruce@momjian.us>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Thu, 10 Oct 2024 at 23:45, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> I wouldn't recommend it if SCRAM is available, but yeah, with TLS and
> sslmode=verify-full, it's secure enough.
Agreed, I'd definitely still recommend SCRAM over password. A big
downside of "password" auth over TLS is that plaintext passwords get
to the server, so a coredump would contain these passwords.
Also, I wanted to call out that SCRAM still needs sslmode=verify-full
to be fully secure. With the SCRAM hash of the server, together with a
MITM between client and server, an attacker can impersonate the client
without the client or server realizing. PgBouncer actually does this:
https://www.pgbouncer.org/config.html#limitations
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 22:00 Jesper Pedersen <jesper.pedersen@comcast.net>
parent: Heikki Linnakangas <hlinnaka@iki.fi>
1 sibling, 1 reply; 32+ messages in thread
From: Jesper Pedersen @ 2024-10-10 22:00 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; Bruce Momjian <bruce@momjian.us>; Jelte Fennema-Nio <postgres@jeltef.nl>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 10/10/24 5:45 PM, Heikki Linnakangas wrote:
> On 11/10/2024 00:03, Bruce Momjian wrote:
>> On Wed, Oct 9, 2024 at 10:30:15PM +0200, Jelte Fennema-Nio wrote:
>>> On Wed, 9 Oct 2024 at 21:55, Nathan Bossart
>>> <nathandbossart@gmail.com> wrote:
>>>> In this message, I propose a multi-year, incremental approach to
>>>> remove MD5
>>>> password support from Postgres.
>>>
>>> +many for the general idea
>>>
>>> I think it makes sense to also remove the "password" authentication
>>> option while we're at it (this can currently be used with SCRAM stored
>>> passwords).
>>
>> I remember "password" as being recommended for SSL connections where
>> there is no risk of the password contents being seen.
>
> I wouldn't recommend it if SCRAM is available, but yeah, with TLS and
> sslmode=verify-full, it's secure enough.
>
> Note that some authentication methods like LDAP and Radius use
> "password" authentication on the wire.
>
Please, deprecate - aka remove - old methods.
All client libraries have caught up, and if they havn't then it their
issue not Core.
+1.
Best regards,
Jesper
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 22:28 Tom Lane <tgl@sss.pgh.pa.us>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 2 replies; 32+ messages in thread
From: Tom Lane @ 2024-10-10 22:28 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> Hmm, yeah. It would be easy enough to prevent MD5 passwords in things
> like CREATE ROLE / ALTER ROLE, but harder to check for MD5 if there are
> direct updates to pg_authid. Maybe we need to teach pg_dumpall a way to
> do that as a workaround?
That seems like a pretty awful idea. Having dump scripts that
perform direct updates on pg_authid would lock us into supporting
the current physical representation (ie that pg_authid is in fact
a table with such-and-such columns) forever. Not to mention that
no such script could be restored with anything less than full
superuser privileges. And in return we're getting what exactly?
On the whole I agree with Heikki's comment that we should just
do it (disallow MD5, full stop) whenever we feel that enough
time has passed. These intermediate states are mostly going to
add headaches. Maybe we could do something with an intermediate
release that just emits warnings, without any feature changes.
regards, tom lane
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 22:34 Daniel Gustafsson <daniel@yesql.se>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 32+ messages in thread
From: Daniel Gustafsson @ 2024-10-10 22:34 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Heikki Linnakangas <hlinnaka@iki.fi>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
> On 11 Oct 2024, at 00:28, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> On the whole I agree with Heikki's comment that we should just
> do it (disallow MD5, full stop) whenever we feel that enough
> time has passed. These intermediate states are mostly going to
> add headaches. Maybe we could do something with an intermediate
> release that just emits warnings, without any feature changes.
+1, warnings and ample documentation for how to perform the migration (and why,
I'm sure it will come as a surprise to *many*) is likely our best investment.
That coupled with a well communicated point in time for when MD5 goes away with
notices in all release notes up until that point.
--
Daniel Gustafsson
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-10 22:39 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jesper Pedersen <jesper.pedersen@comcast.net>
0 siblings, 1 reply; 32+ messages in thread
From: Tom Lane @ 2024-10-10 22:39 UTC (permalink / raw)
To: Jesper Pedersen <jesper.pedersen@comcast.net>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Bruce Momjian <bruce@momjian.us>; Jelte Fennema-Nio <postgres@jeltef.nl>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
Jesper Pedersen <jesper.pedersen@comcast.net> writes:
> On 10/10/24 5:45 PM, Heikki Linnakangas wrote:
>> Note that some authentication methods like LDAP and Radius use
>> "password" authentication on the wire.
> Please, deprecate - aka remove - old methods.
> All client libraries have caught up, and if they havn't then it their
> issue not Core.
It's not the libraries that are the problem. It's the users that
want to use these auth methods --- perhaps even are required to
by dubiously-well-thought-out corporate policies.
regards, tom lane
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-11 06:50 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 32+ messages in thread
From: Laurenz Albe @ 2024-10-11 06:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Jesper Pedersen <jesper.pedersen@comcast.net>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Bruce Momjian <bruce@momjian.us>; Jelte Fennema-Nio <postgres@jeltef.nl>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Thu, 2024-10-10 at 18:39 -0400, Tom Lane wrote:
> Jesper Pedersen <jesper.pedersen@comcast.net> writes:
> > On 10/10/24 5:45 PM, Heikki Linnakangas wrote:
> > > Note that some authentication methods like LDAP and Radius use
> > > "password" authentication on the wire.
>
> > Please, deprecate - aka remove - old methods.
> > All client libraries have caught up, and if they havn't then it their
> > issue not Core.
>
> It's not the libraries that are the problem. It's the users that
> want to use these auth methods --- perhaps even are required to
> by dubiously-well-thought-out corporate policies.
A voice from the field: I know at least one application out there
(that is used by more than one customer) that implemented the line
protocol by itself, back in the days when "crypt" authentication still
existed. So they support "crypt" and "password", and now that
PostgreSQL has removed "crypt", the users are stuck with "password"...
Actually, that may be a good reason to deprecate "password", because
then the vendor might get motivated to remedy that malady. On the other
hand, you can expect some protest...
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-11 13:47 Andrew Dunstan <andrew@dunslane.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 32+ messages in thread
From: Andrew Dunstan @ 2024-10-11 13:47 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 2024-10-10 Th 6:28 PM, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>> Hmm, yeah. It would be easy enough to prevent MD5 passwords in things
>> like CREATE ROLE / ALTER ROLE, but harder to check for MD5 if there are
>> direct updates to pg_authid. Maybe we need to teach pg_dumpall a way to
>> do that as a workaround?
> That seems like a pretty awful idea. Having dump scripts that
> perform direct updates on pg_authid would lock us into supporting
> the current physical representation (ie that pg_authid is in fact
> a table with such-and-such columns) forever. Not to mention that
> no such script could be restored with anything less than full
> superuser privileges. And in return we're getting what exactly?
Well, I think if we keep a sort of half way house where we continue to
allow existing md5 passwords we'd have to do some ugly things. So ...
>
> On the whole I agree with Heikki's comment that we should just
> do it (disallow MD5, full stop) whenever we feel that enough
> time has passed. These intermediate states are mostly going to
> add headaches. Maybe we could do something with an intermediate
> release that just emits warnings, without any feature changes.
>
>
I also agree with this.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-11 21:36 Nathan Bossart <nathandbossart@gmail.com>
parent: Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-10-11 21:36 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Fri, Oct 11, 2024 at 09:47:58AM -0400, Andrew Dunstan wrote:
> On 2024-10-10 Th 6:28 PM, Tom Lane wrote:
>> On the whole I agree with Heikki's comment that we should just
>> do it (disallow MD5, full stop) whenever we feel that enough
>> time has passed. These intermediate states are mostly going to
>> add headaches. Maybe we could do something with an intermediate
>> release that just emits warnings, without any feature changes.
>
> I also agree with this.
Here is a first attempt at a patch for marking MD5 passwords as deprecated.
It's quite bare-bones at the moment, so I anticipate future revisions will
add more content. Besides sprinkling several deprecation notices
throughout the documentation, this patch teaches CREATE ROLE and ALTER ROLE
to emit warnings when setting MD5 passwords. A new GUC named
md5_password_warnings can be set to "off" to disable these warnings. I
considered adding even more warnings (e.g., when authenticating), but I
felt that would be far too noisy.
--
nathan
From a20f43d93562c4234de228ae3f0afae12750d7a0 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v1 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
contrib/passwordcheck/expected/passwordcheck.out | 3 +++
.../passwordcheck/expected/passwordcheck_1.out | 6 ++++++
doc/src/sgml/catalogs.sgml | 9 +++++++++
doc/src/sgml/client-auth.sgml | 8 ++++++++
doc/src/sgml/config.sgml | 8 ++++++++
doc/src/sgml/libpq.sgml | 9 +++++++++
doc/src/sgml/protocol.sgml | 8 ++++++++
doc/src/sgml/ref/create_role.sgml | 8 ++++++++
doc/src/sgml/runtime.sgml | 10 ++++++++++
src/backend/libpq/crypt.c | 10 ++++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/modules/test_misc/t/003_check_guc.pl | 2 +-
src/test/regress/expected/password.out | 15 +++++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++++
16 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..2f91b53b8a 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -13,6 +13,9 @@ ALTER USER regress_passwordcheck_user1 PASSWORD 'alessnicelongpassword';
ERROR: password must contain both letters and nonletters
-- encrypted ok (password is "secret")
ALTER USER regress_passwordcheck_user1 PASSWORD 'md592350e12ac34e52dd598f90893bb3ae7';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- error: password is user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'md507a112732ed9f2087fa90b192d44e358';
ERROR: password must not equal user name
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..ebb72956b0 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -13,6 +13,12 @@ ALTER USER regress_passwordcheck_user1 PASSWORD 'alessnicelongpassword';
ERROR: password must contain both letters and nonletters
-- encrypted ok (password is "secret")
ALTER USER regress_passwordcheck_user1 PASSWORD 'md592350e12ac34e52dd598f90893bb3ae7';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- error: password is user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'md507a112732ed9f2087fa90b192d44e358';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
DROP USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 9707d5238d..f6484f0210 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 2c4d5ef640..dac9eead0b 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2053,6 +2053,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 686309db58..4bdf214b31 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 667e0dc40a..d1be17615c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 3ae4bb1cd9..f4f2f1121a 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
# file.
# - Valid configuration options are followed immediately by " = ",
# with one space before and after the equal sign.
- if ($line =~ m/^#?([_[:alpha:]]+) = .*/)
+ if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
{
# Lower-case conversion matters for some of the GUCs.
my $param_name = lc($1);
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
Attachments:
[text/plain] v1-0001-Deprecate-MD5-passwords.patch (17.1K, ../../ZwmaW2AeUjBJGHgw@nathan/2-v1-0001-Deprecate-MD5-passwords.patch)
download | inline diff:
From a20f43d93562c4234de228ae3f0afae12750d7a0 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v1 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
contrib/passwordcheck/expected/passwordcheck.out | 3 +++
.../passwordcheck/expected/passwordcheck_1.out | 6 ++++++
doc/src/sgml/catalogs.sgml | 9 +++++++++
doc/src/sgml/client-auth.sgml | 8 ++++++++
doc/src/sgml/config.sgml | 8 ++++++++
doc/src/sgml/libpq.sgml | 9 +++++++++
doc/src/sgml/protocol.sgml | 8 ++++++++
doc/src/sgml/ref/create_role.sgml | 8 ++++++++
doc/src/sgml/runtime.sgml | 10 ++++++++++
src/backend/libpq/crypt.c | 10 ++++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/modules/test_misc/t/003_check_guc.pl | 2 +-
src/test/regress/expected/password.out | 15 +++++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++++
16 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..2f91b53b8a 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -13,6 +13,9 @@ ALTER USER regress_passwordcheck_user1 PASSWORD 'alessnicelongpassword';
ERROR: password must contain both letters and nonletters
-- encrypted ok (password is "secret")
ALTER USER regress_passwordcheck_user1 PASSWORD 'md592350e12ac34e52dd598f90893bb3ae7';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- error: password is user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'md507a112732ed9f2087fa90b192d44e358';
ERROR: password must not equal user name
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..ebb72956b0 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -13,6 +13,12 @@ ALTER USER regress_passwordcheck_user1 PASSWORD 'alessnicelongpassword';
ERROR: password must contain both letters and nonletters
-- encrypted ok (password is "secret")
ALTER USER regress_passwordcheck_user1 PASSWORD 'md592350e12ac34e52dd598f90893bb3ae7';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- error: password is user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'md507a112732ed9f2087fa90b192d44e358';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
DROP USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 9707d5238d..f6484f0210 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 2c4d5ef640..dac9eead0b 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2053,6 +2053,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 686309db58..4bdf214b31 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 667e0dc40a..d1be17615c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 3ae4bb1cd9..f4f2f1121a 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
# file.
# - Valid configuration options are followed immediately by " = ",
# with one space before and after the equal sign.
- if ($line =~ m/^#?([_[:alpha:]]+) = .*/)
+ if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
{
# Lower-case conversion matters for some of the GUCs.
my $param_name = lc($1);
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-16 15:30 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-10-16 15:30 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Fri, Oct 11, 2024 at 04:36:27PM -0500, Nathan Bossart wrote:
> Here is a first attempt at a patch for marking MD5 passwords as deprecated.
> It's quite bare-bones at the moment, so I anticipate future revisions will
> add more content. Besides sprinkling several deprecation notices
> throughout the documentation, this patch teaches CREATE ROLE and ALTER ROLE
> to emit warnings when setting MD5 passwords. A new GUC named
> md5_password_warnings can be set to "off" to disable these warnings. I
> considered adding even more warnings (e.g., when authenticating), but I
> felt that would be far too noisy.
In v2, I've added an entry for the new md5_password_warnings GUC to the
documentation, and I've simplified the passwordcheck test changes a bit.
--
nathan
From e7786f4d2e4c892d34c7992ffddbd1cf9e109be7 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v2 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 8 +++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/modules/test_misc/t/003_check_guc.pl | 2 +-
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
17 files changed, 127 insertions(+), 1 deletion(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 934ef5e469..9828f487cc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7865,6 +7873,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 2c4d5ef640..dac9eead0b 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2053,6 +2053,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 2c4cc8cd41..b4c98e40c5 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 667e0dc40a..d1be17615c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 3ae4bb1cd9..f4f2f1121a 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
# file.
# - Valid configuration options are followed immediately by " = ",
# with one space before and after the equal sign.
- if ($line =~ m/^#?([_[:alpha:]]+) = .*/)
+ if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
{
# Lower-case conversion matters for some of the GUCs.
my $param_name = lc($1);
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
Attachments:
[text/plain] v2-0001-Deprecate-MD5-passwords.patch (17.0K, ../../Zw_cAwYO5bhaku3k@nathan/2-v2-0001-Deprecate-MD5-passwords.patch)
download | inline diff:
From e7786f4d2e4c892d34c7992ffddbd1cf9e109be7 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v2 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 8 +++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/modules/test_misc/t/003_check_guc.pl | 2 +-
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
17 files changed, 127 insertions(+), 1 deletion(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 934ef5e469..9828f487cc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7865,6 +7873,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 2c4d5ef640..dac9eead0b 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2053,6 +2053,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 2c4cc8cd41..b4c98e40c5 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 667e0dc40a..d1be17615c 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 3ae4bb1cd9..f4f2f1121a 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
# file.
# - Valid configuration options are followed immediately by " = ",
# with one space before and after the equal sign.
- if ($line =~ m/^#?([_[:alpha:]]+) = .*/)
+ if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
{
# Lower-case conversion matters for some of the GUCs.
my $param_name = lc($1);
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-26 15:55 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-10-26 15:55 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
rebased
--
nathan
From 0f867b4b560c83f33b448df5a9b20a6d61ba2611 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v3 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 8 +++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
16 files changed, 126 insertions(+)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index dc401087dc..02311f6e3b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7892,6 +7900,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index a47fa67b38..2df386ab70 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2052,6 +2052,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8a67f01200..3f09ec41f9 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 39a3ac2312..b6907b2c80 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
Attachments:
[text/plain] v3-0001-Deprecate-MD5-passwords.patch (16.3K, ../../Zx0RAAiMda8s0JZl@nathan/2-v3-0001-Deprecate-MD5-passwords.patch)
download | inline diff:
From 0f867b4b560c83f33b448df5a9b20a6d61ba2611 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Fri, 11 Oct 2024 16:21:09 -0500
Subject: [PATCH v3 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: ???
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 8 +++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
16 files changed, 126 insertions(+)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..60a1d16288 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1260,6 +1260,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index dc401087dc..02311f6e3b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7892,6 +7900,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index a47fa67b38..2df386ab70 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2052,6 +2052,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8a67f01200..3f09ec41f9 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 39a3ac2312..b6907b2c80 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-28 20:21 Greg Sabino Mullane <htamfids@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Greg Sabino Mullane @ 2024-10-28 20:21 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Sat, Oct 26, 2024 at 11:55 AM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> rebased
>
Patch applied without issue and looks good to me.
Cheers,
Greg
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-28 21:10 Jim Nasby <jnasby@upgrade.com>
parent: Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 2 replies; 32+ messages in thread
From: Jim Nasby @ 2024-10-28 21:10 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
> On Oct 28, 2024, at 3:21 PM, Greg Sabino Mullane <htamfids@gmail.com> wrote:
>
> On Sat, Oct 26, 2024 at 11:55 AM Nathan Bossart <nathandbossart@gmail.com <mailto:nathandbossart@gmail.com>> wrote:
>> rebased
>
> Patch applied without issue and looks good to me.
Patch itself looks good, but it does leave me wondering if cleartext should also be deprecated?
Might also be worth mentioning deprecation in pg_hba.conf.
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-28 21:24 Tom Lane <tgl@sss.pgh.pa.us>
parent: Jim Nasby <jnasby@upgrade.com>
1 sibling, 0 replies; 32+ messages in thread
From: Tom Lane @ 2024-10-28 21:24 UTC (permalink / raw)
To: Jim Nasby <jnasby@upgrade.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
Jim Nasby <jnasby@upgrade.com> writes:
> Patch itself looks good, but it does leave me wondering if cleartext should also be deprecated?
Not much point unless we also deprecate all of the other auth methods
that require cleartext password transmission, which from a quick
scan include PAM, BSD, LDAP, and RADIUS. Seems unlikely to fly.
In any case, I don't think this is about password security per se.
It's more about deprecating a method that might look like it's
secure but isn't. In the case of the cleartext-password methods,
it's obvious that you'd better use SSL or GSS encryption if you
want your password hidden from network tapping.
I don't recall how in-your-face we are about that point, but
certainly the docs need to be up front about it, and probably
make the point explicitly with respect to the four methods
listed above.
regards, tom lane
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-10-29 01:06 Nathan Bossart <nathandbossart@gmail.com>
parent: Jim Nasby <jnasby@upgrade.com>
1 sibling, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-10-29 01:06 UTC (permalink / raw)
To: Jim Nasby <jnasby@upgrade.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Mon, Oct 28, 2024 at 04:10:29PM -0500, Jim Nasby wrote:
> Patch itself looks good, but it does leave me wondering if cleartext
> should also be deprecated?
I see that Tom has already chimed in on this point. In any case, this is
probably a topic for another thread.
> Might also be worth mentioning deprecation in pg_hba.conf.
Yeah. I vaguely recall waffling on whether to add one there, and for
whatever reason, I decided against it. I've added it in v4.
--
nathan
From 716ca7332ed3e9e7e23146c926f93cb759a0d227 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Mon, 28 Oct 2024 19:54:02 -0500
Subject: [PATCH v4 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: Greg Sabino Mullane, Jim Nasby
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 17 +++++++++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
16 files changed, 135 insertions(+)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..782b49c85a 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -531,6 +531,15 @@ include_dir <replaceable>directory</replaceable>
user's password. See <xref linkend="auth-password"/>
for details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -1260,6 +1269,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index dc401087dc..02311f6e3b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7892,6 +7900,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index a47fa67b38..2df386ab70 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2052,6 +2052,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8a67f01200..3f09ec41f9 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 39a3ac2312..b6907b2c80 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
Attachments:
[text/plain] v4-0001-Deprecate-MD5-passwords.patch (16.9K, ../../ZyA0_8P8F3WHWnFu@nathan/2-v4-0001-Deprecate-MD5-passwords.patch)
download | inline diff:
From 716ca7332ed3e9e7e23146c926f93cb759a0d227 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Mon, 28 Oct 2024 19:54:02 -0500
Subject: [PATCH v4 1/1] Deprecate MD5 passwords.
MD5 has been considered to be unsuitable for use as a cryptographic
hash algorithm for some time. Furthermore, MD5 password hashes in
PostgreSQL are vulnerable to pass-the-hash attacks, i.e., knowing
the username and hashed password is sufficient to authenticate.
The SCRAM-SHA-256 method added in v10 is not subject to these
problems and is considered to be superior to MD5.
This commit marks MD5 password support in PostgreSQL as deprecated
and to be removed in a future release. The documentation now
contains several deprecation notices, and CREATE ROLE and ALTER
ROLE now emit deprecation warnings when setting MD5 passwords. The
warnings can be disabled by setting the md5_password_warnings
parameter to "off".
Reviewed-by: Greg Sabino Mullane, Jim Nasby
Discussion: https://postgr.es/m/ZwbfpJJol7lDWajL%40nathan
---
.../passwordcheck/expected/passwordcheck.out | 1 +
.../expected/passwordcheck_1.out | 1 +
contrib/passwordcheck/sql/passwordcheck.sql | 1 +
doc/src/sgml/catalogs.sgml | 9 +++++++
doc/src/sgml/client-auth.sgml | 17 +++++++++++++
doc/src/sgml/config.sgml | 24 +++++++++++++++++++
doc/src/sgml/libpq.sgml | 9 +++++++
doc/src/sgml/protocol.sgml | 8 +++++++
doc/src/sgml/ref/create_role.sgml | 8 +++++++
doc/src/sgml/runtime.sgml | 10 ++++++++
src/backend/libpq/crypt.c | 10 ++++++++
src/backend/utils/misc/guc_tables.c | 9 +++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 3 +++
src/test/regress/expected/password.out | 15 ++++++++++++
src/test/regress/expected/password_1.out | 9 +++++++
16 files changed, 135 insertions(+)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 2027681daf..dfb2ccfe00 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/expected/passwordcheck_1.out b/contrib/passwordcheck/expected/passwordcheck_1.out
index 5d8d5dcc1c..9519d60a49 100644
--- a/contrib/passwordcheck/expected/passwordcheck_1.out
+++ b/contrib/passwordcheck/expected/passwordcheck_1.out
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
diff --git a/contrib/passwordcheck/sql/passwordcheck.sql b/contrib/passwordcheck/sql/passwordcheck.sql
index 1fbd6b0e96..5953ece5c2 100644
--- a/contrib/passwordcheck/sql/passwordcheck.sql
+++ b/contrib/passwordcheck/sql/passwordcheck.sql
@@ -1,3 +1,4 @@
+SET md5_password_warnings = off;
LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 964c819a02..0b9ca087c8 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1618,6 +1618,15 @@
will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in a
+ future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 51343de7ca..782b49c85a 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -531,6 +531,15 @@ include_dir <replaceable>directory</replaceable>
user's password. See <xref linkend="auth-password"/>
for details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -1260,6 +1269,14 @@ omicron bryanh guest1
server is encrypted for SCRAM (see below), then SCRAM-based
authentication will automatically be chosen instead.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer to
+ the text below for details about migrating to another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index dc401087dc..02311f6e3b 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1124,6 +1124,14 @@ include_dir 'conf.d'
mechanism, and hence not work with passwords encrypted with
SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
@@ -7892,6 +7900,22 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
</listitem>
</varlistentry>
+ <varlistentry id="guc-md5-password-warnings" xreflabel="md5_password_warnings">
+ <term><varname>md5_password_warnings</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>md5_password_warnings</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls whether a <literal>WARNING</literal> about MD5 password
+ deprecation is produced when a <command>CREATE ROLE</command> or
+ <command>ALTER ROLE</command> statement sets an MD5-encrypted password.
+ The default value is <literal>on</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
<sect2 id="runtime-config-logging-csvlog">
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index afc9346757..54a7bcf6bb 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1341,6 +1341,15 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<para>
The server must request MD5 hashed password authentication.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be
+ removed in a future release of
+ <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 057c46f3f5..b7ecee02c0 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -312,6 +312,14 @@
(Keep in mind the <function>md5()</function> function returns its
result as a hex string.)
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml
index f72ba9affc..cee23b1ea6 100644
--- a/doc/src/sgml/ref/create_role.sgml
+++ b/doc/src/sgml/ref/create_role.sgml
@@ -273,6 +273,14 @@ in sync when changing the above synopsis!
different format). This allows reloading of encrypted passwords
during dump/restore.
</para>
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed
+ in a future release of <productname>PostgreSQL</productname>. Refer
+ to <xref linkend="auth-password"/> for details about migrating to
+ another password type.
+ </para>
+ </warning>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index a47fa67b38..2df386ab70 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -2052,6 +2052,16 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
is an Internet standard and is more secure than the PostgreSQL-specific
MD5 authentication protocol.
</para>
+
+ <warning>
+ <para>
+ Support for MD5-encrypted passwords is deprecated and will be removed in
+ a future release of <productname>PostgreSQL</productname>. Refer to
+ <xref linkend="auth-password"/> for details about migrating to another
+ password type.
+ </para>
+ </warning>
+
</listitem>
</varlistentry>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index b01525dc28..d37c70901b 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -24,6 +24,8 @@
#include "utils/syscache.h"
#include "utils/timestamp.h"
+/* Enables deprecation warnings for MD5 passwords. */
+bool md5_password_warnings = true;
/*
* Fetch stored password for a user, for authentication.
@@ -174,6 +176,14 @@ encrypt_password(PasswordType target_type, const char *role,
MAX_ENCRYPTED_PASSWORD_LEN)));
}
+ if (md5_password_warnings &&
+ get_password_type(encrypted_password) == PASSWORD_TYPE_MD5)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("setting an MD5-encrypted password"),
+ errdetail("MD5 password support is deprecated and will be removed in a future release of PostgreSQL."),
+ errhint("Refer to the PostgreSQL documentation for details about migrating to another password type.")));
+
return encrypted_password;
}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8a67f01200..3f09ec41f9 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2076,6 +2076,15 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"md5_password_warnings", PGC_USERSET, CONN_AUTH_AUTH,
+ gettext_noop("Enables deprecation warnings for MD5 passwords."),
+ },
+ &md5_password_warnings,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 39a3ac2312..b6907b2c80 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,6 +96,7 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
+#md5_password_warnings = on
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index 0bb4400435..db7ea7bd1f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -25,6 +25,9 @@
*/
#define MAX_ENCRYPTED_PASSWORD_LEN (512)
+/* Enables deprecation warnings for MD5 passwords. */
+extern PGDLLIMPORT bool md5_password_warnings;
+
/*
* Types of password hashes or secrets.
*
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index df3857460c..9bb3ab2818 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,8 +14,14 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
CREATE ROLE regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
CREATE ROLE regress_passwd4 PASSWORD NULL;
@@ -57,14 +63,23 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
diff --git a/src/test/regress/expected/password_1.out b/src/test/regress/expected/password_1.out
index bd0c2e48de..8f613e976a 100644
--- a/src/test/regress/expected/password_1.out
+++ b/src/test/regress/expected/password_1.out
@@ -61,12 +61,18 @@ ALTER ROLE regress_passwd2 PASSWORD 'foo';
ERROR: password encryption failed: unsupported
-- already encrypted, use as they are
ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=';
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
@@ -100,6 +106,9 @@ SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+
CREATE ROLE regress_passwd_empty PASSWORD '';
NOTICE: empty string is not a valid password, clearing password
ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a';
+WARNING: setting an MD5-encrypted password
+DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL.
+HINT: Refer to the PostgreSQL documentation for details about migrating to another password type.
ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=';
NOTICE: empty string is not a valid password, clearing password
SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
--
2.39.5 (Apple Git-154)
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-19 23:05 Nathan Bossart <nathandbossart@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-11-19 23:05 UTC (permalink / raw)
To: Jim Nasby <jnasby@upgrade.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
I've gotten a couple of reviews on this patch, and the thread has been
quiet for a while now, so I'm considering committing this soon. There is
still plenty of time to make any adjustments that are suggested
post-commit.
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-20 00:29 Greg Sabino Mullane <htamfids@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Greg Sabino Mullane @ 2024-11-20 00:29 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
I just took a fresh look at / compiled this patch, and it all works as
advertised. My one minor nit is this hint:
HINT: Refer to the PostgreSQL documentation for details about migrating to
another password type.
We don't really have that in the docs, as near as I can tell, the closest
is 20.5 which says "make all users set new passwords, and change the
authentication method specifications in pg_hba.conf to scram-sha-256."
Maybe that's enough?
Cheers,
Greg
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-20 01:55 Nathan Bossart <nathandbossart@gmail.com>
parent: Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-11-20 01:55 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Tue, Nov 19, 2024 at 07:29:27PM -0500, Greg Sabino Mullane wrote:
> I just took a fresh look at / compiled this patch, and it all works as
> advertised. My one minor nit is this hint:
>
> HINT: Refer to the PostgreSQL documentation for details about migrating to
> another password type.
>
> We don't really have that in the docs, as near as I can tell, the closest
> is 20.5 which says "make all users set new passwords, and change the
> authentication method specifications in pg_hba.conf to scram-sha-256."
> Maybe that's enough?
That was my initial thinking. I think we have a few other options:
* Expand the documentation. Perhaps we could add a step-by-step guide for
migrating to SCRAM-SHA-256 since more users will need to do so when MD5
password support is removed.
* Remove the hint. It's arguably doing little more than pointing out the
obvious, and it doesn't actually tell users where in the documentation to
look for this information, anyway.
* Both of the above.
WDYT?
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-20 15:56 Greg Sabino Mullane <htamfids@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Greg Sabino Mullane @ 2024-11-20 15:56 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Tue, Nov 19, 2024 at 8:55 PM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> * Expand the documentation. Perhaps we could add a step-by-step guide
> for migrating to SCRAM-SHA-256 since more users will need to do so when
> MD5 password support is removed.
> * Remove the hint. It's arguably doing little more than pointing out the
> obvious, and it doesn't actually tell users where in the documentation
> to look for this information, anyway.
>
I think both ideally, but maybe just the hint removal for this patch?
On the other hand, "change your password and update pg_hba.conf" is pretty
much all you need, so not sure how detailed we want to get. :)
Cheers,
Greg
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-20 16:33 Nathan Bossart <nathandbossart@gmail.com>
parent: Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Nathan Bossart @ 2024-11-20 16:33 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Wed, Nov 20, 2024 at 10:56:11AM -0500, Greg Sabino Mullane wrote:
> On Tue, Nov 19, 2024 at 8:55 PM Nathan Bossart <nathandbossart@gmail.com>
> wrote:
>
>> * Expand the documentation. Perhaps we could add a step-by-step guide
>> for migrating to SCRAM-SHA-256 since more users will need to do so when
>> MD5 password support is removed.
>> * Remove the hint. It's arguably doing little more than pointing out the
>> obvious, and it doesn't actually tell users where in the documentation
>> to look for this information, anyway.
>>
>
> I think both ideally, but maybe just the hint removal for this patch?
>
> On the other hand, "change your password and update pg_hba.conf" is pretty
> much all you need, so not sure how detailed we want to get. :)
After thinking about this some more, I'm actually finding myself leaning
towards leaving the hint and potentially adding more detail to the
documentation as a follow-up patch. While the hint arguably points out the
obvious, it should at least nudge users in the right direction instead of
just telling them to stop using MD5 passwords. I've always found it
incredibly frustrating when something is marked deprecated but there's zero
information about what to do instead.
I also see a few existing cases where we refer users to the documentation,
so it's not without precedent.
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-11-21 01:17 Greg Sabino Mullane <htamfids@gmail.com>
parent: Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 32+ messages in thread
From: Greg Sabino Mullane @ 2024-11-21 01:17 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Wed, Nov 20, 2024 at 11:33 AM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> After thinking about this some more, I'm actually finding myself leaning
> towards leaving the hint and potentially adding more detail to the
> documentation as a follow-up patch.
Sounds good to me. I think my hesitation was more that the hint was
overpromising help, so big +1 to more detail and keeping it.
Cheers,
Greg
^ permalink raw reply [nested|flat] 32+ messages in thread
* Re: sunsetting md5 password support
@ 2024-12-02 19:33 Nathan Bossart <nathandbossart@gmail.com>
parent: Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 0 replies; 32+ messages in thread
From: Nathan Bossart @ 2024-12-02 19:33 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Jim Nasby <jnasby@upgrade.com>; Andrew Dunstan <andrew@dunslane.net>; Tom Lane <tgl@sss.pgh.pa.us>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-hackers
On Wed, Nov 20, 2024 at 08:17:07PM -0500, Greg Sabino Mullane wrote:
> Sounds good to me. I think my hesitation was more that the hint was
> overpromising help, so big +1 to more detail and keeping it.
Committed. If anyone wants to try putting together a patch that expands
the "migrating to SCRAM" section of the docs before I get to it, please be
my guest.
--
nathan
^ permalink raw reply [nested|flat] 32+ messages in thread
end of thread, other threads:[~2024-12-02 19:33 UTC | newest]
Thread overview: 32+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 19:55 sunsetting md5 password support Nathan Bossart <nathandbossart@gmail.com>
2024-10-09 20:30 ` Jelte Fennema-Nio <postgres@jeltef.nl>
2024-10-10 21:03 ` Bruce Momjian <bruce@momjian.us>
2024-10-10 21:45 ` Heikki Linnakangas <hlinnaka@iki.fi>
2024-10-10 21:59 ` Jelte Fennema-Nio <postgres@jeltef.nl>
2024-10-10 22:00 ` Jesper Pedersen <jesper.pedersen@comcast.net>
2024-10-10 22:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-11 06:50 ` Laurenz Albe <laurenz.albe@cybertec.at>
2024-10-09 20:31 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-10-09 20:44 ` Jonathan S. Katz <jkatz@postgresql.org>
2024-10-09 22:14 ` Jacob Champion <jacob.champion@enterprisedb.com>
2024-10-09 23:11 ` Heikki Linnakangas <hlinnaka@iki.fi>
2024-10-10 12:27 ` Christoph Moench-Tegeder <cmt@burggraben.net>
2024-10-10 12:40 ` Andrew Dunstan <andrew@dunslane.net>
2024-10-10 22:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-10 22:34 ` Daniel Gustafsson <daniel@yesql.se>
2024-10-11 13:47 ` Andrew Dunstan <andrew@dunslane.net>
2024-10-11 21:36 ` Nathan Bossart <nathandbossart@gmail.com>
2024-10-16 15:30 ` Nathan Bossart <nathandbossart@gmail.com>
2024-10-26 15:55 ` Nathan Bossart <nathandbossart@gmail.com>
2024-10-28 20:21 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-10-28 21:10 ` Jim Nasby <jnasby@upgrade.com>
2024-10-28 21:24 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-10-29 01:06 ` Nathan Bossart <nathandbossart@gmail.com>
2024-11-19 23:05 ` Nathan Bossart <nathandbossart@gmail.com>
2024-11-20 00:29 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-11-20 01:55 ` Nathan Bossart <nathandbossart@gmail.com>
2024-11-20 15:56 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-11-20 16:33 ` Nathan Bossart <nathandbossart@gmail.com>
2024-11-21 01:17 ` Greg Sabino Mullane <htamfids@gmail.com>
2024-12-02 19:33 ` Nathan Bossart <nathandbossart@gmail.com>
2024-10-10 20:13 ` Nathan Bossart <nathandbossart@gmail.com>
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