Skip to content

fix: bound threat-pattern/FTS5 regex input and cover V4A Move-File edits - #56151

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1c4ecb10
Jul 1, 2026
Merged

fix: bound threat-pattern/FTS5 regex input and cover V4A Move-File edits#56151
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1c4ecb10

Conversation

@teknium1

@teknium1 teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Bounds the regex-input surface of the threat scanner and FTS5 sanitizer so adversarial input can't induce catastrophic backtracking, and extends V4A patch handling to recognize *** Move File: headers so those edits are permissioned and traversal-checked.

Salvaged from #35130 (@jnibarger01) — the safe, design-aligned subset of that PR's security pass. The multi-tenant TUI session-scoping, gateway per-requester approval matching, and delegate_task ACP-arg stripping from the original are intentionally not carried (Hermes is a personal agent, not multi-tenant; those either fight the design or remove a documented feature).

Changes

  • tools/threat_patterns.py: replace unbounded (?:\w+\s+)* filler with bounded (?:\w+\s+){0,8}, bound the .* runs in the exfil/config-mod patterns, and cap scanned input at MAX_SCAN_CHARS (64 KiB). Kills ReDoS on long near-misses; detections near the start of content preserved.
  • hermes_state.py: cap FTS5 query length (MAX_FTS5_QUERY_CHARS = 2048) and extract quoted phrases via a linear scan instead of a regex, so pathological quote runs can't backtrack.
  • acp_adapter/edit_approval.py + agent/tool_dispatch_helpers.py: recognize *** Move File: src -> dst V4A headers so patch-mode edits are permissioned/traversal-checked (previously only Update/Add/Delete), and surface an approval proposal for mode=patch V4A calls (previously replace-only).

Validation

Result
tests/tools/test_threat_patterns.py 46 passed (incl. ReDoS-bound cases)
tests/agent/test_tool_dispatch_helpers.py 28 passed (incl. Move-File target)
tests/acp/test_edit_approval.py 10 passed (incl. V4A approval)
tests/test_hermes_state.py::TestFTS5Search 54 passed (incl. FTS5 cap)

Rebased onto current main; diff is exactly the 9 salvaged files. Contributor authorship preserved via the Jace Nibarger commit.

Infographic

salvage summary

Nous Research

jnibarger01 and others added 2 commits July 1, 2026 00:43
Salvaged from PR #35130 (the safe subset of jnibarger01's security pass):

- threat_patterns.py: replace unbounded (?:\w+\s+)* filler with bounded
  {0,8} + cap scan input at MAX_SCAN_CHARS (64KiB), and bound the .*
  runs in the exfil/config-mod patterns. Kills catastrophic backtracking
  on adversarial near-misses.
- hermes_state.py: cap FTS5 query length (MAX_FTS5_QUERY_CHARS) and
  extract quoted phrases with a linear scan instead of a regex so
  pathological quote runs can't induce backtracking.
- acp_adapter/edit_approval.py + agent/tool_dispatch_helpers.py: recognize
  '*** Move File: src -> dst' V4A headers so patch-mode edits are
  permissioned/traversal-checked (previously only Update/Add/Delete), and
  surface a proposal for mode=patch V4A calls (previously replace-only).

Tests: +ReDoS-bound + FTS5-cap + Move-File-target + V4A-approval cases.
@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 comp/acp Agent Communication Protocol adapter P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Salvage of #35130 by @jnibarger01 (the safe, design-aligned subset) — related, not a duplicate. The multi-tenant session-scoping / per-requester approval / delegate ACP-arg-stripping from the original are intentionally not carried. Also related to #41754 (omnibus V4A/ACP security pass) and #44473 (dangerous-command ReDoS bound).

@teknium1
teknium1 merged commit cf427cc into main Jul 1, 2026
30 of 31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-1c4ecb10 branch July 1, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/acp Agent Communication Protocol adapter comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants