fix(security): Security Hardening - Remediate Shell Injection Vulnerabilities - #4994
Closed
Xowiek wants to merge 1 commit into
Closed
fix(security): Security Hardening - Remediate Shell Injection Vulnerabilities#4994Xowiek wants to merge 1 commit into
Xowiek wants to merge 1 commit into
Conversation
…ecure docker cleanup
Contributor
|
This is now fixed via PR #5629 (merged), which sanitizes workdir with tilde-aware shlex.quote + an allowlist validator. Thanks for flagging the vulnerability! |
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.
Description
This pull request addresses two critical security vulnerabilities in the Hermes Agent related to
subprocess.Popenandsubprocess.runexecutions withshell=True. Usingshell=Trueexposes the agent to arbitrary shell injection attacks, violating the Hermes Agent Contribution Guide's strict security policies.Remediation Details
1. Docker Cleanup Shell Injection (
tools/environments/docker.py)cleanupmethod for docker containers formerly scheduled background removal usingsubprocess.Popen(..., shell=True)with an unescapedself._container_id. Although currently generated securely via UUID, any future refactoring could allow untrusted inputs, resulting in severe command execution vulnerabilities.subprocess.runwith list arguments (shell=False).2. Local STT Shell Injection (
tools/transcription_tools.py)_transcribe_local_commandrelied onshlex.quotepaired withsubprocess.run(..., shell=True). This creates vulnerabilities on Windows sincecmd.exedoes not respect POSIX single-quotes. Additionally, any metacharacters bypassingshlex.quoteinHERMES_LOCAL_STT_COMMANDcould lead to full RCE.shell=Truestring formatting withshlex.split. Format strings are safely populated securely within the subprocess argument list natively without invoking a subshell (shell=False), effectively neutralizing injection vectors while retaining argument templating functionality.Validation
shlex.splitnatively.threading.Thread.shell=Truewithout breaking multi-platform dependencies (Posix vs Windows).Code Base Compliance
_HAS_FASTER_WHISPERfallback checks.