What happened
An MCP server lets an AI assistant use tools, such as a tool that manages hosting projects. One tool on mittwald's server created SSH keys. It put text from the user into a command, which let an attacker run other commands inside the server's container.
| Date in 2026 | Event |
|---|---|
| 21 October | First tests of the flaw |
| 27 October | The attacker uses the flaw and reads login tokens |
| 28 October to 3 November | The attacker uses tokens to reach projects and adds new ways to get back in |
| 4 November | mittwald finds the attack and shuts down the MCP server |
| 9 November | A second phase begins, using other ways in |
| 12 November | A new flaw in Neos is used to attack mittwald.de |
mittwald confirmed that 56 projects were compromised. Data was probably copied from them. The attacker took several thousand tokens, but mittwald says most had expired. These are the company's own findings. When the report was published, it was still looking into some details.
The coding mistake
The tool built a command from user input and ran it with execSync. This is a short example of the same problem, not mittwald's code:
// Unsafe: a shell reads the whole string
execSync(`ssh-keygen -t ed25519 -f "${file}" -C "${comment}"`);Adding quotes does not make this safe, because a shell can still treat some text inside double quotes as a command.
If you need to run another program, pass each value separately and do not use a shell:
import { execFileSync } from "node:child_process";
if (!/^[A-Za-z0-9@._-]{1,80}$/.test(comment)) {
throw new Error("Invalid comment");
}
execFileSync(
"ssh-keygen",
["-q", "-t", "ed25519", "-N", "", "-f", file, "-C", comment],
{ timeout: 5000, stdio: "ignore" }
);In this example, file must be a new path chosen by the server in a private temporary folder. The -N "" option creates a key without a passphrase. Only use it if your design allows this, and protect the private key. Do not put a real passphrase in a command, because other users on the system may be able to see it.
It is often better to create keys with a library, so you do not need to run another program. Make sure that temporary files are deleted even when there is an error. At mittwald, a cleanup problem left 161 key pairs behind. Three of them contained traces of the attacker.
The simplest fix may be to delete the feature. mittwald found that its tool threw away the key it had made, so the tool did nothing useful.
Why code review missed it
mittwald says AI coding agents wrote most of this code. It looked tidy and had clear comments. Reviewers mainly checked what it was meant to do, and may have looked less closely because names such as "mcp-eval-key" made it look like test code.
There was also no automatic rule to find user input inside an execSync command. You can start with a simple search:
git grep -nE '(exec|execSync)[[:space:]]*\([[:space:]]*`' -- \ '*.js' '*.ts' '*.mjs' '*.cjs'
This does not find every case. For example, the command may be built on an earlier line. Use SAST as well, and review every place where your code starts another program.
Limit what one mistake can do
Command injection was the way in. The tokens gave the attacker access to much more.
- Keep user sessions separate. One container should not be able to read every user's tokens.
- Use short-lived tokens with limited access. Give each token only the access its task needs.
- Limit outgoing connections. An MCP server that needs one API should not be able to reach the whole network.
- Make files read-only where you can. Give the server a small temporary folder if it needs one.
- Send logs to another system. mittwald's MCP server was not connected to its main logging system. When its container was recreated on 2 November, early evidence was lost.
- Watch how tokens are used. Calls made with a valid token can look normal. Look for unexpected API keys, SSH users and access to projects.
- Make sure you can turn off one tool quickly. Test this before you need it.
mittwald says it will only bring its MCP server back with a new design. It plans to use read-only files, separate sessions, limited network access, short-lived tokens and central logs.
Questions for your next MCP review
- Does each tool need to exist?
- Can a tool start a program, read a file or make a web request?
- Which user's access does it use, and where is the token stored?
- What can it still reach if an attacker controls its container?
- Which logs will still be there if the container is deleted?
What scanners can and cannot find
SAST can find many cases where user input reaches a shell command. Results depend on the language, framework and rules used. A code scan may not see how tokens are shared in the live system, or if logs are sent to another place. You need a design review and tests for these.
Check AI-written code at least as carefully as any other code. Clean code and good comments do not prove that it is safe.
Check AI-written code for security problems
AquilaX looks for risky patterns often found in AI-generated code. Included in Ultimate.
See AI code scanning →