Problem/Motivation

The current system only uses the length to penalize short passwords but does not increase the strength calculation for longer passwords.

Length is very important to password entropy and should be included in any strength calculation. For a quick overview see http://xkcd.com/936/.

Proposed resolution

Use the length of the password to provide a score penalty below 8 characters and increase the strength score exponentially beyond that threshold.

Remaining tasks

Backport to D7.

User interface changes

Password strength meter will grow depending on length. Strength changes are now smaller after passing 6 characters.

API changes

n/a

#1497290: Check for common words in password strength indicators

Original report by pht

Drupal installer thinks that 'lMqzYK0fMjgdifcdYeN4ylMJ8bIMnFpB9nindLiz' is 'medium strength' password just because there is no punctuation in it. The password 'Aaa11.' beats it on secureness scale. Please consider password lengths in the strength meter.

Issue fork drupal-454014

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pht’s picture

Component: install system » user system

It appears that the password meter is also in user registration, etc, so i am moving this issue to user system component.

elliotttf’s picture

Status: Active » Needs review
StatusFileSize
new808 bytes

Here's an attempt at this. The strength is increased by one point for every character above 12 as long as no character is repeated within the password more than once. I'm sure there are lots of different ways to decide what kind of repetition is acceptable, so use this as a starting point if it's not exactly what you were thinking.

damien tournoud’s picture

Title: password strength meter » Include length in password strength evaluation
Version: 6.11 » 7.x-dev
Status: Needs review » Patch (to be ported)

This needs to be considered in D7 first.

elliotttf’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new928 bytes

Patch re-rolled for D7. Assuming this feature is still desirable, I've confirmed that the password strength does continue to increase after 12 characters as long as characters are not repeated more than twice in a row.

Status: Needs review » Needs work

The last submitted patch, user-454014.patch, failed testing.

elliotttf’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB

Not sure why the patch failed on the poll module... I've rerolled it anyway though with a change to prevent the strength from going above 100.

ff1’s picture

#6: user-454014.patch queued for re-testing.

scor’s picture

White Fir Design sent the following to the security team:

We just did a quick test to see how various web software rates or
restrict the use of passwords likely to be used in a dictionary attack,
as we have recently seen a campaign that has been attempting this type
of exploit (the campaign was targeting a CMS other than Drupal). We used
a list of 25 common passwords from
http://splashdata.com/splashid/worst-passwords/index.htm in the testing.
We found that Drupal 7 rated 22 of the passwords, including the password
"password", as being Fair and 3 as being Good. These ratings seem
questionable. This was already brought up two years ago,
http://drupal.org/node/693996, so you may have decided this is
acceptable but we felt it worth bringing to your attention in case it
slipped through the cracks. Corroborating the previous issue report we
found that the passwords rated as Fair are rated Low in Drupal 6 and the
passwords rated as Good are rated as Medium in Drupal 6.

The only other software that we tested that provides password strength
measurement, WordPress, rated 23 of passwords as Weak and two as Medium.
Several others have minimum requirements for passwords that would have
excluded the use all of the passwords that Drupal 7 rated as Fair.

mrf’s picture

Version: 7.x-dev » 8.x-dev
Category: bug » feature
StatusFileSize
new872 bytes

Here is a straight reroll for 8.x.

Repeating characters is also handled in #340043: Warn against repeating character classes in passwords. It might make sense to handle that separately as a penalty since it doesn't only hurt us after character 12.

I'd like to see the score grow exponentially rather than linearly to better reflect how much length helps but I don't think my brain is up to that this afternoon.

mrf’s picture

For reference here is what wordpress is currently doing for it's password checks.

