fix(security): replace shell=True with shlex.split in config-driven execution paths#10698
Closed
shaun0927 wants to merge 2 commits into
Closed
fix(security): replace shell=True with shlex.split in config-driven execution paths#10698shaun0927 wants to merge 2 commits into
shaun0927 wants to merge 2 commits into
Conversation
…xecution paths Quick commands (cli.py) and memory plugin dependency checks (memory_setup.py) passed config-sourced strings to subprocess.run() with shell=True. Unlike the terminal tool — which has approval UI, redaction, and audit logging — these paths bypass all agent safety controls. Replace with shlex.split() to prevent shell metacharacter injection from project-level configs or third-party plugin metadata. Closes NousResearch#10692
shlex.split() raises ValueError on unmatched quotes. Catch this gracefully instead of falling through to the generic exception handler. Also adds a comment noting that commands needing shell features (pipes, redirects) can use explicit "sh -c '...'" in config.yaml.
This was referenced Apr 25, 2026
Contributor
|
Closing alongside #10692 (full reasoning there). Short version:
Thanks for the work — the reflex to swap |
This was referenced May 27, 2026
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
Replace
subprocess.run(..., shell=True)withshlex.split()in two config-driven execution paths that bypass the terminal tool's safety infrastructure.Changes
1. Quick commands (
cli.py:5530-5533)exec_cmdcomes fromconfig.yamlunderquick_commands.<name>.command. In a shared-config scenario (project-levelHERMES.mdor config checked into git), a malicious entry could inject shell metacharacters.2. Memory plugin dependency check (
hermes_cli/memory_setup.py:136-137)check_cmdcomes from pluginplugin.yamlmetadata. A compromised or malicious memory plugin could specify arbitrary shell commands.Why this matters
SECURITY.md correctly scopes unrestricted shell access via the terminal tool as by-design. The distinction is that these paths:
agent/redact.py)Files changed (2 files, +4/-2)
cli.pyshlex.split()for quick command exechermes_cli/memory_setup.pyshlex.split()for plugin dependency checkTest plan
ls,echo hello) → work as beforeecho $(whoami)) → executed literally, not interpretedwhich redis-server) → works as beforehermes memory setupflowCloses #10692