Summary
JunoClaw's plugin-shell run_command helper previously wrapped agent-supplied commands in sh -c / cmd /C and forwarded the entire argument string directly to the shell parser. This allowed shell metacharacters provided by an agent to be treated as command syntax rather than data.
In deployments where agents can influence or generate commands, this behavior may enable OS command injection, letting an attacker execute arbitrary system commands under the privileges of the JunoClaw worker process.
Affected context
The vulnerability arises in JunoClaw environments that:
- Enable the plugin-shell capability for agents, and
- Allow agents (or upstream users prompting agents) to supply or influence command strings, and
- Execute those commands through run_command, which previously wrapped them in
sh -c/cmd /Cand passed them as a single unstructured string.
In such setups, any shell metacharacters present in the command text are interpreted by the system shell, potentially chaining additional commands or altering the intended behavior.
Exploit preconditions
- Attack surface: The plugin-shell run_command interface exposed inside the JunoClaw runtime (e.g., agent tools, plugins, or workflows that trigger shell execution).
- Required access: Ability to cause an agent to issue or relay commands to plugin-shell (for instance, by crafting prompts, controlling agent inputs, or operating an agent with shell access).
- Trigger point: Execution of a command via run_command that is wrapped in
sh -c/cmd /Cand passed as a single string to the shell. - Why exploitation is possible: The shell treats the supplied string as full command syntax, so metacharacters such as
;,&&,||, pipes, redirection, and subshell operators are parsed and executed instead of being handled as literal data. There is no strict separation between command and arguments, nor robust quoting/escaping, making injection feasible.
Why this happens
The core issue matches CWE-78: Improper Neutralization of Special Elements used in an OS Command, sometimes combined with CWE-77: Command Injection via Argument Injection. The run_command implementation constructed shell invocations like sh -c "<agent-string>" or cmd /C "<agent-string>", where the agent-controlled string was treated as a complete shell script fragment.
By delegating parsing to the shell, the code implicitly trusted agent-supplied text to be safe command syntax. Shell metacharacters were not neutralized or structurally separated from the intended command, so an attacker could append new commands, alter control flow, or change redirections. Conceptually, this is an insecure pattern where high-level application logic uses generic shell interpreters as a command dispatcher without enforcing a strict, argument-based API.
Potential impact
- Execution of arbitrary OS commands under the privileges of the JunoClaw process or container.
- Reading, modifying, or deleting files accessible to the runtime environment.
- Accessing secrets, API keys, or configuration files present on the host or in the container.
- Establishing outbound network connections for data exfiltration or pivoting to other services.
- Disrupting workflows by terminating processes, corrupting intermediate artifacts, or consuming system resources.
General mitigation guidance
Effective mitigation focuses on removing shell parsing from the trust boundary and treating commands as structured data rather than free-form text.
Common hardening patterns include:
- Prefer direct process execution APIs that take an argument list (e.g.,
execve-style,spawnwith an array) instead of invokingsh -c/cmd /Cwith a single string. - When a shell is truly necessary, construct a fixed, non-agent-controlled command template and pass untrusted values only as data (e.g., through environment variables or safely quoted arguments), avoiding concatenation into a script-like string.
- Apply strict allowlists for executable paths and permitted subcommands, reducing the space of what agents are allowed to run.
- Limit the privileges of the plugin-shell runtime using OS-level sandboxing, dedicated low-privilege users, and minimal filesystem and network access.
- Reduce the scope of inputs that agents can translate into shell commands, and avoid exposing raw shell access where possible.
How teams detect issues like this
Detection typically involves both code-centric and behavior-centric approaches:
- Static analysis and linting:
- Flag usages of generic shell execution APIs where untrusted or dynamically constructed strings are passed to
sh -c,bash -c, orcmd /C. - Identify concatenation or interpolation of agent- or user-controlled data into command strings.
- Enforce policies that prefer argument-based process execution functions over shell-based ones.
- Code review patterns:
- Scrutinize any plugin or tool that grants agents access to system-level commands.
- Look for places where "convenience wrappers" around shell execution might inadvertently reintroduce string-based command invocation.
- Runtime and operational signals:
- Monitor process invocation logs for suspicious patterns such as frequent use of
;,&&,||, or unexpected binaries being launched by the JunoClaw worker. - Use host or container security tooling to detect anomalous command sequences originating from JunoClaw components.
Automated code scanning tools, including SAST and security-focused linters, can be configured with rules to highlight this class of shell invocation patterns across the codebase.

