Skip to content

[INFRA-1157] fix(security): bound password input scored by zxcvbn - #10043

Merged
sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1157-bound-zxcvbn-input
Oct 17, 2026
Merged

sriramveeraghanta merged 2 commits into
previewfrom
fix/infra-1157-bound-zxcvbn-input

Conversation

@dheeru0198

@dheeru0198 dheeru0198 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Description

Password strength checks passed the full submitted password to zxcvbn, with no length bound.

  • New helper is_password_strong() in plane/authentication/utils/password.py scores the first and the last 128 characters (ZXCVBN_MAX_LENGTH) and treats the password as strong if either window has score >= 3, the threshold every caller already used.
  • Every zxcvbn caller now goes through it: Adapter.validate_password (app and space sign-up), change/set password (views/common.py), app and space password reset, instance admin sign-up, and the reset_password management command.
  • A unit test checks that no module under plane/ other than this helper imports zxcvbn.
  • Each caller keeps its existing error code and response. The full password is still hashed and stored, so long passwords keep working.

Behaviour change: none for passwords up to 128 characters. Longer passwords are judged on their first and last 128 characters and accepted if either is strong. The UI has no maximum length, so nothing is rejected for length.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • Sign up (app and space) with a strong 320-character password: zxcvbn receives at most 128 characters, the user is created and can sign in with the full password.
  • Sign up with "password" * 16 + "Xk9#mQ2$vL7@pR4!" (weak start, strong end): accepted.
  • Sign up with a weak password (password): still rejected with PASSWORD_TOO_WEAK.
  • plane/tests/contract/app/test_password_strength_input_bound_app.py, test_authentication.py, smoke/test_auth_smoke.py: 39 passed. The new bound test fails without the fix (assert 320 <= 128).
  • After the review change: the contract file and unit/utils/test_zxcvbn_imports.py pass (5); the strong-tail case fails with prefix-only scoring.

References

  • INFRA-1157

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Security
    • Password strength checks are consistent across signup, password changes, resets, and admin password flows.
    • Strength scoring evaluates up to 128 characters from the beginning and end of a password. Long passwords are stored and verified in full.
    • Weak passwords continue to be rejected with the existing error handling.
  • Tests
    • Added coverage for long-password handling, signup rejection of weak passwords, and centralized password-strength validation.

Add is_password_strong() helper that scores only the first 128 characters,
and route every zxcvbn caller (sign-up, password set/change/reset, instance
admin sign-up, reset_password command) through it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:08

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@makeplane

makeplane Bot commented Oct 16, 2026

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b834890-b0eb-4818-9f82-29903ea675fa
📥 Commits

Reviewing files that changed from the base of the PR and between 6340b0d and 5a797f9.

📒 Files selected for processing: 3
  • apps/api/plane/authentication/utils/password.py
  • apps/api/plane/tests/contract/app/test_password_strength_input_bound_app.py
  • apps/api/plane/tests/unit/utils/test_zxcvbn_imports.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Password-strength evaluation now uses a shared helper that scores the first and last 128-character windows. Authentication, signup, and password reset paths use this helper. Tests cover bounded scoring, long-password verification, weak-password rejection, and zxcvbn import usage.

Changes: Password strength validation

Layer / File(s) Summary
Add bounded strength validator
apps/api/plane/authentication/utils/password.py
Adds a 128-character limit and a helper that returns whether either zxcvbn-scored window meets the minimum score of 3.
Use shared validator across password flows
apps/api/plane/authentication/adapter/base.py, apps/api/plane/authentication/views/*/password_management.py, apps/api/plane/authentication/views/common.py, apps/api/plane/db/management/commands/reset_password.py, apps/api/plane/license/api/views/admin.py, apps/api/plane/tests/contract/app/test_password_strength_input_bound_app.py, apps/api/plane/tests/unit/utils/test_zxcvbn_imports.py
Replaces direct zxcvbn checks with the shared helper while preserving existing rejection responses. Contract tests cover bounded scoring, long-password verification, and weak-password signup rejection. A unit test checks zxcvbn imports outside the tests directory.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5a797

No merge-blocking issue is identified; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the security fix: limiting the password input scored by zxcvbn. It is concise and directly related to the main change.
Description check Passed The description is complete and follows the repository template. It explains the change, marks the change type, documents test scenarios, and references INFRA-1157. Screenshots are not applicable beca…
Full details: Description check

Explanation

The description is complete and follows the repository template. It explains the change, marks the change type, documents test scenarios, and references INFRA-1157. Screenshots are not applicable because this is a backend security fix.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Score the first and the last ZXCVBN_MAX_LENGTH characters and accept the password
if either window is strong; add a unit test that only the password helper imports zxcvbn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@lovelace3 lovelace3 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No blocking findings.

Verified:

  • test_password_strength_input_bound_app.py and unit/utils/test_zxcvbn_imports.py: 5 passed. test_authentication.py and smoke/test_auth_smoke.py: 36 passed.
  • Falsification: with the six callers reverted to the merge-base (helper kept), both test_sign_up_scores_bounded_password_windows cases and the import guard fail. With the helper changed to score the prefix only, test_sign_up_accepts_long_password_with_strong_tail fails.
  • Cost is bounded. Local zxcvbn timings: 128 chars took 30–62 ms across repeated, digit, dictionary, date and random inputs, against 9–40 s at 1000 chars. is_password_strong() on 100k-character inputs of each shape took 30–58 ms.
  • Coverage: the import-guard test is what keeps the reset, change/set-password, instance admin sign-up and reset_password paths behind the helper, because only sign-up is exercised end to end. That's adequate since every path calls the same function. The full password is still hashed, and check_password against the 320-character value passes.

@sriramveeraghanta
sriramveeraghanta merged commit 13011ba into preview Oct 17, 2026
16 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1157-bound-zxcvbn-input branch October 17, 2026 10:39
sriramveeraghanta pushed a commit that referenced this pull request Oct 22, 2026
…0043)

* [INFRA-1157] fix(security): bound password input scored by zxcvbn

Add is_password_strong() helper that scores only the first 128 characters,
and route every zxcvbn caller (sign-up, password set/change/reset, instance
admin sign-up, reset_password command) through it.

* [INFRA-1157] fix: address review

Score the first and the last ZXCVBN_MAX_LENGTH characters and accept the password
if either window is strong; add a unit test that only the password helper imports zxcvbn.
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.

4 participants