On 25 November the German hosting company Mittwald published a long postmortem (in German) about how an attacker got into its platform through the MCP server it offered customers for connecting AI assistants. It is one of the first detailed public write-ups of a real MCP breach. If you run an MCP server in front of your own infrastructure, or plan to, read it.
That plan is getting common. Red Hat made the MCP server for RHEL generally available on 11 November, and AAP has its own MCP server too. Sooner or later most teams end up with a small service that holds credentials and turns requests from a model into actions on real systems. Here is a short version of what went wrong at Mittwald, and what we would change in that kind of service on RHEL, including a systemd hardening drop-in you can roll out with Ansible.
What happened
According to the postmortem, one tool in the MCP server could generate SSH keys. It built the ssh-keygen command line as one string, pasted the comment and passphrase from the tool call into it, and ran it through a shell. Anyone calling the tool could put a command substitution in the comment field and run their own commands in the container.
From there the attacker read the session store. It held the OAuth tokens the server used to act for every user, Mittwald staff included. With those tokens he created SSH users and API tokens in other people’s names and copied configuration and credentials out of customer projects. Mittwald counts 56 projects where the attacker demonstrably acted. Targeted use started on 27 October and the attack was found on 4 November.
The company is open about what made it worse. The token store was readable from inside the container. Scopes were wide, and staff with access to many projects used the server. The container filesystem was writable and the container could reach the internet freely. Its logs never reached central logging, so traces from the first days disappeared when the container was recreated. Two things limited the damage: tokens had a limited lifetime, so most of the stolen ones had already expired, and the separation between customer projects and internal infrastructure held. The Record has a shorter English summary of the first disclosure.
Lesson 1: a tool argument should never reach a shell
The bug is old. A string becomes a shell command, and the shell expands $( ) even inside double quotes. The fix Mittwald describes is to start the program directly with a list of arguments. The same rule applies to Ansible content that an agent can trigger. If a job template takes an extra var or survey answer that an agent fills in, check where that value ends up.
# Risky: key_comment is interpreted by /bin/sh
- name: Generate a key (do not do this)
ansible.builtin.shell: >-
ssh-keygen -t ed25519 -f /tmp/agent_key -N "" -C "{{ key_comment }}"
# Better: no shell, every argument arrives as plain text
- name: Generate a key
ansible.builtin.command:
argv:
- ssh-keygen
- -t
- ed25519
- -f
- /tmp/agent_key
- -N
- ""
- -C
- "{{ key_comment }}"
creates: /tmp/agent_key
ansible.builtin.command does not go through a shell, so pipes, semicolons and $( ) in the comment stay text. If you really need the shell module, run every variable through the quote filter. Narrow surveys help as well. A multiple choice question gives an agent far less room than a free text field.
Lesson 2: the token store is what the attacker wants
An MCP server that acts for its users has to keep their tokens somewhere. At Mittwald, code execution in one tool meant access to every session. Four things reduce that risk:
- Keep sessions and tokens in a separate process or service from the tools, with its own credential. A bug in one tool should not hand over everyone’s session.
- Keep token lifetimes short. This is what kept the Mittwald incident from being worse. Minutes are enough for agent work. We went through one way to do that for AAP in last week’s post on external OIDC access tokens.
- Give agent use its own accounts and scopes. An administrator who can reach everything should not connect that account to an assistant.
- Start read-only. Red Hat ships the RHEL MCP server with read-only tools by default. Keep it that way until you know exactly which write actions you need.
Lesson 3: a read-only service with no way out
A writable filesystem and open egress are things systemd fixes in a few lines. The drop-in below assumes the MCP server runs as a normal systemd service called mcp-server under its own unprivileged user. Adjust the name and the allowed networks to your setup.
- name: Harden the MCP server service
hosts: mcp_servers
become: true
vars:
mcp_service: mcp-server
mcp_allowed_addresses:
- localhost
- 10.20.30.0/24 # the API the server talks to
tasks:
- name: Create the drop-in directory
ansible.builtin.file:
path: "/etc/systemd/system/{{ mcp_service }}.service.d"
state: directory
mode: "0755"
- name: Install the hardening drop-in
ansible.builtin.copy:
dest: "/etc/systemd/system/{{ mcp_service }}.service.d/hardening.conf"
mode: "0644"
content: |
[Service]
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
NoNewPrivileges=yes
CapabilityBoundingSet=
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
SystemCallArchitectures=native
LockPersonality=yes
UMask=0077
IPAddressDeny=any
IPAddressAllow={{ mcp_allowed_addresses | join(' ') }}
notify: Restart MCP server
- name: Apply the change before checking it
ansible.builtin.meta: flush_handlers
- name: Get the systemd exposure report
ansible.builtin.command:
argv:
- systemd-analyze
- security
- --no-pager
- "{{ mcp_service }}.service"
register: exposure
changed_when: false
- name: Show the overall exposure line
ansible.builtin.debug:
msg: "{{ exposure.stdout_lines | last }}"
handlers:
- name: Restart MCP server
ansible.builtin.systemd_service:
name: "{{ mcp_service }}"
state: restarted
daemon_reload: true
ProtectSystem=strict makes the whole filesystem read-only for the service, so nobody can drop their own tools next to it. If the service legitimately writes somewhere, add that path with ReadWritePaths=. PrivateTmp gives it a private /tmp. With NoNewPrivileges and an empty CapabilityBoundingSet the process cannot gain privileges through setuid binaries. All of these are described in systemd.exec.
The network part comes from systemd.resource-control. IPAddressDeny=any plus an allow list means a reverse tunnel to some outside server will not connect. Three details matter. The filter works on IP addresses, not host names. It applies in both directions, so the clients that talk to the MCP server must be allowed too, or you put a reverse proxy on the same host and allow only localhost. And an address in the allow list always wins over the deny list. If the service looks up names, the DNS resolver needs to be reachable as well. When the API sits behind addresses that change, an egress proxy with a host allow list is easier to keep correct.
Roll this out on a test host first and run the service through its normal tools. A Node.js or Python server usually starts fine with these settings, but a missing write path shows up quickly as permission errors in the journal. For a containerised MCP server, Podman’s --read-only flag and a network that can only reach the API do the same job.
None of this stops a process from reading files it is allowed to read. That is why the token store in lesson 2 comes first.
Lesson 4: logs that outlive the service
Mittwald lost evidence because the MCP server only logged inside its own container. On RHEL a service that writes to stdout lands in the journal. Get it off the host, with rsyslog forwarding or systemd-journal-upload from the systemd-journal-remote package, and into whatever central logging you already watch.
Then decide what to alert on. The attacker used the regular API with valid tokens, and each action looked normal on its own: an SSH user here, an API token there. The pattern is what stood out. If agents have their own accounts, as in lesson 2, the useful rule is short. Alert whenever an agent identity creates credentials, users or keys.
Lesson 5: a switch you can pull
Mittwald had to shut off login and SSH for every customer because it had no finer tool. For an agent integration the switch is cheap to prepare. A small playbook, kept as a job template that on-call can launch, stops the service:
- name: Cut off agent access
hosts: mcp_servers
become: true
tasks:
- name: Stop and disable the MCP server
ansible.builtin.systemd_service:
name: mcp-server
state: stopped
enabled: false
Pair it with disabling the agent’s client in your identity provider, so tokens already issued run out and no new ones appear. Short lifetimes make that wait short. We wrote more about scoping agent access to AAP in connecting AI agents to the AAP MCP server.
Most of this is ordinary service hardening. MCP servers just deserve it before anything else, because they collect credentials in one place and take input from a model that can be talked into things.
Sources
- Mittwald: Postmortem on the MCP server and Neos breach (25 November 2026, German)
- The Record: Alleged AI-aided cyberattack exploits assistant interface to breach German web host (9 November 2026)
- Red Hat blog: General availability of MCP server for Red Hat Enterprise Linux (11 November 2026)
- systemd.exec manual
- systemd.resource-control manual



Leave a Reply