Skip to content

fix(approval): extend sensitive write target to cover shell RC and credential files#19282

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-c5c32519
May 3, 2026
Merged

fix(approval): extend sensitive write target to cover shell RC and credential files#19282
teknium1 merged 1 commit into
mainfrom
hermes/hermes-c5c32519

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented May 3, 2026

Salvage of #19240 by @JasonOA888 onto current main. Closes the terminal-vs-write_file inconsistency where echo >> ~/.bashrc, tee -a ~/.netrc, etc. bypassed the approval gate even though write_file blocks those exact paths via file_safety.py.

Changes

  • tools/approval.py: add _SHELL_RC_FILES and _CREDENTIAL_FILES alternatives to _SENSITIVE_WRITE_TARGET (+11/-1)

Validation

  • tests/tools/test_approval.py: 132/132 pass
  • E2E: 8 attack vectors (~/.bashrc, ~/.zshrc, ~/.profile, ~/.bash_profile, ~/.netrc, ~/.pgpass, ~/.npmrc, ~/.pypirc) now trigger approval; 3 normal writes (/tmp/, ~/regular.txt, ~/notes/) still pass through.

Closes #19240. Authorship preserved via cherry-pick.

…edential files

Terminal commands can write to shell RC files (~/.bashrc, ~/.zshrc,
~/.profile) and credential files (~/.netrc, ~/.pgpass, ~/.npmrc,
~/.pypirc) via redirection or tee without triggering approval, even
though write_file already blocks these paths in file_safety.py.

This creates an inconsistency: write_file protects these paths but
terminal shell redirections bypass the same protection. An agent
prompted via indirect injection could install persistent backdoors
(e.g. PATH manipulation, alias overrides) or write credential entries
without user approval.

Extend _SENSITIVE_WRITE_TARGET with two new regex groups matching the
same paths that file_safety.py's WRITE_DENIED_PATHS already covers:
  _SHELL_RC_FILES  — ~/.bashrc, ~/.zshrc, ~/.profile, ~/.bash_profile,
                     ~/.zprofile
  _CREDENTIAL_FILES — ~/.netrc, ~/.pgpass, ~/.npmrc, ~/.pypirc

All 130 existing tests pass.
@teknium1 teknium1 merged commit 69dd0f7 into main May 3, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-c5c32519 branch May 3, 2026 15:49
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P1 High — major feature broken, no workaround comp/tools Tool registry, model_tools, toolsets tool/terminal Terminal execution and process management labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P1 High — major feature broken, no workaround tool/terminal Terminal execution and process management type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants