PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar conseilgouz
conseilgouz
26 Mar 2025

Create a strong password that respects user configuration if no password is given.

Summary of Changes

After PR #29859 , when creating a new user in administration user menu, if no password is entered, a 32-characters usercode is created. It contains a mix of uppercase/lowercase and/or numbers.
This does not respect what may have been defined in the password user configuration :

  • minimum length,
  • minimum number of uppercase,
  • minimum number of lowercase,
  • minimum number of special characters,
  • minimum number of numbers.

Testing Instructions

In user's configuration, define password options so that :

  • minimum length = 12
  • minimum numbers = 1
  • minimum symbols = 1
  • minimum upper case = 1
  • minimum lower case = 1

In administration, create a new user leaving password and confirm password fields empty.

Check creation user email.

Actual result BEFORE applying this Pull Request

A new user has been created with a 32-characters password. It contains a mix of uppercase/lowercase and/or numbers.

Expected result AFTER applying this Pull Request

A new user has been created with a 12-characters password. Itcontains a mix of uppercase/lowercase, numbers and special characters, as defined in the configuration.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar conseilgouz conseilgouz - open - 26 Mar 2025
avatar conseilgouz conseilgouz - change - 26 Mar 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Mar 2025
Category Libraries
avatar conseilgouz conseilgouz - change - 26 Mar 2025
The description was changed
avatar conseilgouz conseilgouz - edited - 26 Mar 2025
avatar conseilgouz conseilgouz - change - 26 Mar 2025
Labels Added: PR-5.2-dev
avatar brianteeman
brianteeman - comment - 26 Mar 2025

The code works but out of the box it generates a weaker password than it does currently. Is that really what we want?

avatar conseilgouz
conseilgouz - comment - 26 Mar 2025

Hi Brian,
Is it weaker due of its length or the way I created it ?

avatar brianteeman
brianteeman - comment - 26 Mar 2025

Hi Brian, Is it weaker due of its length or the way I created it ?

Nothing to do with your code per se.

Before this PR Out of the box we get a 32 character password generated
With this PR Out of the box we get a 12 character password generated

avatar conseilgouz
conseilgouz - comment - 26 Mar 2025

It's a user choice.

I have length = 12 in my configuration for testing purpose, to make sure it respects what I've defined.

avatar brianteeman
brianteeman - comment - 26 Mar 2025

My 2c - any password created in this way is sent in a simple email so if I was to make a change to this I would enforce the password reset functionality on login for all passwords created this way

avatar woluweb
woluweb - comment - 26 Mar 2025

The minimum length parameter means that if a User wants to change his/her password, that User has to respect this minimum length.

As such, creating by default a 32 character password is not contradictory with this minimum length : 32 respects ">12".

But indeed, I understand @conseilgouz (and the people in the community who first reported this issue on some Joomla forum): if a User is allowed to use a 12 character password, it would be consistent that the default password also has 12 characters (otherwise the real end-users of a website will never understand that they get a password which is almost three times as long as "is required").

You and I do use a password manager anyway and we don't care about 12, 32 or even 497 characters.
But in real life, this PR by @conseilgouz makes sense.

avatar AkameOuO
AkameOuO - comment - 27 Mar 2025

rand() is not cryptographically secure. I don't think it should be used in password generation.
see manual: https://www.php.net/manual/en/function.rand.php

avatar exlemor
exlemor - comment - 27 Mar 2025

I agree with Brian, it is better to generate a 32 character password by default... ( in today's processing power, 12 character passwords are not secure enough anyways.... ) and if a user receives a 32 character password, he would more likely think, it's good that Joomla generates a long, strong password. As for AkameOuO's comment, it would be good to switch to the recommended Random\Randomizer may be used with the Random\Engine\Secure engine.

avatar conseilgouz
conseilgouz - comment - 27 Mar 2025

thank you for your comments.
I replaced rand() function by a new function genRandomChar, based on genRandomPassword function.
As stated by Brian, if empty, the created password is sent to the new user by email.
The purpose of this PR is to make sure the new password fulfills site owner's requirements in terms of minimum size, uppercase, lowercase, number and symbol, as it will be shown to new users.

avatar brianteeman
brianteeman - comment - 27 Mar 2025

For the reasons previously stated I do not agree with this PR

avatar conseilgouz conseilgouz - change - 27 Mar 2025
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2025-03-27 08:51:16
Closed_By conseilgouz
avatar conseilgouz conseilgouz - close - 27 Mar 2025
avatar exlemor
exlemor - comment - 27 Mar 2025

@conseilgouz - while part of this PR may not be good - how about a PR for just upgrading the seeding process to use something better than rand() function by a new function genRandomChar, based on genRandomPassword function like you proposed?

That would be positive for everyone right?

avatar woluweb
woluweb - comment - 27 Mar 2025

To make everybody happy, I propose a new Parameter length of default password (or call it whatever is best)
It can be 32 by default, but at least people can decide to make it coherent with, for example, the minimum length

Add a Comment

Login with GitHub to post a comment