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

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

Thanks for the explanation, Tom.
Given that passwordcheck is meant as sample code, I'll not continue with
this patch. In addition, I didn't know that the role name comes from a
shared catalog, so its encoding can't be assumed.

Regards,
Anthony

El mar, 24 nov 2026 a las 23:31, Tom Lane (<tgl(at)sss(dot)pgh(dot)pa(dot)us>) escribió:

> 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-11-25 12:55:24 Re: OOM kill in xmlelement() with large arrays
Previous Message Raja Sai pranav 2026-11-25 12:32:16 [PATCH] Fix off-by-one in -T tablespace mapping length check