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
Related Issues
#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.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | password_length_32.png | 24.23 KB | pancho |
| #26 | Screenshot_29_06_2013_07_10.png | 11.56 KB | alexpott |
Issue fork drupal-454014
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:
- 454014-
changes, plain diff MR !15166
- 454014-include-length-in
compare
Comments
Comment #1
pht commentedIt appears that the password meter is also in user registration, etc, so i am moving this issue to user system component.
Comment #2
elliotttf commentedHere'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.
Comment #3
damien tournoud commentedThis needs to be considered in D7 first.
Comment #4
elliotttf commentedPatch 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.
Comment #6
elliotttf commentedNot 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.
Comment #7
ff1 commented#6: user-454014.patch queued for re-testing.
Comment #8
scor commentedWhite Fir Design sent the following to the security team:
Comment #9
mrf commentedHere 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.
Comment #10
mrf commentedFor 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.
Comment #11
mrf commentedHere 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.
Comment #12
nod_Looks pretty good. I guess we need the sec team looking at this.
You can replace the last two if in the patch by
strength = Math.min(strength + increase, 100);.Comment #13
mrf commentedUpdate with nod's simplification.
Comment #14
BrockBoland commentedNeeds issue summary, and can probably be backported to D7
Comment #15
softescu commentedpatch for D7 coming soon
Comment #16
softescu commentedattached is the patch for D7
Comment #17
softescu commentedattached is the patch for D7
Comment #18
nod_Don't change the version until this is committed please.
Comment #19
softescu commentedI 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.
Comment #20
mrf commentedUpdated issue summary.
Comment #20.0
mrf commentedCreated issue summary.
Comment #20.1
mrf commentedUpdated issue summary.
Comment #21
nod_reroll for 8.x
Comment #22
nod_Actually that's exactly the same as #13 and that already worked.
Comment #23
alexpottThis should be either a task or bug ... but fixing this is certainly not a feature...
We need tests to prove that this works.
Comment #24
nod_It's a JS-only feature. And we can't test JS in core yet. Or do you mean something else?
Comment #25
alexpott@nod_ how right you are setting back to rtbc as per #22
Comment #26
alexpottHmm.... 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)...
Comment #26.0
alexpottadded related dicttionary checking issue
Comment #27
wiifmIt 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?
Comment #28
mrf commentedConfirmed that this issue is now covered by #1497290: Check for common words in password strength indicators. Closing this as a duplicate.
Comment #29
panchoNo 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".
Comment #30
panchoRecommended 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:
What we need instead is a
linearstrongly monotonic function that effectively conveys that there is no clear-cut "good" or "bad", but varying degrees of "better" or "worse."Comment #31
panchoHere's a quite a bit better function:
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:
[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.
Comment #32
panchoThis one might be another tidbit better:
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.
Comment #35
andypostLooks like great improvement, but it needs some testing coverage
Comment #43
prudloff commentedComment #44
smustgrave commentedThis 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!