A repo you clone can name programs your coding agent starts for you. Most tools ask you once and remember the answer, so the next pull can change the program behind that yes.
Engineer's view. This is a cache key that misses an input. Your agent caches "the user approved this MCP server" under the server's name or the folder. The command behind that name can change on the next git pull, and the cached yes still applies. It costs you a stranger's script running with your keys.
TL;DR. In an untrusted repo, your coding agent can start programs the repo's config names. An approval stored under a name or a folder survives an edit to them. Key each approval on what actually runs, and never let the agent write those files on its own.
Explain Like I'm 5
A friend lends you a toy robot. On its back is a card that says what the robot does when you switch it on.
The first time, you read the card. It says "dance," so you say yes. From then on, the robot just starts.
One night someone swaps the card. Now it says "empty the cookie jar." The robot does not ask again, because you already said yes to "the robot."
The fix is to say yes to the card's exact words. If the words change, the robot has to ask you again. And the robot is never allowed to write its own card.
The Problem
You have shipped this bug before, and it had nothing to do with AI.
A service cached permission checks. The key was the user id. Someone's role changed from admin to viewer, and the cache kept saying yes for an hour. The check was correct. The key was missing an input, the role, and the cached answer outlived the fact it was based on.
A coding agent in a cloned repo is that bug with a shell attached. Every coding agent reads config files from the folder you open. Some of those files name commands: an MCP server to start, a hook to run, a task to launch. An MCP server is a helper program the agent starts so it can call its tools. Starting it means running whatever the repo says.
So every tool asks first and saves the answer. The question is what the saved answer is keyed on. In 2025, one popular editor's key was effectively the server's name. Researchers got a harmless server approved, then changed its command in a later commit. The editor started the new command without asking.
There is a second writer the old permission cache never had. The agent itself can edit these files, after reading a README or an issue that told it to.
The fix: treat a repo's config as code. Key every approval on the exact command and the repo files it runs, re-ask when any of them change, and make every agent write to those files ask a human.
Read the full post on The AI Commit
How to Stop a Cloned Repo From Running Code Through Your Coding Agent carries the rest: the fix and why it works, the code to change for each role, how to tell it worked, when it is the wrong tool, and an interactive model you can play with.
Originally published at theaicommit.com, a daily AI engineering lab for software engineers. The original has an interactive version you can play with, and the full runnable code is on GitHub.
Top comments (0)