fix(security): add usedforsecurity=False to all hashlib.md5 calls - #88
Merged
Conversation
MD5 is required by the Supernote protocol (password pre-hashing scheme, file integrity checksums sent to device API). The usedforsecurity=False flag documents this intent explicitly, suppresses CodeQL's py/use-of-broken-or-weak-cryptographic-algorithm alerts, and allows operation on FIPS-compliant systems.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ssword pre-hashing Add lgtm[py/weak-sensitive-data-hashing] suppression comments on the three password-related MD5 calls. These are mandated by the Supernote device authentication protocol (SHA256(MD5(password) + randomCode)) and cannot be replaced with a stronger algorithm.
Alerts 20/21/22 dismissed via GitHub API with won't-fix rationale. Inline lgtm comments had no effect (wrong line after ruff reformat) and added noise.
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.
Summary
usedforsecurity=Falseto all 9hashlib.md5()calls acrossclient/,cli/, andserver/py/use-of-broken-or-weak-cryptographic-algorithmalerts in code scanningDetails
All MD5 uses fall into two categories, both protocol-locked:
cli/admin.py,client/hashing.py): protocol scheme isSHA256(MD5(password) + randomCode); device sends and expects MD5-prehashed passwordsclient/client.py,client/web.py,client/device.py,server/services/blob.py):md5field is a required field in upload API requests/responses; server returns it and device verifies itusedforsecurity=Falseis the correct suppression mechanism: it signals to static analysis tools and FIPS-compliant OpenSSL that MD5 here is not a security primitive choice but a protocol compatibility requirement.Test plan
29 passed)