Skip to content

fix(tools): validate timeout, reject whitespace old_string, narrow /private/var block - #76452

Merged
teknium1 merged 1 commit into
mainfrom
fix/terminal-timeout-and-fuzzy-whitespace
Aug 1, 2026
Merged

teknium1 merged 1 commit into
mainfrom
fix/terminal-timeout-and-fuzzy-whitespace

Conversation

@teknium1

@teknium1 teknium1 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Three lower-severity core-tool robustness fixes from a targeted audit, each reproduced live against current main.

1. terminal_tool didn't validate non-positive timeouts. timeout or default silently coerced 0 to the config default (0 can't mean "no timeout" here), and a negative value is truthy so it flowed into deadline = now + timeout and fired an immediate "-Ns" timeout. Now rejects timeout <= 0 with a clear message.

2. fuzzy_find_and_replace accepted a whitespace-only old_string, which matches trivially (a blank line / run of spaces) and mass-replaces under replace_all or raises an opaque ambiguity error. Now rejected alongside the empty-string check.

3. The /private/var/ sensitive-path prefix over-blocked all macOS temp-file writes. $TMPDIR, /tmp, and /var/folders realpath into /private/var/folders/… on macOS (and paths resolve through symlinks), and /private/var/tmp is a normal temp dir. Narrowed to the genuinely-sensitive subtrees (/private/var/db, /private/var/root); /etc and /private/etc stay blocked.

Validation

Before After
timeout=0 / -1 coerced to default / instant -1s kill rejected with clear error
whitespace-only old_string matches blank lines, mass-replaces rejected
macOS $TMPDIR//private/var/tmp write refused as "sensitive" allowed
/private/var/db, /private/var/root, /etc blocked still blocked
  • Sabotage-verified: all three tests fail against the pre-fix code.
  • 85 terminal/fuzzy/file tests pass; normal timeouts, legit replacements, /var+/boot+/etc blocking unaffected.

Infographic

Three core-tool robustness fixes

…rivate/var block

Three lower-severity core-tool robustness fixes from a targeted audit, each
reproduced live:

1. terminal_tool did not validate non-positive timeouts. 'timeout or default'
   silently coerced 0 to the config default (0 can't mean 'no timeout'), and a
   negative value is truthy so it flowed into 'deadline = now + timeout' and
   fired an immediate '-Ns' timeout. Reject timeout <= 0 with a clear message.

2. fuzzy_find_and_replace accepted a whitespace-only old_string, which matches
   trivially (blank line / run of spaces) and mass-replaces under replace_all
   or raises an opaque ambiguity error. Reject it alongside the empty check.

3. The '/private/var/' sensitive-path prefix over-blocked ALL macOS temp-file
   writes: , /tmp, and /var/folders realpath into /private/var/folders
   on macOS (and paths are resolved through symlinks), and /private/var/tmp is
   a normal temp dir. Narrowed to the genuinely-sensitive subtrees
   (/private/var/db, /private/var/root); /etc and /private/etc stay blocked.

All verified with sabotage-checked regression tests. 85 terminal/fuzzy/file
tests pass; normal timeouts, legit replacements, and /var + /boot + /etc
blocking are unaffected.
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 12be279

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

3 visual diffs.

inline evidence upload failed.

Failed to upload diff-1508682a2ae8-boot-ready-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-1508682a2ae8-boot-ready-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) tool/terminal Terminal execution and process management needs-decision Awaiting maintainer decision before any implementation labels Aug 1, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Related: #41285, #46412, and #64517 address macOS temporary paths with active-tempdir or root allowlists. This PR instead reduces /private/var protection to db/root subtrees, a broader policy choice rather than a redundant same-mechanism patch.

@teknium1
teknium1 merged commit 7f4d155 into main Aug 1, 2026
42 checks passed
@teknium1
teknium1 deleted the fix/terminal-timeout-and-fuzzy-whitespace branch August 1, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists tool/file File tools (read, write, patch, search) tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants