fix: add usedforsecurity=False to hashlib.sha1 in tui_gateway/server (FIPS crash) - #73278
fix: add usedforsecurity=False to hashlib.sha1 in tui_gateway/server (FIPS crash)#73278JonthanaHanh wants to merge 1 commit into
Conversation
…py (FIPS crash) The _mcp_rev_hash() function at tui_gateway/server.py:15009 uses hashlib.sha1() to compute a short revision hash for MCP config changes. On FIPS-enabled systems (RHEL 8/9, Ubuntu FIPS), this raises ValueError: EVP_DigestInit_ex disabled for FIPS, crashing the TUI gateway's MCP reload path. The function is not security-sensitive — it only computes a config fingerprint for change detection. Adding usedforsecurity=False allows it to run on FIPS systems, consistent with the existing FIPS fixes in context_compressor.py, codex_responses_adapter.py, skills_hub.py, and other modules. Fixes tui_gateway/server.py:15009 (not covered by PR NousResearch#64808 which only covered context_compressor + codex_responses_adapter hashlib calls).
Duplicate of #72370: the current diffs are identical one-line changes to the same _compute_mcp_rev SHA-1 call. |
|
Current A useful next step would be to add a regression in |
|
Closing: 1-line change without regression tests. Please reopen with test coverage if this fix is still needed. |
|
Quality Review: This PR has only 1 line change without regression tests. Per our quality standards, we recommend adding test coverage before merging. @GottZ @alt-glitch please advise. |
GottZ
left a comment
There was a problem hiding this comment.
Verdict — The one-line change is correct in isolation: _compute_mcp_rev() computes a config fingerprint for MCP reload change detection, not a security artifact, so annotating the SHA-1 call with usedforsecurity=False (available since Python 3.9) is the right FIPS-compatibility fix for this site.
Symptom — The "crashing the TUI gateway" claim in the summary is overstated. The diff context itself shows the call sits inside try: ... except Exception: return "", so on a FIPS build the ValueError is caught and _compute_mcp_rev() returns "" — the observable failure is silent loss of MCP revision tracking, not a gateway crash. @isak-ialogics already documented this above, including a concrete regression-test recipe (stub hashlib.sha1 to reject calls lacking usedforsecurity=False, assert a non-empty revision); adding that test would also resolve the test-coverage request in this thread.
Duplicate — This PR is byte-identical to your own earlier #72370: same file, same _compute_mcp_rev() call site, same one-line change, both currently open. Our repository graph links the two as duplicates at 0.97 confidence. Please carry exactly one of them forward — the natural move is to close this newer copy and land the summary correction plus the regression test on #72370.
Related PRs:
- duplicates #72370 — same author, identical diff at the same call site
- family: this PR sits in a 20-PR cluster of weak-hash annotations (
usedforsecurity=Falseat other call sites, e.g. #56715, #62654, #64808); per the PR summary this particular site was not covered by #64808, which is consistent with the current diff
This review was generated by an AI triage agent grounded in the repository graph; the claims above were checked against the live diff and thread.
…or FIPS compliance Several hashlib.md5() and hashlib.sha1() calls across the codebase lack usedforsecurity=False, causing ValueError crashes on FIPS-enabled systems (OpenSSL FIPS mode raises EVP_DigestInit_ex for security-tagged hashes). Previous PRs (NousResearch#56736, NousResearch#64808, NousResearch#73278, NousResearch#73800) fixed some sites but missed these files: - agent/context_compressor.py:2837 — md5 for content dedup hashing - agent/codex_responses_adapter.py:333 — sha1 for function call ID seed - plugins/platforms/wecom/adapter.py:1247 — md5 for media chunk upload - plugins/platforms/wecom/wecom_crypto.py:63 — sha1 for WeChat signature - plugins/platforms/sms/adapter.py:281 — sha1 passed to hmac.new() - tools/skills_sync.py:256 — md5 for directory change detection - tools/skills_hub.py:1375,1660,1887,2385,2511 — md5 for cache keys None of these are security-sensitive (content hashing, cache keys, message signatures). usedforsecurity=False is the correct annotation. For the hmac.new() call in sms/adapter.py, a lambda wrapper is used since hmac.new() accepts the digest constructor, not a call result.
Summary
The
_mcp_rev_hash()function attui_gateway/server.py:15009useshashlib.sha1()withoutusedforsecurity=Falseto compute a short revision hash for MCP config changes. On FIPS-enabled systems (RHEL 8/9, Ubuntu FIPS), this raisesValueError: EVP_DigestInit_ex disabled for FIPS, crashing the TUI gateway's MCP reload path.Root Cause
This is the same pattern as the FIPS crashes fixed in:
agent/context_compressor.py(PR fix: hashlib.md5 FIPS crash in context_compressor.py #56715)agent/codex_responses_adapter.py(PR fix: hashlib.sha1 FIPS crash in codex_responses_adapter.py #56716)tools/skills_hub.py,tools/skills_sync.py(PR fix: add usedforsecurity=False to hashlib md5/sha1 in skills_hub, skills_sync, web_server #62654)This particular site was NOT covered by PR #64808 (which covered context_compressor + codex_responses_adapter hashlib calls, and assert→runtime guards in tui_gateway/server.py but NOT this hashlib call).
Fix
One line. The function is not security-sensitive — it only computes a config fingerprint for change detection.
Test Plan
python3 -c "import ast; ast.parse(open('tui_gateway/server.py').read())"