Teams connecting an AI assistant to infrastructure often spend weeks debating model guardrails and system prompts, then wire up an off-the-shelf Model Context Protocol (MCP) server with a single command in a config file. Even when the language model behaves exactly as intended, the “hands” attached to it are ordinary software. An MCP server parses JSON-RPC inputs, spawns child processes, opens SSH sessions, writes files, and reads environment variables under real host or container privileges.
In a previous analysis of MCP transport boundaries and sandboxing, I looked at how stdio and Streamable HTTP separate clients from servers and where OAuth validation belongs. That transport choice sets the perimeter, not the code quality inside the server. Four advisories published in late November 2026 show how quickly MCP wrappers fail when routine software hygiene breaks down inside the tool handler itself: shell interpolation, secrets passed in process arguments, and unauthenticated Docker Compose bridges bound to every interface.
If you run or build MCP servers that touch databases, remote hosts, or developer workstations, the operational question is straightforward: what happens when a tool argument, a local observer, or a packet on port 3001 treats your wrapper as a normal program instead of an AI demo?
How a wrapper turns parameters into a shell
Consider an MCP server that manages remote databases or backups over SSH. From the model’s perspective, a tool like ssh_backup_create or ssh_db_list accepts structured JSON fields such as database, backupDir, or host. Under the hood, however, many wrappers assemble a single command string and hand it to a shell or to an SSH exec channel that invokes the remote user’s login shell.
That mechanism is documented directly in two November 2026 advisories against the npm package mcp-ssh-manager (CWE-78). In GHSA-4jx9-2fwj-pg4j (CVE-2026-77383, fixed in 3.6.7), caller-controlled parameters across the ssh_db_* helpers in src/database-manager.js were interpolated directly into shell command strings. A value containing ;, $(...), backticks, or | broke out of the intended database or table argument and ran arbitrary commands on the target server under the configured SSH account.
What happened next is an even sharper lesson for engineers reviewing patches. Fixing one file did not fix the pattern. Days later, GHSA-qwwm-vrm9-4mw8 (CVE-2026-129995, CVSS 8.8, fixed in 3.8.5) disclosed the same command injection flaw in src/backup-manager.js affecting mcp-ssh-manager versions prior to 3.8.5. While src/database-manager.js had received centralized shellQuote() wrapping across its 15 builders, src/backup-manager.js had zero shellQuote() calls.
Look at how easily an unquoted template string turns a backup helper into remote code execution:
// Vulnerable pattern documented in GHSA-qwwm-vrm9-4mw8 (mcp-ssh-manager < 3.8.5)
let command = 'mysqldump';
if (user) command += ` -u${user}`;
if (password) command += ` -p'${password}'`;
if (host) command += ` -h ${host}`;
command += ` ${database}`;
if (compress) command += ` | gzip > "${outputFile}"`;
Notice two failures in those six lines. First, database is completely unquoted. Second, password and outputFile rely on naive single or double quotes, which break as soon as the input contains a matching quote character. When ssh.execCommand() sends that string through ssh2 to sshd, the remote shell parses every metacharacter before mysqldump ever starts.
Why readonly modes and sibling tools fail together
Both mcp-ssh-manager advisories expose a subtle architectural trap: policy bypass through “safe” read-only tools. Operators often harden an MCP connection by switching it to a readonly or restricted mode, expecting that the agent can inspect state without executing arbitrary commands.
In mcp-ssh-manager, ssh_db_list (in CVE-2026-77383) and ssh_backup_list (in CVE-2026-129995) were classified as read-only or omitted from COMMAND_BEARING_TOOLS and READONLY_BLOCKED_TOOLS. Because ssh_backup_list did not run through applyServerPolicy and still built a find "${backupDir}" ... shell string, a caller hitting a readonly server could still achieve remote code execution via backupDir.
This failure has nothing to do with how clever the language model is. As the advisories note, tool arguments can be steered by indirect prompt injection in retrieved data or by a compromised MCP client. If your security boundary lives in a tool-name blocklist rather than at the execution sink, one overlooked helper voids the whole policy.
Why secrets in CLI flags leak before execution finishes
Even when a command cannot be injected, how an MCP wrapper passes credentials to child processes matters. A common shortcut when wrapping Windows, cloud, or database CLIs is to render a template containing the username, password, or bearer token and pass it directly as a command-line flag.
On 30 November 2026, GHSA-mf4q-589h-8gwx (CVE-2026-137184, CVSS 7.8, CWE-214) detailed this exact mistake in PowerShell MCP (@imrrd/powershell-mcp <= 0.5.2, fixed in 0.5.3, and the deprecated unscoped powershell-mcp <= 0.3.2, which will not receive a legacy patch). Its winrm_exec tool constructed a PowerShell script holding the caller-supplied WinRM username and plaintext password, then passed the entire script as the literal -Command argument on the spawned PowerShell process.
Process arguments are not private memory. On Linux, /proc/<pid>/cmdline is readable according to system configuration and process visibility; on Windows and Linux workstations alike, endpoint detection and response (EDR) agents, SIEM forwarders, and process-creation audit logs capture full command lines and retain them long after the child process exits. Any local user, monitoring tool, or log-reading role with access to process telemetry can recover credentials straight out of argv.
By contrast, the ssh_exec tool in the same PowerShell MCP codebase was unaffected because it used the ssh2 library in-process rather than spawning an external CLI with plaintext secrets in its argument vector. When spawning a subprocess is unavoidable, @imrrd/powershell-mcp version 0.5.3 shows the cleaner design: keep a fixed, non-sensitive bootstrap script in argv, and stream all caller-controlled credentials and parameters through child stdin.
Unauthenticated Docker bridges and persistent poisoning
Local subprocess bugs stay bounded to the host and its configured targets until someone wraps the MCP server in Docker Compose and exposes it over HTTP. That is where GHSA-c4hm-4h84-2cf3 (CVE-2026-59726, CVSS 10.0 Critical, published 24 November 2026) illustrates the full chain reaction.
In ruflo prior to 3.16.3, the default docker-compose.yml shipped an MCP bridge on port 3001 and MongoDB on port 27017 bound to all interfaces (0.0.0.0) with no authentication on POST /mcp or POST /mcp/:group. Worse, a tool blocklist covering terminal_execute was enforced only in the autopilot flow, not on the HTTP MCP endpoints themselves.
An unauthenticated caller on the network did not need to trick an LLM at all. They could send a direct tools/call request for terminal_execute to POST /mcp and gain a shell inside the container as the node user (UID 1000). From that single shell, three consequences followed immediately:
- Provider key theft: every LLM API key (
OPENAI,GOOGLE,OPENROUTER,ANTHROPIC) stored in the container environment could be read directly. - Resource hijacking: the attacker could spawn external workloads billed to those stolen keys.
- Persistent AI poisoning: because MongoDB had no
--authrequirement by default, the attacker could write poisoned entries into theAgentDBlearning store (agentdb_pattern-store), steering future AI outputs for all legitimate users of that instance.
Notice what the ruflo advisory explicitly warns operators: upgrading to 3.16.3 does not clean up a compromised deployment. Once an unauthenticated bridge and database are exposed, remediation requires firewalling ports 3001 and 27017, rotating every provider key, and auditing or purging AgentDB and MongoDB for tampering.
Three failure modes compared
Each vulnerability class strikes a different layer of the MCP server stack and demands a distinct engineering fix:
| Failure layer | Verified mechanism | Primary blast radius | Required fix |
|---|---|---|---|
| Shell string interpolation | Unescaped arguments concatenated into sh or SSH exec (CVE-2026-77383, CVE-2026-129995) |
Arbitrary OS execution on target hosts, even in readonly mode |
Parameterized execFile/spawn (shell: false), or strict quoting plus allowlists on SSH |
Secrets in process argv |
Plaintext credentials passed via -Command or CLI flags (CVE-2026-137184) |
Local credential recovery via /proc, EDR, SIEM, and audit logs |
In-process protocol clients, or static bootstrap in argv with secrets via stdin or FD |
| Open network bridge | Unauthenticated POST /mcp and DB bound to 0.0.0.0 (CVE-2026-59726) |
Unauthenticated RCE, env API key theft, and persistent store poisoning |
Default 127.0.0.1 bind, constant-time token auth, server-side tool gates, DB auth |
How to harden MCP server implementations
Applying a single regex filter or hiding a tool in a client config is never enough. The MCP security best practices for revision 2026-07-28 make this clear for local servers and proxies alike: avoid shell execution when handling untrusted URLs or inputs, treat proxy boundaries as code-execution gates, and enforce sandboxing plus authentication at the server.
1. Eliminate shell parsing wherever the OS allows it
When your MCP server executes a local binary, do not pass a formatted string to exec(), cmd.exe, or sh -c. Use execFile() or spawn() with an explicit argument array and shell: false (the Node.js default, which should never be overridden for convenience):
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
// Safe local binary call: no shell interprets metacharacters in backupDir
export async function listBackupMetadata(backupDir) {
if (!/^[a-zA-Z0-9/_.-]+$/.test(backupDir)) {
throw new Error('Invalid backup directory characters');
}
const { stdout } = await execFileAsync(
'find',
[backupDir, '-maxdepth', '2', '-name', '*.meta.json', '-type', 'f'],
{ shell: false, timeout: 10_000 }
);
return stdout;
}
When does this stop being enough? Over raw SSH exec channels, the protocol itself hands a single command string to the remote sshd, which typically launches the user’s login shell. In that specific case, every interpolated argument must pass through a centralized single-quote escaping helper (shellQuote()), and structured identifiers such as database names, hostnames, and backup paths should also pass strict format validation before reaching the command builder. Never rely on partial tool allowlists alone: centralize the policy check inside the single execution dispatcher so no *_list helper can bypass it.
2. Keep credentials out of argv and isolate runtime secrets
If a wrapped CLI accepts data on standard input or via a dedicated file descriptor, pass secrets there and keep argv strictly static. When using Node.js or Python libraries directly (such as ssh2 or a native database driver), keep authentication in-process so no child process is spawned at all.
Environment variables avoid argv logging in ps, yet they are still shared across every tool inside the same container. As shown in CVE-2026-59726, placing four provider API keys into one container’s env means any code execution in terminal_execute harvests all four. Split high-privilege tools into separate workers with only the scoped credentials each worker needs, and manage rotation cleanly rather than leaving long-lived plaintext keys in compose files, as covered in the article on eliminating plaintext .env secrets with SOPS, age, and Infisical.
3. Fail closed on network binds, auth, and container privileges
Follow the remediation pattern used in ruflo (3.16.3 / ADR-166) whenever an MCP server exposes HTTP or runs in Docker Compose:
- Bind loopback by default: listen on
127.0.0.1or a permissioned Unix domain socket for local deployments. If an operator explicitly enables a public interface, requireMCP_AUTH_TOKENat startup and fail closed if it is unset. - Verify tokens in constant time: compare bearer headers using
crypto.timingSafeEqualand enforce server-side tool gates (such as requiringMCP_ENABLE_TERMINAL=trueinsideexecuteToolitself, not just in one orchestrator flow). - Lock down companion stores and container capabilities: require
--authon databases, keep internal database ports off host0.0.0.0mappings, run containers as non-root withread_only: trueplustmpfs, drop Linux capabilities (cap_drop: ["ALL"]), and setno-new-privileges:true. The breakdown of rootless containers and distroless images covers that container baseline.
4. Prove the boundaries with negative tests in CI
Positive tests only prove the happy path works when inputs are polite. Before shipping an MCP server or approving a third-party wrapper for production, add automated negative tests that verify refusals across all three layers:
- Injection refusal: pass
; id,$(whoami), and quote-breaking strings into every tool parameter, including read-only list tools, and assert that either validation rejects them or no secondary command runs. - Telemetry cleanliness: inspect spawned child arguments (or mock
spawn/execFile) to confirm no password, token, or private key ever appears inargv. - Fail-closed defaults: boot the Docker Compose or HTTP service with default environment variables and verify that unauthenticated
POST /mcpcalls fail, public binds refuse to start without a token, and disabled terminal tools cannot be invoked directly over JSON-RPC.
An MCP integration is only as trustworthy as its dullest wrapper code. When you treat every tool handler like an untrusted network API, keep secrets out of argv, and test refusals in CI, a misbehaving model or a stray packet stops at a hard boundary instead of becoming a shell on your infrastructure.
[+] On this page 18 topics ▼
- How a wrapper turns parameters into a shell
- Why readonly modes and sibling tools fail together
- Why secrets in CLI flags leak before execution finishes
- Unauthenticated Docker bridges and persistent poisoning
- Three failure modes compared
- How to harden MCP server implementations
- 1. Eliminate shell parsing wherever the OS allows it
- 2. Keep credentials out of argv and isolate runtime secrets
- 3. Fail closed on network binds, auth, and container privileges
- 4. Prove the boundaries with negative tests in CI
- Author
- Frequently Asked Questions
- If prompt injection is blocked at the model layer, are MCP tool servers safe?
- Why did readonly mode fail to stop command injection in mcp-ssh-manager?
- Why is passing a password or token as a CLI flag dangerous even inside a private host?
- Does patching an exposed MCP container undo database or prompt-store poisoning?
- Related Articles
- Continue reading
Frequently Asked Questions
If prompt injection is blocked at the model layer, are MCP tool servers safe?
No. Prompt injection is only one way untrusted inputs reach a tool. MCP servers are ordinary network services and subprocess wrappers: unauthenticated HTTP bridges, shell string interpolation, and secrets placed in process arguments can be exploited by malicious clients, local observers, or unexpected data without tricking the LLM.
Why did readonly mode fail to stop command injection in mcp-ssh-manager?
In CVE-2026-77383 and CVE-2026-129995, read-classified tools such as ssh_db_list and ssh_backup_list bypassed the command-bearing policy checks while still passing unescaped parameters into remote shell strings. Labelling a tool read-only does not create a boundary unless the execution layer validates or quotes every parameter.
Why is passing a password or token as a CLI flag dangerous even inside a private host?
Process arguments (argv) are exposed to local users, monitoring agents, EDR sensors, and process-creation audit logs via interfaces like /proc/<pid>/cmdline or Windows process telemetry. Passing sensitive payloads over stdin, a dedicated file descriptor, or an in-process library avoids leaving credentials in command-line logs.
Does patching an exposed MCP container undo database or prompt-store poisoning?
No. As documented in the CVE-2026-59726 remediation guidance for ruflo, once an attacker reaches an unauthenticated bridge and writes into shared persistence such as AgentDB or MongoDB, upgrading the container image only closes future entry. Operators still have to firewall ports, rotate exposed API keys, and audit or purge poisoned records.
Related
Start your project
Need a website that earns trust, ranks in search, and gives your business a stronger digital presence? Start the conversation here.