Skip to content

fix(file-tools): allow macOS var folders temp writes - #32344

Open
drewTuzson wants to merge 1 commit into
NousResearch:mainfrom
drewTuzson:fix/macos-var-folders-file-write
Open

fix(file-tools): allow macOS var folders temp writes#32344
drewTuzson wants to merge 1 commit into
NousResearch:mainfrom
drewTuzson:fix/macos-var-folders-file-write

Conversation

@drewTuzson

Copy link
Copy Markdown

Summary

  • exempt macOS /private/var/folders and /var/folders temp roots from the sensitive system path guard
  • keep /private/var/db and other protected system paths blocked
  • add regression coverage for both macOS temp spellings

Verification

  • python -m pytest tests/tools/test_file_write_safety.py -q

Notes

  • untracked local .hermes/plans files were left untouched

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/file File tools (read, write, patch, search) labels May 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #31021 and #13733 — all three PRs exempt macOS /private/var/folders from the sensitive-path write guard in file_tools.py. See also closed #11983 (same fix, already closed).

bitfrost7 pushed a commit to bitfrost7/hermes-agent that referenced this pull request Jul 10, 2026
…ousResearch#32344)

Cherry-picked from PR NousResearch#32344 upstream. macOS resolves temp dirs under
/private/var/folders/ which triggers the /private/var/ sensitive path
check, blocking write_file to legitimate temp files.

Add _SENSITIVE_PATH_EXEMPT_PREFIXES to exempt /var/folders/ and
/private/var/folders/ before the main sensitive-path check.

@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 identifying the macOS temp-directory regression. The premise remains valid on current main: tools/file_tools.py:673-675 blocks all /private/var/ descendants, and write_file_tool invokes that guard at tools/file_tools.py:1678.

Problems

  • tools/file_tools.py:196 allows the exemption when either the resolved or normalized path matches. A user-writable allowlisted path can be a symlink to a protected target: the normalized spelling matches the exemption while the resolved target is sensitive. This weakens the macOS symlink protection introduced by 311dac197145e19e07df68feba2cd55d896a3cd1.
  • The exemption is not Darwin-gated, so it changes the sensitive-path guard outside macOS as well.

Suggested changes

  • Make the exemption Darwin-only and require both normalized and resolved paths to be allowlisted; fail closed when resolution fails.
  • Extend tests/tools/test_file_write_safety.py:109-115 with symlink-target, resolution-error, and platform-gate coverage.

Automated hermes-sweeper review.

Comment thread tools/file_tools.py
"Use the terminal tool with sudo if you need to modify system files."
)
for prefix in _SENSITIVE_PATH_EXEMPT_PREFIXES:
if resolved.startswith(prefix) or normalized.startswith(prefix):

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 must not be an OR check: an allowlisted-looking /private/var/folders/... symlink can resolve to a protected target while normalized still matches. Gate this to Darwin and require both resolved and normalized paths to match the allowlist, failing closed if resolution fails.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/file File tools (read, write, patch, search) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants