Re: passwordcheck: Make the user name check case-insensitive

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Anthony Sotolongo <asotolongo(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: passwordcheck: Make the user name check case-insensitive
Date: 2026-11-25 02:31:48
Message-ID: 1230826.1795573908@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Anthony Sotolongo <asotolongo(at)gmail(dot)com> writes:
> contrib/passwordcheck rejects clear-text passwords that contain the role
> name, but the check uses a plain strstr(), so it is case-sensitive. A
> different capitalization is enough to get around it. For example, for a
> role named "alice":
> ALTER ROLE alice PASSWORD 'Alice2024!';
> is accepted, although the password obviously contains the role name.

passwordcheck is only intended as sample code, not a production-grade
check for weak passwords. I'm not sure we want to give people the
impression that it's good for anything more than that as-is.

> The attached patch lowercases both the password and the role name with
> str_tolower() before checking whether the password contains the role
> name, so the check becomes case-insensitive.

One reason I'm hesitant about that is that we don't really know the
name's encoding for sure, at least not in the ALTER ROLE pathway.
This problem is bigger than passwordcheck of course, but I'm not
in a hurry to make it worse by assuming that we know how to
case-fold strings found in a shared catalog.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2026-11-25 02:36:29 Small cleanup of leftover pre-1.1.0 OpenSSL code
Previous Message Chao Li 2026-11-25 02:29:29 Re: [PATCH] psql: Complete GRANTED BY in GRANT and REVOKE