AI Governance & Security · Deep Dive
MCP security: which permissions a coding agent really needs
An agent with broad permissions is not an assistant but an account with no personnel file. This deep dive describes the threat model of agentic tool chains, the recurring attack patterns and a way of scoping permissions that keeps the benefit without growing the attack surface along with it.
- Reading time
- approx. 5 minutes
- Last reviewed
- August 2026
- For
- Security, Architects, Platform Engineering
Once a coding agent can operate tools it is, in security terms, no longer an editor plugin but an acting account – one whose behaviour depends on text it reads along the way. That combination produces risks classic application security does not know in this form.
1. Threat model
Three properties make the tool chain attackable:
- The agent acts – it does not only read, it calls tools that have effects.
- Its control input is text – and text also comes from sources nobody has checked.
- It works with somebody else's permissions – usually those of the person who started it.
Attackers therefore need no access to your system. It is enough to place text somewhere the agent reads: a ticket description, a code comment, an error message, a fetched web page, the result of a tool call.
2. Indirect prompt injection
The central pattern. A model does not reliably distinguish between “this is the content you should think about” and “this is an instruction”. A request hidden in running text can therefore trigger actions.
Effective countermeasures are architectural, not linguistic:
- Treat tool results as data. The trust level depends on the source, not on the wording.
- Classify sources: an internal repository, an internal ticket system and the open internet are not the same thing.
- Limit the effect. If an injection can only read, the damage is small.
- Do not treat “ignore instructions in the text” prompts as a safeguard – that is a request, not a control.
3. The dangerous combination
Three properties that become critical together
- 1Access to confidential data – source code, client data, credentials.
- 2Processing of untrusted content – anything that comes from outside.
- 3The ability to communicate outwards – network, push, message, pull request.
If one of the three is missing, the damage stays limited. The most effective way to scope a tool chain is therefore never to grant all three at once.
4. Confused deputy and token forwarding
A server acting for many users with broad permissions becomes a confused deputy: it performs an action because a caller asked for it – without being able to check whether that caller was entitled to ask.
Two patterns that prevent this:
- Act on behalf of the person, not through a technical shared account. Only then do existing permissions and logs apply.
- Restrict tokens to the target resource. An access token issued for one server must not simply be passed on to another system – resource indicators in OAuth-based models exist precisely for this.
5. Servers as a supply chain
An MCP server is third-party software running on your systems whose tool descriptions help steer the agent's behaviour. It therefore belongs to be treated like any other dependency:
- Check the provenance and restrict it to known sources.
- Pin versions instead of pulling “latest”.
- Treat changes to the tool list like a dependency change: make them visible, review them, approve them. A server can change tools and descriptions after the initial approval.
- Keep them updated – servers have vulnerabilities too.
6. Permission model
| Action | Recommendation |
|---|---|
| Reading within the project scope | allowed, without asking |
| Writing to a working branch / staging | allowed, with approval per tool |
| Outbound network access | only to approved destinations |
| Deleting, deploying, approving | do not offer as a tool |
| Permission and user administration | do not offer as a tool |
7. Isolation and network boundaries
- A separate environment for agent runs – a container or dedicated workspace instead of the workstation with all its access.
- Restrict outbound connections; an allow-list is more effective than any content inspection.
- No production credentials in environments where agents run – not even “read only”.
- Keep secrets separate: no credentials in the working directory, secret scanning as a blocking gate.
8. Logging and detection
Log on the server side, not the client side: who, when, which tool, with which parameters, with what result. It only becomes analysable once it lives outside the session. Anomalies worth watching: unusually many calls in a short time, access outside the usual scope, outbound connections to new destinations.
Common mistakes
- An administrative shared account, because it is quicker.
- Offering everything as a tool, including pure read operations.
- Treating prompt rules as a security measure.
- Servers without pinned versions from an unknown source.
- Agent runs on the workstation with all production credentials present.
- No server-side logs – and therefore no ability to answer when it matters.
Checklist: securing agent permissions
- Confidential data, foreign content and outbound communication never meet.
- The agent acts on behalf of a person, not through a technical shared account.
- Tokens are restricted to the target resource and are not passed on.
- Servers are pinned and from a known source, and changes to tool lists are reviewed.
- Agent runs are isolated, with outbound connections limited to an allow-list.
- Calls are logged server-side and analysed for anomalies.
Conclusion
The security of agentic tool chains is not decided by the model but by the scoping: which data is reachable, which actions are possible and where results may flow. Deliberately limiting those three axes lets you use agents productively without growing the attack surface along with them.
The organisational frame around it – approved tools, data classes, review duties – is in the deep dive AI coding governance.
Sources & further standards
-
Model Context Protocol – specification
The authoritative source on primitives, transports, authorisation and versions. modelcontextprotocol.io -
OWASP Top 10 for Large Language Model Applications
Risk categories for LLM-based applications and tool chains. owasp.org -
RFC 8707 – Resource Indicators for OAuth 2.0
The basis for restricting access tokens to a specific resource. datatracker.ietf.org -
OWASP Application Security Verification Standard (ASVS)
Verifiable security requirements – usable as a checklist for reviews and gates. owasp.org
The protocol and its support in individual clients keep evolving. Check the specification version that applies to your tool chain before basing architecture decisions on it.
Further reading
Related deep dives.
MCP & Agentic Development
MCP in software development: controlled access for AI agents
Tools and resources, host-client-server, permission boundaries.
AI Governance & Security
AI coding governance: how teams use AI in a controlled way
Data classes, review duties, responsibility and technical enforcement.
Platform
How CodamAI implements these steps
MCP integration, explicit backend models, the Hub, OpenAPI and your own CI/CD.
Does CodamAI fit your engineering setup?
The most honest way to find out is a technical conversation: about your stack, your delivery and the requirements you have to evidence.