Severity:

HIGH RISK

(7.3)

OS Command Injection in Toowiredd chatgpt-mcp-server

CVE-2026-7061

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-77, CWE-78

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Toowiredd chatgpt-mcp-server up to version 0.1.0 contains an OS command injection vulnerability in the MCP/HTTP Docker service (src/services/docker.service.ts), where untrusted input can influence shell commands.

An attacker who can reach the affected HTTP/MCP endpoint may execute arbitrary system commands on the host running the service, potentially gaining full control of the underlying environment.

Affected context

This vulnerability impacts deployments of the Toowiredd chatgpt-mcp-server that:

  • Expose the MCP/HTTP interface over a network (local, internal, or public)
  • Use the Docker-related functionality implemented in src/services/docker.service.ts
  • Construct or execute OS-level commands (e.g., docker CLI or shell commands) based on data derived from requests or other external sources

The weakness arises when user-controlled or otherwise untrusted values are concatenated into shell commands or passed to command execution APIs without sufficient validation or escaping.

Exploit preconditions

  • Attack surface: MCP/HTTP API endpoint(s) linked to Docker operations in src/services/docker.service.ts
  • Required access: Network access to the server that exposes the vulnerable endpoint (this may be from the internet, an internal network, or a local client depending on deployment)
  • Trigger point: Sending crafted input parameters (such as container names, image identifiers, or command arguments) that are incorporated into an OS command executed by the service
  • Why exploitation is possible: The implementation appears to build shell commands directly from untrusted input without rigorous validation, canonicalization, or use of parameterized/argument-based process execution APIs, enabling injection of additional command segments or operators

Why this happens

The root cause aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') and is closely related to CWE-77: Command Injection.

In the Docker service (src/services/docker.service.ts), command-line strings are likely being constructed by concatenating user-influenced values (e.g., request parameters) with static command fragments, and then executed via a shell-aware API (such as child_process.exec or a similar abstraction).

Because special shell metacharacters (like ;, &&, |, or backticks) are not robustly neutralized and the input is not strictly constrained to a safe pattern or whitelist, attackers can inject additional commands or alter the intended execution.

Abstractly, this is the insecure pattern of:

  • Treating untrusted input as part of an executable command
  • Relying on string concatenation rather than structured argument passing
  • Omitting strict validation and escaping at the boundary between data and code

Potential impact

  • Execution of arbitrary OS commands under the privileges of the chatgpt-mcp-server process
  • Unauthorized control of Docker containers, including starting, stopping, deleting, or modifying containers and images
  • Lateral movement within the host environment or connected infrastructure, depending on what the service account can access
  • Data exfiltration from local files, environment variables, configuration files, or mounted volumes
  • Deployment of malicious images or containers used as a pivot for broader compromise
  • Denial of service, such as by stopping critical containers or exhausting system resources

General mitigation guidance

Effective mitigation focuses on eliminating direct command construction from untrusted input and tightening trust boundaries around process execution:

  • Prefer parameterized command execution using APIs that accept an executable path and an array of arguments (e.g., child_process.spawn or execFile in Node.js) instead of passing a single shell-processed string.
  • Introduce strict input validation and normalization for any values that influence command arguments:
  • Use allowlists of permissible values (e.g., known container names, fixed actions, well-formed identifiers).
  • Reject or sanitize inputs containing shell metacharacters or unexpected patterns.
  • Replace dynamic shell usage with library-based Docker clients (e.g., Docker SDKs) where possible, so that user input is passed as structured parameters, not as shell text.
  • Apply least-privilege execution for the service:
  • Run the chatgpt-mcp-server under a dedicated, minimally privileged account.
  • Restrict its ability to manage Docker or system resources to only what is strictly necessary.
  • Segment network and infrastructure so that even if a command is injected, the blast radius is reduced (e.g., isolating this service onto constrained hosts or namespaces).
  • Document and enforce coding guidelines that prohibit direct shell command composition from untrusted sources.

How teams detect issues like this

Detection can combine code-level analysis, configuration review, and runtime monitoring:

  • Static analysis and code review:
  • Search for uses of shell-executing APIs (e.g., child_process.exec, execSync, shelljs) in src/services/docker.service.ts and related modules.
  • Flag any instances where command strings are built via concatenation or template literals that include request parameters or other untrusted variables.
  • Establish linting or custom static-analysis rules that disallow passing string-built commands to shell-aware APIs or require justification/approval.
  • Policy enforcement in CI/CD:
  • Add automated checks that block merges when new shell command execution patterns are introduced without appropriate validation scaffolding.
  • Maintain a secure coding standard mandating argument-based process execution and input whitelisting for command-related code.
  • Runtime and log-based monitoring:
  • Monitor logs for unusual or malformed command invocations, unexpected arguments, or errors from Docker commands.
  • Correlate spikes or anomalies in process creation, container lifecycle events, or failed commands with incoming HTTP/MCP requests.
  • Security testing:
  • Incorporate command injection test cases into automated API security tests or dynamic application security testing (DAST).
  • Use fuzzing or negative testing on endpoints that accept parameters used for container or command configuration.

Sources

SourceLink
github.comgithub.com/Toowiredd/chatgpt-mcp-server/
github.comgithub.com/Toowiredd/chatgpt-mcp-server/issues/8
github.comgithub.com/wing3e/public_exp/issues/28
vuldb.comvuldb.com/submit/798613
vuldb.comvuldb.com/vuln/359636
vuldb.comvuldb.com/vuln/359636/cti

Frequently asked

questions

Yes. If the MCP/HTTP interface is reachable over a network and the vulnerable Docker service endpoints are exposed, an attacker can attempt exploitation remotely by sending crafted requests.

The attacker typically needs network-level access to the chatgpt-mcp-server instance and the ability to invoke the affected endpoint. No local shell access is required, although authentication or API keys might be needed depending on how the service is deployed and protected.

Refactor the Docker service to avoid composing shell command strings from any untrusted input. Use argument-based process execution or Docker library calls, enforce strict whitelisting/validation of allowable values, and ensure that no user-controlled data is ever interpreted as part of a shell expression.

Adopt secure coding guidelines that explicitly forbid direct shell command construction from externally influenced data, enforce these guidelines with linters and static analysis in CI, and favor high-level SDKs or APIs over raw shell commands for system and container management. Complement this with regular security-focused code reviews of any module that interacts with the OS or container runtime.

Find out what's already
exploitable in your codebase.