Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] Improve entropy estimation in PasswordStrengthValidator #49879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2023

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Mar 31, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Improves a bit the estimation of the entropy from #49856

/cc @Spomky

@Spomky
Copy link
Contributor

Spomky commented Mar 31, 2023

Hello @nicolas-grekas,

I played with this new calculation method and it gives an entropy that is approx +40% compare to the one I proposed.
I have no remark to be honest.

  • A 8-chars password with [a-zA-Z0-9]+symbols has almost always a strength of 2, which is fine.
  • A 10-chars ones gives 3
  • With 12-chars or more I have 4
    Looks good to me 👌🏼.

@Spomky
Copy link
Contributor

Spomky commented Mar 31, 2023

Also, as noted by @stof in this #49868 (comment), the named argument of constriant should be at the end.
We could take the opportunity of this PR to move the argument $minScore.

@nicolas-grekas
Copy link
Member Author

We could take the opportunity of this PR to move the argument $minScore.

Right, updated!

it gives an entropy that is approx +40%

Thanks for checking. I think the new logic better accounts for things like mixing character case, symbols, and other and also duplicate chars.

@nicolas-grekas nicolas-grekas merged commit cc7cdf2 into symfony:6.3 Apr 1, 2023
@nicolas-grekas nicolas-grekas deleted the validator-entropy branch April 3, 2023 13:36
@kriskoch
Copy link

kriskoch commented Jun 20, 2023

Is it just me or does this feature seem to be tuned too harshly

I used the BitWarden random password generator to generate some random passwords and then ran it through this algorithm

%ba9J$3eTvqm -> 68 (Weak)
n54Pwq^Qq4CN -> 72 (Weak)
j*@CQ7$RHwuYPt -> 91 (Medium)
horse battery staple -> 99 (Medium)

Now out of all of those passwords, it makes no sense why horse battery staple would be stronger than the other three.
The first 3 I think anyone reasonable would consider strong/very strongm or at least medium... No way first one would be weak.

@Spomky
Copy link
Contributor

Spomky commented Jun 20, 2023

Hi,

Estimating the strength of a password is not so easy. And I must admit there is no standard way to achieve this.
With the iteration of this feature, the estimate was more tougher than this one and with the examples you shared, the results would be 43, 39, 53 and 71 respectively.
I submitted them to https://timcutting.co.uk/tools/password-entropy and the results are almost the same.
horse battery staple being safer than the other one seems to be counter intuitive, but the fact is that the strength is greatly influenced by the length

  • Number of possibilities for a 20chars passphrase (e.g. horse battery staple) of a-z+space = 27^20 = 42x10^27
  • Number of possibilities for a 14chars password (e.g. j*@CQ7$RHwuYPt) or all 97 writable chars on an ascii keyboard = 97^14 = 4x10^27

Nowadays, passwords with a length of 12 (~80 bytes entropy) or lower can be (statistically) guessed too easily and should be considered as risky. You can still adjust the threshold if needed.

Illustration source: https://www.hivesystems.io/blog/are-your-passwords-in-the-green (also, depends on the way the passwords are stored)
2023 Password Table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants