Summary
Network-AI's agent sandbox uses a command allowlist that glob-matches full shell command strings, but then executes them via /bin/sh -c, allowing shell metacharacters to bypass intended restrictions.
If an attacker controls an agent's command string and any broad pattern like git *, npm *, or node * is allowed, they can append additional shell commands and achieve arbitrary command execution in the orchestrator environment.
Affected context
This vulnerability arises in Network-AI deployments where:
- The
ShellExecutorruns commands through/bin/sh -c - The sandbox allowlist (
SandboxPolicy.isCommandAllowed) uses glob patterns over the entire command string - Broad patterns such as
git *,npm *,node *, or similar are present to allow scoped tool usage
In such setups, a compromised or malicious agent that can propose shell commands gains a path to escape intended sandbox boundaries.
Exploit preconditions
- Attack surface: Agent command execution interface within Network-AI
- Required access: Ability for an adversary to influence or control the shell command string sent to
ShellExecutor(e.g., compromised agent, malicious tool, or untrusted workflow definition) - Trigger point: Execution of an allowed command pattern, such as
git *, which is passed to/bin/sh -cwithout strict tokenization - Why exploitation is possible: The allowlist checks only a glob match on the full string, while
/bin/sh -cinterprets shell metacharacters (;,&,|, etc.), so a seemingly limited command likegit status; evilstill matchesgit *yet executes additional attacker-supplied commands.
Why this happens
The core issue is an overly permissive and incorrectly layered command validation strategy.
Instead of validating discrete executable paths and arguments, the sandbox applies glob patterns to the entire command string and then delegates interpretation to a shell (/bin/sh -c), which expands metacharacters and composes pipelines.
This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because shell metacharacters are not rejected or isolated before execution, allowing injection of additional commands beyond the intended allowed tool call.
Potential impact
- Compromise of the Network-AI orchestrator host via arbitrary command execution
- Exfiltration or destruction of data accessible to the orchestrator process
- Installation of backdoors or persistence mechanisms on the underlying system
- Abuse of CI/CD or automation environments for supply-chain attacks
- Lateral movement to other services reachable from the orchestrator environment
General mitigation guidance
Effective mitigation focuses on removing shell interpretation from the command path and tightening command validation semantics.
Pattern-based strategies include:
- Executing commands via direct process spawning with explicit executable and argument arrays, avoiding
/bin/sh -cor equivalent shells - Introducing a quote-aware tokenizer that separates program names and arguments before any allowlist evaluation
- Enforcing allowlists on normalized command tokens (e.g., specific binaries and whitelisted argument patterns) rather than on raw strings
- Rejecting unquoted shell metacharacters (
;,&,|,$, backticks,(,),<,>,{,}, and newlines) at the sandbox boundary - Reducing trust in agents by limiting which tools they can invoke and aligning privileges with least-privilege principles
- Avoiding broad wildcard rules such as
node *ornpm *and preferring narrowly scoped, task-specific allowlist entries
How teams detect issues like this
Detection can rely on both static and runtime signals.
Common approaches include:
- Static analysis rules that flag use of
/bin/sh -cor similar APIs when combined with dynamic input from agents or workflows - Code review checklists that require commands to be built from structured argv arrays and prohibit raw string shells in sandboxed contexts
- Configuration reviews that highlight overly broad allowlist entries (e.g.,
*,git *,npm *,node *) and require justification - Logging and monitoring of executed commands, with alerts on suspicious shell metacharacters or multi-command sequences originating from agents
- Incorporation of automated security scanning tools in CI pipelines to enforce policies on process execution and sandbox enforcement code

