Summary
picoclaw versions up to and including v0.1.2 contain an OS command injection vulnerability in the ExecTool component, where shell commands are filtered using an incomplete denylist.
An attacker who can influence commands executed through ExecTool may be able to run arbitrary operating system commands on the host, bypassing the intended restrictions in guardCommand().
Affected context
This vulnerability affects deployments of picoclaw that:
- Use the ExecTool functionality implemented in
pkg/tools/shell.go - Allow user-controlled or externally supplied input to be passed to guardCommand() for shell execution
- Rely on the internal denylist-based filtering as the primary safety mechanism for validating shell commands
The risk is most pronounced in environments where ExecTool is exposed through APIs, CLIs, web handlers, or automation workflows that accept untrusted or semi-trusted input.
Exploit preconditions
- Attack surface: Any interface (CLI, HTTP API, RPC, plugin system, or automation hook) that routes user-controlled input into ExecTool/guardCommand() for shell execution.
- Required access: Ability to submit or influence command strings or command parameters that are evaluated by guardCommand().
- Trigger point: Invocation of ExecTool that leads to guardCommand() evaluating the supplied command, followed by passing the approved command to the system shell.
- Why exploitation is possible: The guardCommand() function enforces security using a small denylist of regular expressions. Because the denylist is incomplete, attackers can craft commands that evade these patterns while still invoking dangerous shell constructs, leading to unintended command execution.
Why this happens
The root cause is a classic OS command injection pattern, mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Instead of treating all external input as untrusted and avoiding direct shell composition, the ExecTool implementation attempts to "guard" commands using a limited set of denylisted regex patterns. This design assumes that dangerous commands and metacharacters can be exhaustively enumerated and blocked. In practice, shell syntax provides many alternative forms, encodings, and built-ins that bypass such filters.
By not using parameterized OS APIs, strict allowlists, or non-shell execution primitives, the code path continues to build or pass command strings directly into a shell interpreter. As soon as a bypass is found around the eight denylisted patterns, arbitrary command execution becomes possible under the privileges of the picoclaw process.
Potential impact
- Execution of arbitrary OS commands with the privileges of the picoclaw service or calling process
- Reading, modifying, or deleting local files accessible to the service account
- Lateral movement within the host or container environment by invoking system utilities or network tooling
- Extraction of sensitive configuration, credentials, or environment variables
- Interference with system availability, including process termination or resource exhaustion
- Establishment of a persistent foothold or backdoor on the affected system
General mitigation guidance
Effective mitigation focuses on eliminating direct shell injection surfaces and minimizing trust in input passed to command execution APIs:
- Prefer high-level, parameterized APIs over shell execution:
- Use language-native functions that accept arguments as structured lists rather than concatenated strings.
- Avoid invoking a general-purpose shell unless absolutely necessary.
- Replace denylist-based filtering with safer patterns:
- Use strict allowlists of permitted commands and subcommands where possible.
- Constrain arguments to known-safe values (e.g., enums, IDs, file basenames) instead of arbitrary strings.
- Constrain execution environment:
- Run picoclaw components under least-privilege service accounts with restricted filesystem and network access.
- Consider containerization or sandboxing to limit blast radius if command execution is abused.
- Harden input boundaries:
- Reduce or remove the ability for untrusted users to supply raw command strings.
- Introduce higher-level abstractions (e.g., well-defined actions or tasks) instead of generic shell execution.
- Apply defense-in-depth validation:
- Normalize and validate all inputs before they reach ExecTool, applying conservative constraints suited to each caller context.
How teams detect issues like this
Detection strategies can combine code-centric and runtime approaches:
- Static analysis and code review:
- Search for use of shell execution functions (e.g.,
os/execwithsh -c, or equivalents) that accept concatenated strings. - Flag custom "command guard" logic that relies on denylisted regular expressions or substring checks.
- Review all call sites of ExecTool and guardCommand() to identify where untrusted input can flow into command strings.
- Policy and architectural checks:
- Enforce coding standards that discourage direct shell invocation and require structured command APIs.
- Add CI rules or linters that detect shell commands built from variable input without strong validation.
- Runtime monitoring and logging:
- Enable detailed logging of commands executed via ExecTool (excluding sensitive data where necessary).
- Monitor for anomalous command patterns, such as unexpected networking tools, interpreters, or file operations.
- Integrate host or container security tools that can alert on suspicious process trees originating from the picoclaw service.

