[API] Hash bcrypt passwords without passlib and drop the bcrypt pin #11249
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 359 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.352
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #11249"
general
weight: 0.35
ska2704
<!-- Describe the changes in this PR -->
Fixes #11203.
bcrypt was pinned to 4.0.1 in #7390 because passlib's bcrypt backend breaks on bcrypt 5.0: its startup self-test hashes a secret longer than 72 bytes, which bcrypt 5 now rejects with
ValueError. On 4.1 to 4.3 it works but logs a traceback, since it reads the removedbcrypt.__about__. conda-forge has no 4.0.1 builds for Python 3.13+, so current skypilot can't be installed there.This PR:
$2a$/$2b$/$2y$hashes with thebcryptpackage directly (legacy$2$hashes are mapped to$2a$the way passlib did), and keeps passlib only for the htpasswd schemes (apr_md5_crypt,ldap_sha1, ...). Those are still needed: the deploy docs buildSKYPILOT_INITIAL_BASIC_AUTHwithhtpasswd -nb, which gives an apr1 hash.bcrypt>=4.0.1and switches the dashboard e2e script off passlib's bcrypt.crypt_ctxkeeps the samehash/verify/identifymethods, so call sites are unchanged. Once this is released, the pin in the conda-forge feedstock recipe can be dropped too.<!-- Describe the tests ran -->
<!-- Unit tests (tests/test_*.py) are part of GitHub CI; below are tests that launch on the cloud. -->
Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)<!-- CI commands (/-prefixed) can only be triggered by repo members -->
TestCryptContextintests/unit_tests/test_sky/server/test_common_auth.pycovers a bcrypt round trip, a long-password hash and a$2$hash made with passlib + bcrypt 4.0.1, and realhtpasswd -nbB/-nb/-nbsoutput. On master with bcrypt 5.0.0 the three bcrypt cases fail with theValueErrorabove.pytest tests/unit_tests/test_sky/users tests/unit_tests/test_sky/server/{test_common_auth,test_server,test_common,test_metrics,test_auth_db_deadline}.py: 671 passed with bcrypt 5.0.0 and 4.0.1 (670 on 4.3.0 before the$2$commit) (Python 3.11). On master with bcrypt 5.0.0, 11 tests intest_sky/users/test_server.pyfail.BasicAuthMiddlewareagainst a real user DB with bcrypt 5.0.0: the apr1 admin user and a bcrypt user with an 80-byte password both get in, while wrong passwords and the 71-byte prefix get 401.mypy $(cat tests/mypy_files.txt)are clean.