Another approach that might prove useful for generally improving password checks is over at [#1497920], but I think adding good length scoring should be the top priority here.

mrf’s picture

Here is an updated version that drops the repeated letter check (note to self to work on that as a separate patch).

Also added is an exponential increase after 8 characters. The calculation isn't technically correct mainly designed to make the bar change in a way that smoothly reflects the added strength.

I've also included a small penalty for less than 8 characters, this is mainly to make a smooth increase as a user types in a longer password instead of having a big jump at the magic number 6 which happened previously.

nod_’s picture

Status: Needs review » Needs work

Looks pretty good. I guess we need the sec team looking at this.

You can replace the last two if in the patch bystrength = Math.min(strength + increase, 100);.

mrf’s picture

Status: Needs work » Needs review
StatusFileSize
new1.01 KB

Update with nod's simplification.

BrockBoland’s picture

Needs issue summary, and can probably be backported to D7

softescu’s picture

patch for D7 coming soon

softescu’s picture

StatusFileSize
new1001 bytes

attached is the patch for D7

softescu’s picture

Version: 8.x-dev » 7.x-dev
StatusFileSize
new1001 bytes

attached is the patch for D7

nod_’s picture

Version: 7.x-dev » 8.x-dev

Don't change the version until this is committed please.

softescu’s picture

I didn't know how to upload the patch for D7 and queue it for testing. Patch #17 is for D7, patch #13 is for D8.

mrf’s picture

Updated issue summary.

mrf’s picture

Issue summary: View changes

Created issue summary.

mrf’s picture

Issue summary: View changes

Updated issue summary.

nod_’s picture

StatusFileSize
new1.01 KB

reroll for 8.x

nod_’s picture

Status: Needs review » Reviewed & tested by the community

Actually that's exactly the same as #13 and that already worked.

alexpott’s picture

Category: feature » task
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This should be either a task or bug ... but fixing this is certainly not a feature...

We need tests to prove that this works.

nod_’s picture

It's a JS-only feature. And we can't test JS in core yet. Or do you mean something else?

alexpott’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs tests

@nod_ how right you are setting back to rtbc as per #22

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs manual testing
StatusFileSize
new11.56 KB

Hmm.... so I manually tested this...

Current head

lMqzYK0fMjgdifcdYeN4ylMJ8bIMnFpB9nindLiz has strength 87.5
Aaa11 has strength 52.5
Aaa11rw! has strength 100

With this patch

lMqzYK0fMjgdifcdYeN4ylMJ8bIMnFpB9nindLiz has strength 100
Aaa11 has strength 52.5
Aaa11rw! has strength 80

However for some reason the last password Aaa11rw! generated the following issue with the patch (not without)...

Screenshot_29_06_2013_07_10.png

alexpott’s picture

Issue summary: View changes

added related dicttionary checking issue

wiifm’s picture

Issue summary: View changes

It is worth noting that I have added a patch to #1497290: Check for common words in password strength indicators that will address this issue too. Perhaps this can be closed as a duplicate?

mrf’s picture

Status: Needs work » Closed (duplicate)

Confirmed that this issue is now covered by #1497290: Check for common words in password strength indicators. Closing this as a duplicate.

pancho’s picture

Version: 8.0.x-dev » 8.6.x-dev
Status: Closed (duplicate) » Needs work
Issue tags: +Needs security review, +Security, +Security improvements

No duplicate unless #1497290: Check for common words in password strength indicators is actually implemented, which remains to be seen.
Also, this one here applies to D 8.6 and may be backported, while the other one probably won't be there before D 8.8.
Back to "needs work".

pancho’s picture

Recommended minimum password length used to be 6 characters, is now 12 characters (since #2177769: User module should recommend longer password).
While this may be a slight improvement, it still doesn't tackle the following problems:

  1. There's no reward for passwords longer than the minimum recommended (now 12 characters)
  2. The function is discontinuous and only weakly monotonic. While a password length of 11 characters receives 35% penalty (no better than "fair"), adding a single character will elevate the password to 0% penalty, right into the "strong" bin.
  3. At the same time any additional character beyond 12 characters will not make any difference, no matter whether 12 or 16 or 25 characters are used.
  4. A rather short, therefore clearly not strong, but otherwise at least mediocre password of 9 characters receives a harsh penalty of 50%, putting it right into the "weak" bin, where it coexists with outright insecure passwords of 1 or 2 characters.

What we need instead is a linear strongly monotonic function that effectively conveys that there is no clear-cut "good" or "bad", but varying degrees of "better" or "worse."

pancho’s picture

Status: Needs work » Needs review
StatusFileSize
new19.29 KB
new1.62 KB

Here's a quite a bit better function:

let strength = 0;
strength += (((password.length + 1) ^ .27) - 1) * 100;

A simple exponential function, adding 1 to the length to assign a positive value to a length of 1 character, and with an exponent of .27 in order to approximate 100 points for a length of 12 characters:

Comparison

[edit: Instead of "before" and "now", please read "current" and "proposed"].

Note that even if correctly measured, entropy is not the same as password strength. Entropy may climb faster and faster, and additional entropy always does make a password stronger. In real life, however, the first bits of entropy are the most important ones, while once a fair level is reached, the necessity of adding more and more entropy decreases.

Also note that this obviously still is a pragmatic rather than a purely scientific approach. I posted some interesting reads including current scientific literature in #1824800-110: Require a (configurable) minimum password length for user accounts, but we're currently so far away from the ideal approach that we need to approximate it step by step. Which is absolutely acceptable, as all reviews are showing (almost) none of the major networks, websites, OS's or CMS's follow a state-of-the-art scientific approach. Finally, even science still has a long way to go to grasp all relevant real-life parameters of password strength in full.

More important than whether we're using advanced mathematics is the fact we're not good at measuring entropy to begin with. This mainly is because entropy highly dependent on frequently used words, combinations and replacements rather than a simply function of password length. Two random characters may have a higher entropy than a single, long word with 12 or 15 characters. That's out-of-scope here, though, and may be improved in #1497290: Check for common words in password strength indicators.

Patch might require some recalibration of penalties, strength bins and tests, but for the moment I wanted to focus on the central aspect.

pancho’s picture

StatusFileSize
new24.23 KB
new1.54 KB
new1.68 KB

This one might be another tidbit better:

    let strength = 20;
    strength += ((password.length ^ .2375) - 1) * 100;

Comparison

Again, note that the patch might require some recalibration of penalties, strength bins ("strong" should probably be no less than 100/100, "good" might start at 90/100 points, "fair" at 75/100 points) and tests, but for the moment I wanted to focus on the central aspect.

We can also shift the curve a bit downwards, if 12 characters including all (questionable) LUDS features don't have to be at 100/100 points.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

Version: 8.9.x-dev » 9.4.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests

Looks like great improvement, but it needs some testing coverage

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

prudloff made their first commit to this issue’s fork.

prudloff changed the visibility of the branch 454014-include-length-in to hidden.

prudloff’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs backport to D7 +Needs change record

This 100% feels like it'll need a CR,

Also the summary hasn't been touched in probably 10+ years lets make sure that's good to go

Thanks!