fix: hashlib.md5 FIPS crash in context_compressor.py - #56715
Conversation
hashlib.md5() in context_compressor.py is used solely for content deduplication (non-security). On FIPS-enabled systems (RHEL 8/9, CentOS with FIPS mode), calling hashlib.md5() without usedforsecurity=False raises ValueError: EVP_DigestInit_ex disabled for FIPS. Adding usedforsecurity=False signals to OpenSSL that this hash is not used for security purposes, allowing it to work on FIPS systems.
Related: this single-site FIPS fix ( |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused compatibility fix. Current main still contains the exact unflagged deduplication call at agent/context_compressor.py:1553, where _prune_old_tool_results hashes long string tool outputs.
Problems
- There is no regression test for the new constructor argument. Existing deduplication coverage begins at
tests/agent/test_context_compressor.py:2636, but does not exerciseusedforsecurity=Falseor FIPS-compatible construction. - This is necessarily a narrow slice: current main also has unflagged MD5 calls in
agent/codex_responses_adapter.py:236,tools/skills_sync.py:234, andtools/skills_hub.py:1362. The member discussion appropriately links open #52783 as a broader audited superset.
Suggested changes
- Add a focused mocked-constructor regression test for this call while preserving duplicate-result behavior.
- Either keep the scope explicitly complementary to #52783 or consolidate the audited non-security call sites there.
Automated hermes-sweeper review.
| if len(content) < 200: | ||
| continue | ||
| h = hashlib.md5(content.encode("utf-8", errors="replace")).hexdigest()[:12] | ||
| h = hashlib.md5(content.encode("utf-8", errors="replace"), usedforsecurity=False).hexdigest()[:12] |
There was a problem hiding this comment.
Please add a focused regression test that invokes this deduplication path and asserts hashlib.md5 receives usedforsecurity=False; existing compressor tests cover pruning behavior but not this FIPS-compatibility contract.
|
Interlock completion for the context-compressor shard campaign:
The full related set is explicitly recorded in #81074, including the prior compressor shards, same-surface colliders/fixers, and their referenced issue nodes. The residual |
Summary
hashlib.md5()incontext_compressor.pyis used for content deduplication (hashing tool outputs to detect duplicates). On FIPS-enabled systems (RHEL 8/9, CentOS with FIPS mode), this raises:Root Cause
Line 1229 calls
hashlib.md5()withoutusedforsecurity=False. OpenSSL in FIPS mode rejects MD5 for any use unless explicitly marked as non-security.Fix
Added
usedforsecurity=Falseparameter to thehashlib.md5()call. This hash is used solely for content deduplication — no security implications.Changes
agent/context_compressor.py:hashlib.md5(...)→hashlib.md5(..., usedforsecurity=False)Test Plan