mkopinsky / zxcvbn-php

Realistic PHP password strength estimate library based on Zxcvbn JS
MIT License
23 stars 9 forks source link

Situations where our result doesn't match upstream #4

Closed clamburger closed 6 years ago

clamburger commented 6 years ago

Use this issue for tracking situations we need to resolve before release

clamburger commented 6 years ago

These three are unfixable:

Each issue is caused by the same thing: when the upstream library sorts the matches coming out of the Matcher (before sending them into the Scorer), it only checks the i and j members of the match. If both are equal, it's arbitrary as to which one is chosen - it's an implementation detail of the browser as to which sorting algorithm is used. This means that browsers experience the same issue: for some matches, Firefox will return a different sequence to Chrome.

Luckily the fallout isn't that bad. guesses and score are still guaranteed to be the same everywhere. All we can really do is add a note to the docs.

edit: more investigation revealed that the majority of browsers perform a stable sort (the main exception being Chrome when there are more than ten elements). As such, I've used a stable sort in PHP as well so that it matches most of the time.

clamburger commented 6 years ago

I've checked the first million rows of the rockyou password list. Haven't found any further issues.