---
title: Audit your MCP servers for shell commands built from tool parameters, and keep user tokens out of reach of tool code | ctxsec
url: https://ctxsec.com/items/tip-mcp-tools-never-build-shell-strings-from-tool-params-mittwald-lesson
description: "Mittwald's breach started with one MCP tool that put caller-supplied text into execSync(). A quick grep plus a few architecture checks catch the same class of bug before an attacker does."
status: "guide (based on Mittwald postmortem)"
published: 2026-11-27
---

> Mittwald's breach started with one MCP tool that put caller-supplied text into execSync(). A quick grep plus a few architecture checks catch the same class of bug before an attacker does.

[← Tips & Guides](/tips) · [markdown](/items/tip-mcp-tools-never-build-shell-strings-from-tool-params-mittwald-lesson.md)

guide (based on Mittwald postmortem)

2026-11-27 2:49 PM ET

### Audit your MCP servers for shell commands built from tool parameters, and keep user tokens out of reach of tool code

- **Grep:** search MCP server code for exec/execSync/spawn with shell: true, os.system, subprocess with shell=True, and template strings feeding them; pass arguments as arrays without a shell.
- **Static analysis:** enable a rule that fails builds on command execution with interpolated variables (Mittwald says it had none for this project).
- **Tokens:** don't let the tool-execution container read the session/token store; scope tokens narrowly and keep staff accounts off customer-facing MCP servers.
- **Containment:** read-only container filesystem and default-deny egress, so a code-exec bug can't pull in tooling.
- **Review agent-written code** line by line for security, not just function; remove test-only tools before production.

Sources: [Mittwald postmortem](https://www.mittwald.de/blog/mittwald/postmortem-wie-ein-angreifer-ueber-unseren-mcp-server-und-neos-eindrang)
