Summary
PicoClaw up to version 0.2.4 contains a command injection flaw in the Web Launcher Management Plane, specifically exposed through the /api/gateway/restart endpoint.
A remote attacker who can reach this API may inject arbitrary system commands by manipulating request parameters, potentially gaining control over the underlying host or service.
Affected context
The vulnerability occurs in deployments of PicoClaw (versions up to 0.2.4) where the Web Launcher Management Plane is exposed, and the /api/gateway/restart endpoint is accessible over the network.
It is most relevant in environments where this management API is reachable from untrusted networks, where input from HTTP requests is passed to system-level restart logic without robust sanitization or isolation.
The specific function is not documented, but the behavior suggests that user-controlled data influences shell commands used for gateway control or restart operations.
Exploit preconditions
- Attack surface: Network-accessible HTTP(S) endpoint at
/api/gateway/restart. - Required access: Ability to send crafted requests to the Web Launcher Management Plane; authentication requirements are unknown and may vary by deployment.
- Trigger point: Invocation of the restart-related logic that constructs and executes system commands using parameters from the request.
- Why exploitation is possible: Unvalidated or improperly encoded user input is incorporated into command-line arguments or shell strings, resulting in CWE-77: Command Injection (and related CWE-74: Improper Neutralization of Special Elements in Output).
Why this happens
At the core, the implementation appears to use user-supplied data from the /api/gateway/restart API call to build shell commands or command-line arguments without sufficient neutralization of metacharacters.
This behavior aligns with CWE-77, where special characters (such as separators, operators, or redirection tokens) are not filtered or escaped before being passed to an interpreter.
If the application invokes a shell (or shell-like mechanism) to perform restart operations, any concatenated input that is not strictly validated, sanitized, or parameterized can be interpreted as additional commands.
The presence of CWE-74 suggests the problem is part of a broader pattern of improper neutralization of special elements when generating downstream outputs that are consumed by system components.
Potential impact
- Remote execution of arbitrary system commands with the privileges of the PicoClaw service or web process.
- Full compromise of the affected host, including installation of backdoors or malware.
- Unauthorized access to configuration files, credentials, or sensitive operational data.
- Disruption of services through forced restarts, crashes, or resource exhaustion.
- Lateral movement into adjacent systems reachable from the compromised host.
General mitigation guidance
Effective mitigation focuses on removing direct coupling between user input and command interpreters, and on constraining the management surface:
- Replace shell-based command construction with strict, parameterized process invocation APIs that do not invoke a shell by default.
- Restrict accepted input for management operations to a small, well-defined set of values (e.g., enumeration of allowed actions or identifiers) and reject anything outside that set.
- Apply rigorous validation and canonicalization on all request parameters used in restart or control functions, treating all external input as untrusted.
- Run the Web Launcher Management Plane and associated processes with least privilege, and isolate them via operating system or container-level sandboxing where feasible.
- Limit exposure of management APIs by enforcing network segmentation, access control, and authentication on the management plane to reduce who can interact with
/api/gateway/restart.
How teams detect issues like this
Detection usually combines code-centric review with operational monitoring:
- Static analysis: Configure rules to flag instances where user-controlled data flows into command execution APIs (e.g., shell invocation,
system-like calls, or process builders using strings) without strict validation or parameterization. - Code review: During manual reviews, pay special attention to management endpoints that trigger system-level operations (restart, deploy, configure) and look for string concatenation or interpolation used to build commands.
- Security testing: Use focused dynamic application security testing (DAST) and API fuzzing targeting
/api/gateway/restartto identify inputs that alter command behavior. - Runtime monitoring: Enable logging and alerting on unusual command execution patterns, unexpected subprocess invocations, or anomalies related to the gateway restart operations.
- Automated SAST and API security scanners can be integrated into CI/CD pipelines to consistently detect command injection sinks before deployment.

