Re: Add a warning message when using unencrypted passwords

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add a warning message when using unencrypted passwords
Date: 2024-12-08 22:08:47
Message-ID: CAGECzQTZ-2zaeeRZ0hF81XE93m2+fBciQh=hU39=UTZJFQOGvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 7 Dec 2024 at 15:40, Guillaume Lelarge <guillaume(at)lelarge(dot)info> wrote:
> > Whenever log_statement is set to all (which I understand should be done for a short period of time for troubleshooting purposes only), if we change the password for a user, or create a new user, the passwords would be logged in plain text. From a security point of view, this should not be allowed. Ideally, It should error out (or at least throw a warning) saying “while log_statement is set to ‘all’, you shouldn’t change passwords/create new user with passwords”.
>
> While I dislike the idea of throwing an error, I found the idea of a warning message really great. So kudos to her for the idea!

+1 for more clearly letting people know that what they're doing is not
recommended from a security standpoint.

Regarding warning vs error, I agree that a WARNING is probably the
right choice generally. But I think that Divya is correct: When
log_statement = 'all', an error should be thrown instead. Because when
that is the case, we know for sure that the password will be leaked to
the logs. And that error should contain something like: You should
consider this password compromised.

Throwing an error always actually has an interesting downside: We then
automatically log the statement, and thus the password to the log.
When I change the level to ERROR in your code, I get the following
(but with WARNING the STATEMENT line is not there):

2024-12-08 22:59:50.967 CET [104900] ERROR: using a plaintext
password in a query
2024-12-08 22:59:50.967 CET [104900] DETAIL: plaintext password may be logged.
2024-12-08 22:59:50.967 CET [104900] HINT: Refer to the PostgreSQL
documentation for details about using encrypted password in queries.
2024-12-08 22:59:50.967 CET [104900] STATEMENT: ALTER ROLE jelte
PASSWORD 'abc';

PS. I created a commit fest entry here:
https://commitfest.postgresql.org/51/5426/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-12-08 22:09:17 Re: Giving the shared catalogues a defined encoding
Previous Message Tom Lane 2024-12-08 19:25:53 Re: Assert failure on running a completed portal again