Skip to content

fix(security): apply file safety rules to Copilot ACP fs handlers#13391

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-a4af2bcc
Apr 21, 2026
Merged

fix(security): apply file safety rules to Copilot ACP fs handlers#13391
teknium1 merged 3 commits into
mainfrom
hermes/hermes-a4af2bcc

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

ACP fs handlers now enforce the same file-safety rules as Hermes's own file tools: permission requests default-deny, reads of internal hub cache are blocked and secrets redacted, writes hit the protected-path denylist + HERMES_WRITE_SAFE_ROOT.

Salvaged from #2195 by @ifrederico — commit authorship preserved via rebase-merge.

Changes

  • agent/file_safety.py (new): shared helpers is_write_denied, get_read_block_error, build_write_denied_paths/prefixes, get_safe_write_root. Profile-aware (get_hermes_home() for .env + hub cache).
  • agent/copilot_acp_client.py: session/request_permission now returns cancelled instead of allow_once; fs/read_text_file gates on get_read_block_error() and runs redact_sensitive_text() on content; fs/write_text_file gates on is_write_denied().
  • tools/file_operations.py, tools/file_tools.py: delegate to the shared module; all existing entries (.docker, .azure, .config/gh, profile-aware .env) preserved.
  • tests/agent/test_copilot_acp_client.py: 5 regression tests.
  • scripts/release.py: AUTHOR_MAP entry for @ifrederico.

Validation

Result
tests/agent/test_copilot_acp_client.py 5/5 pass
tests/tools/test_file_operations.py + test_file_tools.py 69/69 pass
E2E (isolated HERMES_HOME, real handler) permission denied • hub cache read blocked • secrets redacted • writes to ~/.ssh/id_rsa and ~/.hermes/.env denied • normal writes succeed

Closes #2195.

ifrederico and others added 3 commits April 21, 2026 00:35
file_safety now uses profile-aware get_hermes_home(), so the test
fixture must override HERMES_HOME too — otherwise it resolves to the
conftest's isolated tempdir and the hub-cache path doesn't match.
@teknium1 teknium1 merged commit 7166855 into main Apr 21, 2026
6 of 7 checks passed
@teknium1 teknium1 deleted the hermes/hermes-a4af2bcc branch April 21, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants