#82 - Tools, Mcps, And Attack Scenarios
A local MCP server runs with its user's permissions, making every new tool a trust decision.
17 min read
This time we talk about how LLMs use tools and what the Model Context Protocol (MCP) brings to the table. What are the risks? How can an attacker exploit MCPs? And why are LLMs a bit like grandpas — helpful but forgetful?
The agent reads text that strangers wrote
Wire a coding agent into your GitHub organization and ask it to go through the open issues. The agent calls an MCP server, the server calls GitHub, and the issue bodies come back as plain text that lands in the model’s context right next to your own instructions. One of those issues was filed by somebody you have never met. Say its text tells the agent to pull the private repository next door and paste what it finds into a pull request. The agent holds a token that can do both. Whether it goes through comes down to two things you set: what that token reaches, and whether anyone reads the approval prompt before clicking past.
This is not hypothetical. Invariant Labs published a working demo on 26 May 2025: one public repository, one private repository, a malicious issue filed on the public one, and a prompt as ordinary as “Have a look at the open issues in my public repo”. The agent came back having published details from the private side, a project name, a planned relocation and a salary, into a public pull request. Their write-up is blunt about where the fault sits: this is “not a flaw in the GitHub MCP server code itself” but “a fundamental architectural issue that must be addressed at the agent system level”. They ran it against Claude Desktop, and say “the vulnerability is not specific to any particular agent or MCP client”.
The protocol in the middle is the Model Context Protocol, which Anthropic open sourced in November 2024 as a standard way to connect assistants to the systems where data lives. It does that job. What it does not do is judge whether the data coming back deserves to be acted on, or bound what the thing acting on it can reach. Those two decisions are yours: what the agent may touch, and what you approve when it asks.
Tools are what turned the chat box into something that acts
The risk arrives from what MCP plugs into, so start there.
What turns a chat box into an agent?
A list of functions the model is allowed to call, plus a program willing to run them on its behalf.
When ChatGPT showed up at the end of 2022 it was a toy. You could talk to it, and that was the whole product. Our working analogy for a model is a 90-year-old grandpa: knowledgeable, not current, and by the fifth follow-up he has forgotten where the conversation started. He has no idea what day it is either. Ask for a plan covering the rest of this year’s competitions and the answer comes back full of dates from previous years, because nothing in the model checks the calendar.
Tools patch the specific gaps. Search was the first one in wide use, often a search function wrapping an API like Brave’s. Arithmetic is another: models guess at numbers, so you hand them a Python interpreter and let the math module produce a reliable answer, which is what a deep research run means when it announces that it is using Python. The current date is the third. Amazon Bedrock’s documentation puts the mechanics plainly: “In Amazon Bedrock, the model doesn’t directly call the tool”, your application runs it and returns the result for the model to use.
Which functions exist is decided by whoever shipped the package you run: Claude Code, Claude Desktop, Cursor, the editor extensions, Codex, Amazon Q Developer CLI. Type /tools in q chat and you get the built-in list, fs_read, fs_write, execute_bash, use_aws, report_issue. Five or six functions, fixed. Everything past that list is the question MCP answers.
MCP is a plugin system for your agent
That list is short, and somebody else chose it for you.
What does an MCP server actually give the model?
A set of tools it advertises when the client connects, plus the credentials and API knowledge to drive the system behind them.
Think of a Jenkins plugin. Jenkins has no idea how to talk to your Jira; install the plugin and now it does. An MCP server is that deal for a model. It knows one system’s API, it holds the authentication for that system, and it tells the model what it can do. Server-side authentication can keep that credential out of the model’s context: the server logs in, the model gets results, and nobody pastes a token into a chat window. It holds only as far as the rest of the session allows. Give the same model a filesystem tool and ~/.aws/credentials is a file it can read. There is an MCP server for 1Password, and a password that server returns arrives in the context like any other tool result.
Remote servers were in the design from the start. The November 2024 specification defined two transports. One is stdio, where the client launches the server as a subprocess and the two talk over standard input and output. The other is HTTP with Server-Sent Events, for a server running somewhere else. March 2025 changed which HTTP transport, not whether there was one. That revision replaced HTTP+SSE with Streamable HTTP. stdio came through unchanged, and the June 2025 text repeats the same sentence: “The client launches the MCP server as a subprocess”.
Security guidance was in the specification from the first revision. November 2024 has a section on security and trust, and it is direct: “Tools represent arbitrary code execution and must be treated with appropriate caution”, and hosts “must obtain explicit user consent before invoking any tool”. June 2025 added a dedicated security best practices page covering the confused deputy problem, token passthrough and session hijacking. Both are worth reading, and worth seeing for what they are: advice to the people who write servers and clients, not a setting you turn on.
Everything the server returns gets interpreted
The useful mental model for what comes back is not “data”. It is “input to an interpreter”.
Why can’t the server sanitise the results first?
Because marking where untrusted text starts is not the same as making the model obey the mark.
The markers do exist. Microsoft’s April 2025 guidance for MCP describes delimiters, which show the model “the location of the input text”, and datamarking, which “extends this concept by using special markers” at the boundary between trusted and untrusted data. Both improve the odds that the model keeps the two apart. Neither can promise that what sits inside the untrusted marker is read as data and nothing else, because the content is still English and it was written to be followed.
If you work in security, the word interpreter should turn on a red light. PDF has been an attack surface for decades, and Adobe keeps patching Reader for the way it interprets documents. iMessage interprets what arrives and became the delivery path for Pegasus. Your browser is the largest example of all: you open a page with no idea what is on it, and your machine parses it anyway. Each of these is a program handling input it does not control.
A model with tools is the same shape with a much worse input grammar, because the grammar is English and the input is whatever the tool just fetched. Simon Willison’s lethal trifecta, published in June 2025, names the combination that makes it exploitable: access to your private data, exposure to untrusted content, and the ability to communicate externally. His read on the defenses is worth keeping in mind before you install anything: “we still don’t know how to 100% reliably prevent this from happening”.
An agent holding an organization-wide GitHub token has all three at once. Private repositories, issue text anyone on the internet can write, and a pull request as the way out.
The issue that files a pull request against you
Put those three together and the attack writes itself.
Is this a bug in the GitHub MCP server?
No. Every component did its job: the server fetched the issues it was asked for, and the model acted on what it read.
The uncomfortable part is that the benign version is the same feature. Letting an agent read inbound issues and fix the simple ones is exactly what a lot of teams want to buy: people write issues, the agent resolves them, everybody is happy. Public issue intake, private repository access and write permission in one session is the trifecta assembled on purpose, as a product decision.
Invariant make two recommendations. Granular permission control is the one we would reach for first: one repository per session, least-privilege tokens. A token that reads every repository in the organization is what turns a prompt injection into a leak. Their second is continuous security monitoring, a scanner that audits what passes between agents and MCP servers, which they say detects and responds to threats “in real time” and leaves an audit trail that helps “detect exploitation attempts”. It is worth having and slower to stand up, and it buys you detection. Stopping the private code from reaching the pull request takes an enforced boundary instead: a token that cannot read the other repository, or a runtime policy that refuses the second one inside a session.
The approval prompt is a weaker backstop than people assume. Invariant ran their demo against a client that asks: “Claude Desktop by default requires the user to confirm individual tool calls.” Their next sentence is the problem. “However, many users already opt for an ‘Always Allow’ confirmation policy when using agents, and stop monitoring individual actions.” One click, and the confirmation prompt stops being a control.
None of this is a fix for prompt injection. It is a limit on the blast radius when the injection lands, which is the part you control.
An MCP server is a stranger’s code running as you
Scope matters because of what an MCP server is on your machine.
What can a malicious MCP server reach on your laptop?
Your files, because it runs as your user account, and whatever environment variables the client chose to pass in.
Treat it the way you treat a Docker image from an author you have never heard of. A server definition is a command line, and most run uvx, Astral’s runner, which “invokes a tool without installing it”. Written plainly, your agent config says fetch this code from the internet and run it as me. There is an MCP server for 1Password, so “as me” can include your passwords.
Clients differ on that second half, so check yours. The official Python SDK does not hand a stdio server your whole environment. Version 1.9.4 passes an allowlist on POSIX: HOME, LOGNAME, PATH, SHELL, TERM and USER, plus whatever env the server entry declares. A real mitigation, with a narrow edge: it covers variables and nothing else.
The AWS case shows where that edge falls. aws-vault puts temporary credentials into your shell’s environment, so a client that forwards the environment forwards those. An SSO login works differently: it caches a token under ~/.aws/sso/cache for the CLI to pick up, beside the profile in ~/.aws/config. Either way q chat acts on whichever account is selected. At an AWS user group in Las Palmas in June we asked Amazon Q to scale an ECS service, and it scaled it. A six-variable environment does nothing about the files, because the server runs as you and ~/.aws is a directory you can read.
Vendor tools are not above this either. AWS’s security bulletin of 23 July 2025 describes version 1.84.0 of the Amazon Q Developer extension for VS Code shipping malicious code. It reached a release through “an inappropriately scoped GitHub token in their CodeBuild configuration” and “was unsuccessful in executing due to a syntax error”. Version 1.85.0 fixed it.
This field is young and rough at the edges. Docker had very little security when it started, and Jenkins was not built with it in mind. A container narrows what a server can open on disk to the image plus what you mount, which is why it beats the host. Plenty of servers ship no container, so that work is yours.
When a bash script beats an MCP server
Before installing anything, it is worth asking whether the job needs a model in the loop.
When is an MCP server the wrong tool?
When you do not control what goes in and what comes back, or when a deterministic script already does the work.
Here the three of us do not agree. Mattias wants an MCP server in front of data so an agent can use it: a recipe database, or an inventory question across four hundred repositories about which Next.js version each one is on. Andrey has not found that use case in his own workflow. Take the common example of summarising your commits, filling in the pull request template and opening the pull request. A bash script with the gh CLI already does it, more cheaply and more predictably, and it warms up the planet less. For the four-hundred-repository question, Andrey’s counter is that your Git host usually has insights of its own, computed with ordinary code that costs less to run. Whether yours answers that particular question, which Next.js version each of four hundred repositories pins, is worth checking before you put an agent on it.
That is the line that survives the disagreement. MCP is a useful tool, and agents running locally are genuinely good at investigations, the kind of work you would hand to an intern rather than spend your own attention on. The question is what the server is pointed at, not whether the protocol is good.
The traffic nobody is paying for
There is a second direction to this, which is what happens when the thing reading your service is an agent.
What changes when your reader is a bot?
Your serving costs move before your revenue does, because bots read in a pattern your caches were not built for.
The numbers from people who host popular content are not subtle. The Wikimedia Foundation reported in April 2025 that bandwidth for downloading multimedia had grown by 50% since January 2024, and that “at least 65% of this resource-consuming traffic we get for the website is coming from bots”, against roughly 35% of pageviews. Their explanation is about where a request lands. A page read often enough is cached in the datacenter nearest the reader, and a page nobody has asked for in a while has to come from the core. People cluster on popular topics and hit the cache. Bots “tend to ‘bulk read’ larger numbers of pages and visit also the less popular pages”, which “makes it much more expensive in terms of consumption of our resources”.
That report is about bots “collecting training data for large language models”, which is a different thing from an assistant running a search while you wait. Our read on live search is softer: it feels like these tools cache very little, as if each question sends a fresh query out to the web. That is an impression from watching them work, not something we measured. Open source hosting projects have described their own squeeze, multiples of the traffic they used to get and a bill to match.
The incentive underneath has shifted too. You used to write good text so search could find it, and that bargain returned visitors. With answers assembled elsewhere, the discipline people are now calling AEO is about being findable by the models instead. The channel is real even when the clicks are not: we have had an inbound lead arrive through a ChatGPT search, which surprised us more than it should have.
That is also the honest argument for building a server for your own data. If people will reach your service through an agent, giving that agent a defined, machine-readable path beats letting it poke at your site a thousand times to find the same answer.
What this means for teams
None of this needs a policy program. It needs to know which servers are installed, what each one can reach, and which sessions mix private data with text anyone can write.
Four things worth doing this week:
- Open every agent config on your machine and list the MCP servers in it. For each one, write down who publishes it, how it starts (
uvx,npx, a container), and what the client hands it: environment variables, and the files it can open as you. - Replace any organization-wide token used by an agent with a scoped one, and keep repository-reading sessions to the repositories they actually need.
- Pick one agent workflow that reads text from outside your company and list every way that session can send data out. A pull request or a comment is the obvious one. A tool that fetches a URL is the quiet one, because a secret fits in a query string. Splitting the workflow in two only helps if the untrusted text cannot reach the half holding the private data.
- Take your most-used agent task and write the script version. If
gh, the AWS CLI or your Git host’s own reporting does the job, keep the script.
Common questions, answered
How do I stop an AI agent from leaking a private repository through a public issue?
Scope the session to one repository and give it a token that can reach only that repository. The attack needs private data, attacker-written text and a way to send data out, all in the same session. Remove any one of the three and it breaks: read public issues with a token that cannot see private code, or read private code in a session that never touches inbound issues.
Prompt filtering is not the control to lean on. Delimiters and datamarking improve the odds, but nobody has a reliable way to stop a model from following instructions in its input, so change how far it reaches when it does.
How do I run an MCP server without handing it my AWS credentials?
Put the credentials out of its reach on disk, not only out of the environment. A stdio server is a subprocess of the tool that started it, and runs as the same user. Clearing AWS_ACCESS_KEY_ID from the shell is half the job: ~/.aws/credentials, the profile in ~/.aws/config and the cached SSO token are files it can open. Run it in a container and leave ~/.aws unmounted. The container still holds the image, whatever you pass in, and networking “enabled by default” for outgoing connections. Scope the agent’s profile to the task rather than handing it your full session.
Do I need to build an MCP server for my own product?
Not before you have a reason beyond “everyone is shipping one”. If agents can already reach your service through a documented API, that path works, and a server mainly buys efficiency: fewer wasted calls, a defined set of operations, authentication in one place. The case is strongest for search over data you own, where an unguided model is slow for itself and expensive for you.
Related episodes
- #81 Keeping Secrets Safe: the credentials an agent inherits from your shell, and where they should live instead.
- #78 Building AI Tools For IaC Compliance: what it takes to put an LLM inside a pipeline people are willing to trust.
- #63 Yet Another AI Episode: the earlier round of claims about AI doing the engineering work.
- #60 ChatGPT Anniversary: Where Are We With AI In Our Everyday Work: our earlier assessment of AI in everyday engineering work.
- #46 Software supply chain attacks: the trust question behind a config line that pulls a package you have not read.
- #4 Docker Runtime Security: the isolation argument behind running an MCP server in a container.
Resources
- Invariant Labs, GitHub MCP exploited: accessing private repositories via MCP: the May 2025 demo, what leaked, the two mitigations the authors recommend, and why they call it an agent-system problem rather than a server bug.
- Simon Willison, The lethal trifecta for AI agents: the three capabilities whose combination makes prompt injection worth exploiting, including why any outbound request counts as the third.
- Microsoft, Protecting against indirect prompt injection attacks in MCP: what delimiters and datamarking do, and what Microsoft claims for them, which is mitigation rather than prevention.
- MCP specification 2024-11-05, security and trust: that consent, data privacy and tool safety were in the first revision, including that tools are arbitrary code execution.
- MCP specification 2025-06-18, security best practices: confused deputy, token passthrough and session hijacking, pinned at the June 2025 revision tag.
- MCP specification, key changes for 2025-03-26: the replacement of the original HTTP+SSE transport with Streamable HTTP.
- MCP Python SDK v1.9.4, stdio client: the default environment a
stdioserver gets, which is an allowlist rather than everything you have exported. - AWS security bulletin AWS-2025-015: how malicious code reached version 1.84.0 of the Amazon Q Developer extension, and why it failed to run.
Since we recorded
GitHub’s answer to the public-issue path shipped on 10 December 2025: lockdown mode on the remote GitHub MCP server “ensures that only content from trusted collaborators with push access is surfaced”, and the same release added a header for exposing only named tools. Discovery got a front door as well, with the MCP Registry opening in preview on 8 September 2025 as an open catalog of publicly available servers. Amazon Q Developer CLI, the tool in the AWS examples above, has since been folded into Kiro CLI, and its repository now states that the open source project receives critical security fixes only. We returned to this topic in episode 86, MCP plugins: your next security blind spot?.
