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 (<[email protected]>) escribió: > Anthony Sotolongo <[email protected]> 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 >
