Experts blog

For years, we have designed API security around a fairly stable idea: a client requests access to a capability and the system decides whether it can use it. We authenticate the client, authorize the operation, validate the data and let the backend enforce its business rules.

With Model Context Protocol (MCP), that logic is still necessary, but it is no longer enough.

The fundamental difference is that a model now sits between the user and the capability, one that can discover tools, interpret descriptions, combine context and decide which action to execute. From an architectural point of view the change looks small, but it significantly alters the risk model.

An API Owner governs how other systems consume capabilities. An MCP Owner also has to govern how an AI discovers, interprets and uses those same capabilities.

And this gives rise to one of the core ideas of MCP security:

The model can propose an action, but the system must authorize it.

The new problem is not just who can do something

In a traditional API, we usually know in advance which operation an application wants to execute. In an MCP environment, the path is different: the user expresses an intention in natural language, and the agent interprets it, analyzes the available context, discovers several tools and decides which one to use and with which parameters.

This means it is no longer enough to ask ourselves “does this user have permission to perform this action?”. We also have to ask:

  • Why did the agent decide to use this tool?
  • Where does the information that influenced that decision come from?
  • Can a description, a document or the output of another tool change its behavior?
  • What happens if it combines two capabilities that seemed safe on their own?

This is where the risks specific to agentic systems come in. Prompt injection, tool poisoning, cross-server shadowing or dangerous combinations of tools are not just new risk categories: they all point to the same problem. Part of the decision is being made by a probabilistic component that works with potentially untrusted information.

That is why an instruction like this one:

“Never run this tool unless you are completely sure”

can be useful to guide the model, but it is not a real security control. Critical controls have to live outside the model.

Designing for when the agent gets it wrong

A good MCP architecture should not assume that the agent will always make the right decision. In fact, it should be designed precisely for the opposite scenario.

The agent can get it wrong: misinterpret a request, be manipulated through external content, select the wrong tool or generate unexpected parameters. None of that should automatically become a real action. The conceptual flow should be structured as follows:

MCP security flow: the agent proposes and the policy and authorization layer decides before reaching the backend

The agent proposes; the rest of the system decides whether that proposal can be carried out.

The MCP Server can apply controls specific to agentic interaction: checking whether a tool is available to that user, validating parameters against its schema, limiting certain combinations, requiring human approval or applying policies on the context.

However, this does not mean turning the MCP Server into a second backend. Business rules still belong to the API or the domain system. If the API already ensures that users can only operate on their own orders, that logic should not be duplicated in the MCP layer. If the backend controls financial limits, valid states or idempotency, it should keep doing so.

Defense in depth is not about duplicating rules in every layer, but about making sure each layer applies the controls it is actually responsible for.

OAuth is still OAuth, but the context changes

MCP does not need to reinvent OAuth either. Today’s Authorization Servers already solve most of the well-known problems: authentication, issuing access tokens, scopes, expiration, PKCE or redirect URI validation. The real risk appears when we misuse these mechanisms within an MCP architecture.

A clear example is token passthrough. Suppose the client obtains a token to access the MCP Server:

"aud": "customer-support-mcp"

That token should not be reused to call an internal API such as orders-api. Each resource server must receive a credential issued specifically for it; if the MCP Server needs to call that API, it should obtain its own token (for example, through token exchange) instead of forwarding the client’s. In fact, the MCP specification explicitly forbids a server from accepting tokens that were not issued for it.

The difference looks technical, but it has important consequences: if the same token works both to access the MCP Server and to call the API directly, the client could bypass the MCP layer and its controls entirely. In addition, a compromised credential would have a much larger blast radius, and traceability would suffer, because the API would not know who is really behind each call.

The rule is simple:

The audience indicates where a token can be used; the scope, what it can do.

A valid token is not necessarily a valid token for your service.

Not all URLs deserve trust

Another critical point arises during the OAuth discovery phase. An MCP server can dynamically tell the client which authorization or token endpoints to use, and it is tempting to assume that, because they come from the OAuth metadata, those URLs are trustworthy. They are not.

A dynamically obtained URL is still input that third parties can control. A malicious server could try to direct the request to 127.0.0.1, a private network or even the cloud metadata service.

This pattern leads directly to Server-Side Request Forgery (SSRF): getting our own infrastructure to send a request to a destination chosen by the attacker. The problem is not only that the address is internal, but that the attacker controls the destination of a request that originates from infrastructure with more privileges and access than the attacker has.

That is why the controls at this point can be summed up in three words:

Destination, redirection and resolution.

Validating the initial URL is not enough if there is a subsequent redirect to another destination. And validating the hostname is not enough either if it ends up resolving to a disallowed IP address.

A session is not an identity either

After authentication comes another risk that is easy to underestimate: session management.

A sessionId is used to maintain context, correlate messages or preserve state, but it should never become an authorization credential on its own.

If an attacker obtains a session identifier, the system must not automatically assume it is the same user. The session must be strictly bound to an authenticated identity, have a limited lifetime and be sufficiently unpredictable.

And above all, sensitive operations must still be authorized independently at the time they are executed.

The session maintains context; it does not grant privileges.

A valid session does not automatically turn a refund into an authorized operation.

When the MCP Server runs in the user’s local environment

So far we have mainly discussed risks related to identity, authorization, the network and sessions. The scenario changes completely when the MCP Server runs locally, which is very common with the standard input/output (stdio) transport.

In this case, we are no longer dealing only with an external integration: we are running real code on the user’s machine. That process can inherit access to the filesystem, environment variables, the network and local credentials, or even interact with other running processes.

That is why dismissing it as “just a local MCP” is a mistake. A local MCP must be treated with the same rigor as any other executable software: the organization needs to know what code it is running, with what permissions and whether it exactly matches what was approved. This is where controls such as these come into play:

  • Version pinning.
  • Hash and digital signature validation.
  • Managed installation processes.
  • Process isolation (sandboxing).
  • Runtime comparison of capabilities.

If an approved version only exposed getCustomer and getOrders, and later runShell silently appears, the problem is not only the existence of a new tool. What really matters is that what is running no longer matches what was evaluated, audited and approved.

Therefore, governing a local MCP cannot be limited to the MCP Server: it also has to cover the client, the endpoint and the mechanism through which those servers are installed and run.

Security does not end when we define the control

Designing controls is only half the job. The other half is proving empirically that they work.

A methodical and useful way to structure MCP security is to always think in terms of an inseparable triad:

MCP security triad: risk, control and evidence

  • If we want to prevent token passthrough, we must test what happens when we send a token with the wrong audience.
  • If we want to prevent session hijacking, we must deliberately try to reuse another user’s session.
  • If we want to block an SSRF attack, we must check how the system behaves with internal destinations, illegitimate redirects and disallowed DNS resolutions.
  • If we want to protect a local MCP, we must try to access resources outside its sandbox or run an unauthorized capability.

This way, security stops being a statement of intent and becomes a verifiable state.

Conclusion

This is probably the most profound governance shift that MCP introduces: it is no longer enough to know which capabilities we have published. We need to understand how they can be discovered, interpreted, combined and used by a probabilistic agent. And, above all, we must assume that sooner or later the agent will make a bad decision.

The right architecture is not one that aims for the model never to make mistakes, which is unattainable, but one that ensures that, when it does, the system remains secure.

The model can get it wrong. The architecture should not depend on it getting it right.

How CloudAPPi helps

At CloudAPPi we help teams design, govern and test MCP architectures: from the authorization model and audience separation to controls over local servers and the test suite that proves they work. If you are exposing your APIs to AI agents, we can help.

Author

Omar del Valle

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.