Skip to content

KC-706: Updated master password grading to use zxcvbn#1999

Merged
sshrushanth-ks merged 4 commits intoupdate-master-password-zxcvbnfrom
update-master-password-zxcvbn-int
May 5, 2026
Merged

KC-706: Updated master password grading to use zxcvbn#1999
sshrushanth-ks merged 4 commits intoupdate-master-password-zxcvbnfrom
update-master-password-zxcvbn-int

Conversation

@sshrushanth-ks
Copy link
Copy Markdown
Contributor

@sshrushanth-ks sshrushanth-ks commented Apr 29, 2026

Summary

  • Added master_password_score() using zxcvbn, scoped exclusively to master password strength evaluation. The existing password_score() heuristic is preserved unchanged for vault record passwords.

Changes

  • requirements.txt — Added zxcvbn dependency.
  • keepercommander/utils.py — Added master_password_score() and is_master_pw_weak/fair/medium/strong() helpers.
  • keepercommander/commands/utils.py — reset-password now always calls master_password_score() for zxcvbn strength logging, and BreachWatch scan runs alongside it independently instead of as a mutually exclusive alternative.
  • unit-tests/test_crypto.py — Added test_master_password_score().

@sshrushanth-ks sshrushanth-ks changed the title Updated master password grading to use zxcvbn KC-706: Updated master password grading to use zxcvbn Apr 29, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 29, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedzxcvbn@​4.5.0100100100100100

View full report

@sshrushanth-ks sshrushanth-ks self-assigned this Apr 29, 2026
@sshrushanth-ks sshrushanth-ks marked this pull request as ready for review April 29, 2026 08:02
Comment thread keepercommander/utils.py Outdated
Comment thread keepercommander/utils.py Outdated
return _MASTER_PASSWORD_SCORE_MAP[result['score']]


def is_master_pw_weak(pw_score): # type: (int) -> bool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are not used anywhere, so maybe we can remove them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, removed.

Comment thread keepercommander/utils.py Outdated
def master_password_score(password): # type: (str) -> int
if not password or not isinstance(password, str):
return 0
result = _zxcvbn.zxcvbn(password)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wrap the external library call in a try except block and also use of .get instead of direct access.

    try:
        result = _zxcvbn.zxcvbn(password)
        return _MASTER_PASSWORD_SCORE_MAP.get(result.get('score'), 25)
    except Exception as e:
        logging.debug('zxcvbn scoring failed: %s', e)
        return 25

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added try/except with .get() for safer access. Falls back to 25 (Weak) on any failure.

@sshrushanth-ks sshrushanth-ks merged commit 2b87430 into update-master-password-zxcvbn May 5, 2026
4 checks passed
sshrushanth-ks added a commit that referenced this pull request May 6, 2026
* Updated master password grading to use zxcvbn

* Added zxcvbn to install_requires

* Added zxcvbn-based master password strength grading alongside BreachWatch score.

* Addressed PR review comments on master_password_score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants