fix: add usedforsecurity=False to MD5 hash for Python 3.13/OpenSSL 3+ compatibility#530
Merged
willmurphyscode merged 6 commits intoanchore:mainfrom Jan 27, 2026
Merged
Conversation
- Code currently uses timestamp.isoformat(), which >= py-3.11 supports rfc3319 designations with stdlib - This removes the unused import since the project already pins to >=3.11, < 3.14 - All tests currently pass with this change Signed-off-by: James Gardner <james.gardner@chainguard.dev>
… compatibility Fixes UnsupportedDigestmodError when running on Python 3.13 with newer OpenSSL versions that have MD5 disabled by default for security. The MD5 hash in Match.__post_init__ is used solely for generating content-based match IDs for comparison purposes, not for cryptographic security. Adding usedforsecurity=False allows MD5 to work even when disabled in OpenSSL's security policy. This parameter was added in Python 3.9 specifically for non-security use cases like checksums and content hashing. Signed-off-by: James Gardner <james.gardner@chainguard.dev>
… compatibility Fixes UnsupportedDigestmodError when running on Python 3.13 with newer OpenSSL versions that have MD5 disabled by default for security. The MD5 hash in Match.__post_init__ is used solely for generating content-based match IDs for comparison purposes, not for cryptographic security. Adding usedforsecurity=False allows MD5 to work even when disabled in OpenSSL's security policy. This parameter was added in Python 3.9 specifically for non-security use cases like checksums and content hashing. Also adds a regression test to ensure Match objects can be created without raising UnsupportedDigestmodError on systems with strict OpenSSL configurations. Removed the now-unnecessary noqa: S324 comment since modern bandit versions recognize the usedforsecurity parameter. Signed-off-by: James Gardner <james.gardner@chainguard.dev>
jamestexas
commented
Jan 20, 2026
| assert expected == le.effective_year(by_cve=year_from_cve_only) | ||
|
|
||
|
|
||
| def test_match_md5_hash_with_openssl3(): |
Contributor
Author
There was a problem hiding this comment.
We're testing the regression (that Match objects can be created without errors), not the MD5 implementation itself here.
willmurphyscode
approved these changes
Jan 27, 2026
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.
Fixes
UnsupportedDigestmodErrorwhen running on Python 3.13 with OpenSSL 3+, which disables MD5 by default.The MD5 hash is only used for generating content-based match IDs (not cryptography), so adding
usedforsecurity=Falseis the correct fix. This parameter was added in Python 3.9 for exactly this use case.Also adds a regression test and removes the now-unnecessary
# noqa: S324comment.Example error:
Example Error