passwordcheck: Make the user name check case-insensitive

From: Anthony Sotolongo <asotolongo(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: passwordcheck: Make the user name check case-insensitive
Date: 2026-11-25 02:18:52
Message-ID: CAASDfF3fvn8Nc_aFn7S8iyoECQ1=RqMvkfrg2NZi66O0rXBD1A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

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.

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.

Best regards

Attachment Content-Type Size
v1-0001-passwordcheck-Make-the-user-name-check-case-insen.patch text/x-patch 5.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-11-25 02:29:29 Re: [PATCH] psql: Complete GRANTED BY in GRANT and REVOKE
Previous Message Andreas Karlsson 2026-11-25 02:12:29 Re: Let OpenSSL auto-select DH parameters by default