Skip to content

fix: add usedforsecurity=False to hashlib in tools/ and plugins/ (FIPS compliance) - #65570

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

fix: add usedforsecurity=False to hashlib in tools/ and plugins/ (FIPS compliance)#65570
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/hashlib-fips-tools-plugins

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Summary

Add usedforsecurity=False to hashlib.sha256/md5/sha1 calls in tools/ and plugins/ that were missing it.

Problem

Python's hashlib defaults usedforsecurity=True, which causes a ValueError crash on FIPS-compliant systems (RHEL 8+, Ubuntu FIPS mode, AWS GovCloud):

ValueError: [digital envelope routines] unsupported

Changes (18 files, 19 call sites)

run_agent.py — name sanitization + image URL cache key (2 sites)

tools/:

  • tirith_security.py — file integrity hash
  • tool_result_storage.py — result ID dedup
  • checkpoint_manager.py — path fingerprint
  • web_tools.py — URL cache key
  • approval.py — reason hash

plugins/platforms/:

  • discord/adapter.py — payload verification
  • line/adapter.py — access token fingerprint
  • feishu/adapter.py — webhook signature verification
  • whatsapp/adapter.py — file hash fingerprint

plugins/memory/:

  • honcho/oauth_flow.py — PKCE challenge
  • honcho/session.py — peer ID hash
  • honcho/client.py — ID fingerprint
  • holographic/holographic.py — word digest

plugins/other:

  • teams_pipeline/store.py — canonical hash
  • dashboard_auth/basic/__init__.py — SIG_LEN constant
  • dashboard_auth/self_hosted/__init__.py — PKCE challenge
  • dashboard_auth/nous/__init__.py — PKCE challenge

Not changed

  • hashlib.scrypt (password hashing) — does not support usedforsecurity parameter
  • hmac.new(..., hashlib.sha256) calls — hmac.new does not support the parameter in Python 3.10-3.11

Risk

None — all calls are for cache keys, fingerprints, or deduplication. No-op on non-FIPS systems.

…/ (FIPS)

hashlib.md5/sha1/sha256 default to usedforsecurity=True which crashes
on FIPS-compliant systems. Add the flag to 19 call sites across 18 files.

Note: hmac.new and hashlib.scrypt do not support usedforsecurity in
Python 3.10-3.11, so those calls are left unchanged.

Files: run_agent.py, tirith_security, tool_result_storage,
checkpoint_manager, web_tools, approval, discord, line, feishu,
whatsapp, honcho (3 files), holographic, teams_pipeline,
dashboard_auth (3 files)
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins comp/tools Tool registry, model_tools, toolsets platform/discord Discord bot adapter platform/feishu Feishu / Lark adapter platform/whatsapp WhatsApp Business adapter needs-decision Awaiting maintainer decision before any implementation sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 16, 2026

@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 pursuing FIPS compatibility. The current implementation needs a narrower security classification before it is safe to salvage.

Problems

  • plugins/platforms/feishu/adapter.py:3566-3586 verifies an inbound webhook signature, and plugins/dashboard_auth/nous/__init__.py:179-195 derives a PKCE S256 challenge. Both are security contexts, but the patch passes usedforsecurity=False, which Python documents as declaring a non-security use.
  • CPython documents SHA-256 as always present; the documented FIPS-blockable constructor is MD5. Meanwhile non-security MD5 uses remain at tools/skills_sync.py:234 and tools/skills_hub.py:1363.
  • The diff changes 18 production files without FIPS-focused regression coverage.

Suggested changes

  • Keep normal SHA-256 for signature verification, PKCE, and integrity checks.
  • Re-scope to verified non-security uses of algorithms that can be blocked, and add targeted restricted-hash tests.

Automated hermes-sweeper review.

@@ -3574,7 +3574,7 @@ def _is_webhook_signature_valid(self, headers: Any, body_bytes: bytes) -> bool:
try:

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.

This computes the value used to authenticate an inbound Feishu webhook. usedforsecurity=False declares a non-security use, so this verification path should retain the normal SHA-256 constructor.

code_verifier = _b64url_no_pad(secrets.token_bytes(64)) # ~86 chars
code_challenge = _b64url_no_pad(
hashlib.sha256(code_verifier.encode("ascii")).digest()
hashlib.sha256(code_verifier.encode("ascii"), usedforsecurity=False).digest()

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.

This is the OAuth PKCE S256 code challenge, a security protocol value. Please keep normal SHA-256 here rather than marking the hash as non-security.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 18, 2026
@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Twenty-one PRs address or reference this cluster: most annotate non-security MD5/SHA-1 constructors for FIPS compatibility, while #39049, #43937, and #54617 address WeCom constant-time signature comparison; several broader SHA-256 sweeps also modify security-sensitive contexts without establishing that those changes are required.

Related pull requests

Duplicates

#52967 is the closed v2 duplicate/superset of #52783; #73278 is the closed identical duplicate of #72370. #39049 and #43937 overlap #54617 but target the retired path; #48472 is the Skills Hub subset of #62654, #56715 is a focused subset of #52783, and #66857 overlaps the Weixin slice of #56719/#65434.

Suggested consolidation

Author action on #65570: split out only non-security hash sites whose restricted-runtime failure is demonstrated, remove Feishu signature-verification, PKCE, and other security-context SHA-256 annotations, then add targeted constructor regressions. The visible keep_open reviews support salvage rather than current-form acceptance: retain focused current-path work such as #54617, #62654, #66857, #72370, and #74632 long enough to add the requested tests, consolidate overlapping slices into the smallest tested PRs, and close the remaining open subsets as explicit duplicates only after their unique sites have been carried forward.

Cross-PR triage: Reviewed 21 pull requests and 0 issues in this complex. Diffs were read for 20 of 21 PRs (rest unavailable); Assessment working set: 112 kB of PR diffs, 28 kB of issue/PR text, 22 kB of discussion (31 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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 comp/plugins Plugin system and bundled plugins comp/tools Tool registry, model_tools, toolsets needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/discord Discord bot adapter platform/feishu Feishu / Lark adapter platform/whatsapp WhatsApp Business adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants