Summary
A high-severity OS command injection vulnerability in the PentestAgent MCP HTTP Server allows attacker-controlled input to reach the run_task function and be interpreted by the operating system. Because the affected server is remotely accessible, an attacker may execute commands with the privileges of the service when crafted task data reaches the vulnerable execution path.
Affected context
The vulnerability occurs in the MCP HTTP Server component of GH05TCREW PentestAgent, specifically in the run_task function within interface/main.py. Risk is present when the server accepts remotely supplied task parameters and passes insufficiently constrained values into an operating-system command execution path. Actual exposure depends on network reachability, authentication, authorization, and the permissions of the service account.
Exploit preconditions
- Attack surface: MCP HTTP Server endpoint exposing task execution functionality
- Required access: Network access to the server and any access permitted by its authentication or authorization controls
- Trigger point: Processing of attacker-influenced input by the
run_taskfunction - Why exploitation is possible: Input can reach an OS command execution context without sufficient separation between data and command syntax
Why this happens
The underlying flaw is improper neutralization of special elements in operating-system commands, mapping primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command. The related CWE-77: Improper Neutralization of Special Elements in Command describes the broader command construction problem. An insecure implementation combines or forwards insufficiently trusted input into a shell or command interpreter instead of treating task values strictly as data.
Potential impact
- An attacker may execute arbitrary commands on the PentestAgent host or container.
- The attacker could access, alter, or delete data available to the service account.
- The compromise could enable credential theft, persistence, or lateral movement.
- The service could be used to affect connected testing systems or other internal resources.
- Availability may be reduced through disruptive command execution.
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from task execution and reducing the trust placed in HTTP-supplied values.
Common defensive patterns include:
- Prefer direct process APIs with argument arrays over shell-based command construction.
- Enforce strict allowlists for permitted tasks, options, and argument formats.
- Apply context-appropriate validation and reject unexpected characters, delimiters, and expansions.
- Keep user-controlled values separate from executable commands and avoid dynamic command concatenation.
- Require authentication and authorization for task execution, using least privilege for service accounts.
- Isolate command-running workloads and limit filesystem, network, and operating-system permissions.
- Use secure-by-default configurations that disable unnecessary task types and remote execution paths.
- Avoid relying on escaping alone as the primary security boundary.
How teams detect issues like this
Detection approaches can include:
- Static analysis rules for shell invocation, dynamic command construction, and unsafe process APIs.
- Code review checks for string concatenation or interpolation involving HTTP parameters and command execution.
- Policy enforcement that requires allowlisted commands and direct argument passing.
- Runtime monitoring for unusual child processes, shell launches, command-line expansions, or unexpected outbound connections.
- HTTP and application logging that records authorized task requests without exposing sensitive values.
- Automated security review tools that flag CWE-77 and CWE-78 patterns during development.

