Repository navigation
fix(secrets): stop reporting password hashes as hardcoded credentials - #214
Merged
Merged
Conversation
A value in PHC or modular crypt format (argon2, bcrypt, SHA-crypt, PBKDF2, scrypt) is what an application stores instead of the password and does not reveal it. It is recognised by its algorithm identifier, so an incomplete hash is not reported either; plaintext values are still reported. Closes #211
Review of the hash check: an algorithm identifier followed by plaintext, such as $2y$Summer2024!, was skipped, while Werkzeug, Django, md5-crypt, apr1 and yescrypt hashes were still reported. A value is now a hash when the identifier is followed by fields of its format's shape, or stands alone as an incomplete hash. Refs #211
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #211.
hardcoded-credentialreported password hashes as hardcoded passwords: a credential-like name bound to$argon2id$...or$2b$...was judged like a plaintext value, sincelooks_like_digestonly knows hexadecimal digests and subresource-integrity hashes.Change
plugins/secrets.py:is_password_hashrecognises a password hash by the shape of its format, andSecretDetector.judgeno longer reports such a value as a credential. Formats:$1$,$5$,$6$,$7$,$y$(yescrypt),$apr1$,$argon2i|d|id$,$pbkdf2[-sha1|256|512]$,$scrypt$, whose identifier must be followed by at least two fields of the hash alphabet; bcrypt ($2a|b|x|y$) with its fixed shape;scrypt:...$salt$hexandpbkdf2:...$salt$hex;pbkdf2_sha256$...,pbkdf2_sha1$...,argon2$...,bcrypt$...,bcrypt_sha256$...,scrypt$...,md5$...,sha1$....$argon2id$, as in mitmproxy's invalid-hash test) is an incomplete hash and reveals nothing. An identifier followed by text of another shape ($2y$Summer2024!,$scrypt$MyRealPassw0rd) is a plaintext password and is still reported.$is outside the token alphabet), so nothing replaces the finding.The first version recognised the identifier alone; the review showed that it skipped plaintext values opening with an identifier and missed the Werkzeug and Django encodings, the most common in Python code. Both are addressed above.
Validation
tests/test_password_hashes.py(no existing test changed): 20 hash values of every listed format are not reported (all failed before the change); six plaintext values are still reported, including$2y$Summer2024!,$scrypt$MyRealPassw0rdand$5$hunter2-plain. The hash check stays linear on 8 MB adversarial strings.test_packaging::test_the_version_has_one_source_of_truth, comes from a stale local editable install (metadata 0.8.0 vs 0.21.0) and fails identically onmain.ruff check,ruff format --checkon the new file andmypypass.be75825, enterprise plugins atac35460,[email protected], no baseline, compared with the 87 results of the 2026-10-02 reference: exactly F050 and F051 (test_webaddons.py:37,:48) disappear, nothing else changes. 87 → 85 results,high18 → 16. Plugin digests are identical.Not covered
Docker Compose's escaped form (
$$2y$$...) is not recognised.