fix(security): harden terminal safety and sandbox file writes#1085
Closed
ismoilh wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(security): harden terminal safety and sandbox file writes#1085ismoilh wants to merge 1 commit intoNousResearch:mainfrom
ismoilh wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Contributor
Author
|
Hi @teknium1 |
teknium1
pushed a commit
that referenced
this pull request
Mar 17, 2026
Two security improvements: 1. Dangerous command detection: expand shell -c pattern to catch combined flags (bash -lc, bash -ic, ksh -c) that were previously undetected. Pattern changed from matching only 'bash -c' to matching any shell invocation with -c anywhere in the flags. 2. File write sandboxing: add HERMES_WRITE_SAFE_ROOT env var that constrains all write_file/patch operations to a configured directory tree. Opt-in — when unset, behavior is unchanged. Useful for gateway/messaging deployments that should only touch a workspace. Based on PR #1085 by ismoilh.
Contributor
|
Merged via PR #1653. Both changes (expanded shell -c detection and HERMES_WRITE_SAFE_ROOT sandboxing) were salvaged onto current main with authorship preserved and additional tests. Thanks for the security contribution! |
teknium1
pushed a commit
that referenced
this pull request
Mar 17, 2026
Two security improvements: 1. Dangerous command detection: expand shell -c pattern to catch combined flags (bash -lc, bash -ic, ksh -c) that were previously undetected. Pattern changed from matching only 'bash -c' to matching any shell invocation with -c anywhere in the flags. 2. File write sandboxing: add HERMES_WRITE_SAFE_ROOT env var that constrains all write_file/patch operations to a configured directory tree. Opt-in — when unset, behavior is unchanged. Useful for gateway/messaging deployments that should only touch a workspace. Based on PR #1085 by ismoilh.
teknium1
added a commit
that referenced
this pull request
Mar 17, 2026
* fix(security): harden terminal safety and sandbox file writes Two security improvements: 1. Dangerous command detection: expand shell -c pattern to catch combined flags (bash -lc, bash -ic, ksh -c) that were previously undetected. Pattern changed from matching only 'bash -c' to matching any shell invocation with -c anywhere in the flags. 2. File write sandboxing: add HERMES_WRITE_SAFE_ROOT env var that constrains all write_file/patch operations to a configured directory tree. Opt-in — when unset, behavior is unchanged. Useful for gateway/messaging deployments that should only touch a workspace. Based on PR #1085 by ismoilh. * fix: correct "POSIDEON" typo to "POSEIDON" in banner ASCII art The poseidon skin's banner_logo had the E and I letters swapped, spelling "POSIDEON-AGENT" instead of "POSEIDON-AGENT". --------- Co-authored-by: ismoilh <ismoilh@users.noreply.github.com> Co-authored-by: unmodeled-tyler <unmodeled.tyler@proton.me>
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.
What does this PR do?
This PR hardens Hermes Agent’s terminal and filesystem safety in two ways:
bash|sh|zsh|ksh -...cinvocations (includingbash -lc) as dangerous inline shell execution, closing common RCE patterns that were not previously caught explicitly.HERMES_WRITE_SAFE_ROOTguard that constrains allwrite_file/patchoperations to a configured directory tree, denying writes outside that subtree even if they are not on the static deny list. This gives operators a simple way to sandbox file writes to a workspace checkout, especially in gateway/messaging deployments.This approach builds on the existing approval and write‑deny mechanisms, keeps behavior backwards‑compatible by default (safe root is opt‑in), and adds tests to prevent regressions.
Related Issue
Fixes #
Type of Change
Changes Made
tools/approval.pybash|sh|zsh|ksh -[... ]cinvocation (includingbash -lc) as “shell command via -c/-lc flag”.tools/file_operations.py_get_safe_write_root()helper that resolvesHERMES_WRITE_SAFE_ROOT._is_write_denied()to:HERMES_WRITE_SAFE_ROOTis set, deny any write/patch whose resolved path is outside the configured safe root subtree.tests/tools/test_approval.pybash -lc 'echo pwned'being detected as dangerous.bash -lccommand still being caught by the detector.tests/tools/test_yolo_mode.pybash -lc 'echo pwned'in the list of dangerous commands, ensuringHERMES_YOLO_MODEconsistently bypasses all dangerous patterns (including the new one) as designed.tests/tools/test_file_write_safety.py(new)HERMES_WRITE_SAFE_ROOTis set, writes inside the safe root are allowed and writes outside are denied.HERMES_WRITE_SAFE_ROOTbehaves as “feature disabled”.How to Test
Run targeted tests (after activating your virtualenv):
pytest tests/tools/test_approval.py tests/tools/test_yolo_mode.py tests/tools/test_file_write_safety.py -q