Skip to content

fix(security): add usedforsecurity=False to all hashlib.md5 calls - #88

Merged
ddulic merged 3 commits into
mainfrom
fix/md5-usedforsecurity-false
Apr 13, 2026
Merged

fix(security): add usedforsecurity=False to all hashlib.md5 calls#88
ddulic merged 3 commits into
mainfrom
fix/md5-usedforsecurity-false

Conversation

@ddulic

@ddulic ddulic commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds usedforsecurity=False to all 9 hashlib.md5() calls across client/, cli/, and server/
  • MD5 is mandated by the Supernote protocol and cannot be replaced — the flag explicitly documents this intent
  • Resolves all 7 open CodeQL py/use-of-broken-or-weak-cryptographic-algorithm alerts in code scanning

Details

All MD5 uses fall into two categories, both protocol-locked:

  • Password pre-hashing (cli/admin.py, client/hashing.py): protocol scheme is SHA256(MD5(password) + randomCode); device sends and expects MD5-prehashed passwords
  • File integrity checksums (client/client.py, client/web.py, client/device.py, server/services/blob.py): md5 field is a required field in upload API requests/responses; server returns it and device verifies it

usedforsecurity=False is 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

  • All existing tests pass (29 passed)
  • Lint clean (ruff, mypy, codespell)

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.
Comment thread supernote/cli/admin.py Fixed
Comment thread supernote/cli/admin.py Fixed
Comment thread supernote/client/hashing.py Fixed
@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

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.
Comment thread supernote/cli/admin.py Fixed
Comment thread supernote/cli/admin.py Fixed
Comment thread supernote/client/hashing.py Fixed
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.
@ddulic
ddulic merged commit 10287c5 into main Apr 13, 2026
8 checks passed
@ddulic
ddulic deleted the fix/md5-usedforsecurity-false branch April 13, 2026 15:06
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.

2 participants