fix(security): harden terminal safety and sandbox file writes#1653
Merged
fix(security): harden terminal safety and sandbox file writes#1653
Conversation
7 tasks
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.
The poseidon skin's banner_logo had the E and I letters swapped, spelling "POSIDEON-AGENT" instead of "POSEIDON-AGENT".
52acdee to
fe4b804
Compare
2 tasks
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
Salvage of PR #1085 by @ismoilh onto current main.
1. Expanded dangerous command detection
The shell
-cflag pattern intools/approval.pyonly caughtbash -c,sh -c,zsh -c. Common variants likebash -lc(login shell + inline command) andksh -cbypassed detection entirely.Before:
r'\b(bash|sh|zsh)\s+-c\s+'After:
r'\b(bash|sh|zsh|ksh)\s+-[^\s]*c(\s+|$)'Now catches any combined flags containing
-c(-lc,-ic,-xc, etc.) for all four shells.2. HERMES_WRITE_SAFE_ROOT sandboxing
New opt-in env var that constrains all
write_file/patchoperations to a configured directory tree. Writes outside the safe root are denied even if they're not on the static deny list.Useful for gateway/messaging deployments where the agent should only touch a workspace checkout.
Tests
bash -lc, multilinebash -lc,ksh -cbash -lcin dangerous commands listFull suite: 4867 passed, 8 pre-existing failures (unrelated), 200 skipped.
Credit
Original implementation by @ismoilh (PR #1085).
Closes #1085