Skip to content

fix: hashlib.md5 FIPS crash in context_compressor.py - #56715

Open
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/hashlib-md5-fips-compat
Open

fix: hashlib.md5 FIPS crash in context_compressor.py#56715
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/hashlib-md5-fips-compat

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Summary

hashlib.md5() in context_compressor.py is used for content deduplication (hashing tool outputs to detect duplicates). On FIPS-enabled systems (RHEL 8/9, CentOS with FIPS mode), this raises:

ValueError: EVP_DigestInit_ex disabled for FIPS

Root Cause

Line 1229 calls hashlib.md5() without usedforsecurity=False. OpenSSL in FIPS mode rejects MD5 for any use unless explicitly marked as non-security.

Fix

Added usedforsecurity=False parameter to the hashlib.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

  • Lint passes
  • Verify on FIPS-enabled system (RHEL 8/9)

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.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jul 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: this single-site FIPS fix (agent/context_compressor.py) is one of the call-sites already covered by the open 16-site superset PR #52783, and is a sibling of #56716 (same author, codex_responses_adapter.py). Not a duplicate (subset, not the same PR) — a maintainer can pick the broad #52783 or these focused per-file fixes.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 exercise usedforsecurity=False or 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, and tools/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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andrexibiza

Copy link
Copy Markdown
Contributor

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 agent/context_compressor.py remains alive until the 2k Law is satisfied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants