fix: mark MD5 usage as non-security (B324)#53
Merged
Conversation
Add usedforsecurity=False to hashlib.md5() calls in atomic_svc.py. These usages are for file deduplication and ability ID generation, not for cryptographic security purposes. Fixes: B324 (Use of weak MD5 hash for security) Detected by: bandit
There was a problem hiding this comment.
Pull request overview
This PR updates MD5 hashing calls in AtomicService to explicitly mark them as not used for security purposes (likely to address environments enforcing stricter crypto policies).
Changes:
- Add
usedforsecurity=Falsetohashlib.md5()when hashing attachment contents. - Add
usedforsecurity=Falsetohashlib.md5()when generating deterministic ability IDs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # to avoid collisions between payloads with the same name | ||
| with open(attachment_path, 'rb') as f: | ||
| h = hashlib.md5(f.read()).hexdigest() | ||
| h = hashlib.md5(f.read(), usedforsecurity=False).hexdigest() |
| Return True if an ability was saved. | ||
| """ | ||
| ability_id = hashlib.md5(json.dumps(test).encode()).hexdigest() | ||
| ability_id = hashlib.md5(json.dumps(test).encode(), usedforsecurity=False).hexdigest() |
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
Add
usedforsecurity=Falsetohashlib.md5()calls that are used for non-cryptographic purposes.Changes
app/atomic_svc.py:124— MD5 used for payload file deduplication (collision avoidance prefix)app/atomic_svc.py:304— MD5 used for ability ID generation from test contentNeither usage is for security/authentication. The
usedforsecurity=Falseparameter (Python 3.9+) clarifies intent and suppresses security scanner warnings.Security Reference
Test plan