3 Hops to RCE. | MCP Security Part 4
A prompt injection could make GitHub Copilot write to its own settings file and enable auto-approve, after which the agent ran shell commands without confirmation, giving remote code execution on the developer's machine. A separate bug in Anthropic's Filesystem MCP server used a string prefix check for allowed directories, so paths that merely started with an allowed path were also accessible.
medium.com
Published on medium.com
Previously in this series: Part 1 · Part 2 — tool poisoning · Part 3 — prompt injection as SSRF for text
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The agent had write access to its own configuration and permission files, so untrusted input could disable the confirmation gates that would otherwise stop command execution.
Impact
An attacker could achieve remote code execution on the developer's machine, and could persist or spread the injection to other projects, though the text notes the chain was patched in August 2025.
What the attacker needed
Agent can write its own config files; attacker controls input the agent reads; agent can run terminal commands
The fix
The agent should not be able to write to its own configuration or permission files, or every such write should require explicit human approval; the text says the Copilot issue was fixed in August 2025.
How it was found
- Deliver an injection through a channel the attacker controls, such as a source file, a web page, a GitHub issue or a tool response.
- The injection makes the agent add an auto-approve setting to the workspace settings file.
- The agent's confirmation prompts are now disabled.
- With confirmations off, the agent runs a terminal command, achieving code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
An AI coding assistant reads text from files, web pages and tool results, and it can also write files. If an attacker hides instructions in that text, the assistant may follow them. Here the assistant was allowed to edit its own settings, so it turned off the safety prompts that ask the user before running commands, and then it ran commands on the computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.