Skip to content

fix(cli): prevent shell injection in quick_commands exec type - #3049

Closed
Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/quick-command-shell-injection
Closed

fix(cli): prevent shell injection in quick_commands exec type#3049
Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/quick-command-shell-injection

Conversation

@Kewe63

@Kewe63 Kewe63 commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • quick_commands of type exec in config.yaml were executed with shell=True, allowing shell metacharacters (&&, |, $(...), backticks) to be interpreted by the shell. A malicious or compromised config entry could run arbitrary commands beyond the intended one.
  • Switched to shlex.split() + shell=False so the command is parsed into an argument list and passed directly to the OS — no shell involved, metacharacters are treated as literal arguments.
  • Added a ValueError handler to surface unterminated-quote parse errors clearly.

Before:

subprocess.run(exec_cmd, shell=True, ...)

shell=True with a config-provided command string allowed shell operators
(`&&`, `|`, `$(...)` etc.) to be interpreted by the shell. A malicious
or compromised config.yaml entry could therefore run arbitrary commands.

Switch to shlex.split() + shell=False so the command is parsed into an
argument list and passed directly to execvp, with no shell involvement.
Shell metacharacters in the command string are now treated as literal
arguments rather than operators.

Also add a ValueError handler to report unterminated-quote parse errors
clearly instead of silently failing.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P1 High — major feature broken, no workaround comp/cli CLI entry point, hermes_cli/, setup wizard labels May 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of the quick_commands shell injection fix in #5381. See also closed #5125.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of the quick_commands shell injection fix in #5381. See also closed #5125.

@Kewe63 Kewe63 closed this May 2, 2026
@Kewe63
Kewe63 deleted the fix/quick-command-shell-injection branch May 2, 2026 20:14
@Kewe63
Kewe63 restored the fix/quick-command-shell-injection branch May 2, 2026 20:14
@Kewe63
Kewe63 deleted the fix/quick-command-shell-injection branch May 2, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants