fix(tools): validate timeout, reject whitespace old_string, narrow /private/var block - #76452
Merged
Merged
Conversation
…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.
Contributor
૮ >ﻌ< ა ci reviewran on 12be279 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job3 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three lower-severity core-tool robustness fixes from a targeted audit, each reproduced live against current
main.1.
terminal_tooldidn't validate non-positive timeouts.timeout or defaultsilently coerced0to the config default (0 can't mean "no timeout" here), and a negative value is truthy so it flowed intodeadline = now + timeoutand fired an immediate "-Ns" timeout. Now rejectstimeout <= 0with a clear message.2.
fuzzy_find_and_replaceaccepted a whitespace-onlyold_string, which matches trivially (a blank line / run of spaces) and mass-replaces underreplace_allor 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/foldersrealpath into/private/var/folders/…on macOS (and paths resolve through symlinks), and/private/var/tmpis a normal temp dir. Narrowed to the genuinely-sensitive subtrees (/private/var/db,/private/var/root);/etcand/private/etcstay blocked.Validation
timeout=0/-1-1skillold_string$TMPDIR//private/var/tmpwrite/private/var/db,/private/var/root,/etc/var+/boot+/etcblocking unaffected.Infographic