4
IETF/OAuth specifications the MCP authorization flow is built on: OAuth 2.1, RFC 8414 (authorization server metadata), RFC 7591 (dynamic client registration), and RFC 9728 (protected resource metadata)
10
risk categories cataloged in the OWASP MCP Top 10, the first OWASP framework dedicated specifically to Model Context Protocol implementations
STDIO
the one MCP transport the spec explicitly tells servers to skip OAuth for, pulling credentials from the local environment instead of running a browser-based authorization flow

SponsoredHorizon3.ai

Proactive Security for the AI Era

NodeZero continuously and autonomously pentests infrastructure, identity, cloud, and now web applications, chaining weaknesses across every domain the way real attackers do. Every finding ships with replayable proof showing exploitable business impact, not theoretical risk.

See NodeZero WebApp in action

Most teams that stand up an MCP server get the plumbing right and stop there: the server exposes a set of tools, an agent connects to it, tool calls work. What usually does not get built before launch is the part that keeps working once someone other than your own team can reach that server, or once one of the tools it exposes turns out to be less trustworthy than it looked in code review. This guide is a concrete implementation path through the three controls that actually matter for a production MCP deployment: authentication using the mechanism the MCP spec itself defines, sandboxing so a tool's execution cannot reach past its own boundary, and allowlisting so an authenticated session can only invoke the specific tools and parameters it was explicitly granted. If you already have an MCP server running and just want a way to continuously check its configuration against known risk patterns, our comparison of MCP security scanners from Cisco, Invariant, and Akto covers that separate, tool-based approach. This piece is about configuring the server itself.

The problem with a default MCP deployment

The Model Context Protocol makes it easy to expose tools to an agent and easy to forget that every one of those tools is now reachable by anything that can reach the server. Authorization in the MCP spec is explicitly optional, which means a server can be fully spec-compliant while accepting any connection with no authentication at all. Tool execution by default runs wherever the server process runs, so a tool that shells out to run a command or fetch a URL is one bug or one poisoned tool description away from doing that on behalf of an attacker rather than the intended agent. And most MCP clients grant an agent access to every tool a connected server advertises, with no separate step asking whether this particular session actually needs all of them. None of that is a flaw in the protocol. It is what you get from a protocol that deliberately leaves authorization, sandboxing, and access policy to the implementer rather than baking in one opinionated answer. The three sections below are that implementer's job.

Prerequisites before you start

Before touching configuration, get clear answers to a few questions. Getting these wrong is the most common reason teams end up bolting on the wrong control for their actual deployment.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Free daily briefing

Briefings like this, every morning before 9am.

Threat intel, active CVEs, and campaign alerts, distilled for practitioners. 50,000+ subscribers. No noise.

Step 1: Implement the MCP spec's OAuth-based authorization flow

The current MCP specification defines authorization for HTTP-based transports as a specific, narrower profile of OAuth 2.1, not a free-form "add whatever OAuth flow you like" instruction. In this model, the MCP server acts as an OAuth 2.1 resource server, the MCP client acts as an OAuth 2.1 client, and a separate authorization server (which may or may not be the same system as the MCP server) issues the actual access tokens. The flow is built on four underlying specifications: OAuth 2.1 itself, RFC 8414 for authorization server metadata discovery, RFC 7591 for dynamic client registration, and RFC 9728 for protected resource metadata. Getting these four pieces wired together correctly is most of the work.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Step 2: Sandbox tool execution so a compromised tool cannot reach the host

Authentication controls who can talk to your MCP server. It does nothing about what happens once a tool call actually executes. A tool that runs a shell command, fetches a URL, or executes model-generated code needs its own execution boundary, because a single vulnerable or maliciously modified tool running in the same process as your server's request handling can compromise everything else that process can reach.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Step 3: Allowlist exactly which tools and parameters a session can invoke

OAuth handles who is connecting, and a valid, correctly scoped token proves the connection is legitimate at a coarse level. It does not tell you which of the specific tools your server exposes that session should actually be able to call, because the MCP spec does not standardize per-tool scope conventions. That gap has to be closed with your own policy layer, and it needs to be enforced twice, not once.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Validating the deployment

Configuration that looks correct in code is not the same as configuration that behaves correctly under an actual request. Run each of these checks before calling the deployment done, and re-run them whenever the token validation, sandbox, or allowlist logic changes.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Failure cases: what actually breaks in production

These are the specific ways this implementation goes wrong in practice, not hypothetical edge cases.

Subscribe to unlock Remediation & Mitigation steps

Free subscribers unlock full IOC lists, Sigma detection rules, remediation steps, and every daily briefing.

Security tradeoffs to accept knowingly

None of these three controls is free, and pretending otherwise leads to configurations that get quietly rolled back the first time they cause friction. Stronger sandboxing (gVisor, microVMs) adds real per-call latency and infrastructure cost compared to a bare container or in-process execution, which is why the trust-level classification in the prerequisites matters: paying that cost for every internal, low-risk tool call is often not worth it, while skipping it for a third-party server executing model-generated code is a real gap. Fine-grained, parameter-level tool allowlisting is an ongoing maintenance burden, not a one-time setup task. Every new tool needs an explicit grant decision, and every change to an existing tool's schema needs a re-review, and teams that let that process lapse drift back toward broad, undocumented trust without necessarily noticing it happened. The MCP spec's own authorization flow is also narrower than it might look: it standardizes authentication and coarse resource-level access well, but it deliberately leaves per-tool scope granularity to the implementer, which means two MCP servers can both be fully spec-compliant on authentication while having completely different actual tool-level access control. Compliance with the OAuth flow described here is a necessary control, not evidence on its own that a deployment is secure. Automated scanners, covered in our comparison of Cisco, Invariant, and Akto's MCP scanners, catch some known patterns like poisoned tool descriptions and can flag some rug pull activity, but that tooling category is young, without a long independent track record, and complements the manual work in this guide rather than replacing it. Finally, none of this exists in isolation: the identity and access decisions made for a single MCP server should fit into a broader program for how your organization manages AI agent and non-human identities generally, which our agentic AI identity maturity model walks through at the organizational level rather than the single-server level covered here.

The bottom line

Securing an MCP server is three separate, concrete jobs, not one setting to toggle on. Authentication means actually implementing the MCP spec's OAuth 2.1-based flow correctly, including audience validation on every request and never passing a client's token through unmodified to an upstream API, while skipping it entirely for STDIO transports as the spec directs. Sandboxing means routing every tool execution into an isolation boundary matched to that tool's actual trust level, from a hardened container for internal tools up to gVisor or a microVM for anything running model-generated code or third-party server logic, with network egress default-denied and only explicitly opened where a tool genuinely needs it. Allowlisting means starting every session at zero tools, enforcing the grant at both list time and call time, constraining parameters and not just tool names, and treating a changed tool definition as requiring fresh approval rather than inheriting old trust. None of these controls is complete on its own, and none of them is free: they add real latency, real infrastructure cost, and a real ongoing review burden. But a default MCP deployment with none of them is fully spec-compliant and still open to any client that can reach it, running every tool with the same trust as the server process itself, with no record of which tool a given session was actually supposed to be able to call.

Frequently asked questions

Is OAuth actually required to secure an MCP server?

Not by the letter of the spec. The MCP specification marks authorization as optional and says HTTP-based transports should follow its OAuth 2.1-based flow, using the word SHOULD rather than MUST. In practice, any MCP server reachable over HTTP without it accepts requests from anyone who can reach the endpoint, so treat it as required for any server that is not purely local. STDIO transport servers are the explicit exception: the spec says they should not implement this OAuth flow at all, and should instead pull credentials from the local environment the host process injects.

What is the difference between MCP server authentication and tool allowlisting?

Authentication, implemented through the MCP spec's OAuth flow, establishes that a connecting client holds a valid token issued for your specific server, which answers who or what is connecting. Tool allowlisting is a separate policy layer you build yourself, since the spec does not standardize per-tool scopes, and it answers a narrower thing: given that this session is authenticated, which specific tools, and which parameter values for those tools, is it actually permitted to invoke. A valid token proves identity; it says nothing on its own about which of the server's tools that identity should reach.

Do I need a full microVM to sandbox MCP tool execution, or is a container enough?

It depends on the trust level of the tool. A hardened container, read-only root filesystem, all capabilities dropped, no-new-privileges enabled, is a reasonable boundary for first-party, internal tools you wrote and reviewed yourself. For tools executing model-generated code, or for any third-party or community-published MCP server, a plain container's namespace isolation is not a strong boundary against code actively trying to escape it, and gVisor or a hardware-virtualized microVM such as Firecracker or Kata is the more defensible choice.

How does the MCP spec prevent a token from being reused against a different service?

Through audience binding using RFC 8707 resource indicators. MCP clients must include a resource parameter, set to the MCP server's canonical URI, in both the authorization request and the token request, and MCP servers must validate that any token presented to them was actually issued with their own URI as the audience before processing the request. Servers must also avoid forwarding a client's original token unmodified to an upstream API, since doing so recreates the same confused deputy risk the audience check is meant to prevent.

What is a rug pull attack against an MCP server, and does allowlisting stop it?

A rug pull is when a tool passes initial review and gets allowlisted, then its description or behavior silently changes afterward, weaponizing a tool the agent already trusts. CVE-2025-54136, disclosed against Cursor's MCP integration, formalized this exact pattern. A name-based allowlist alone does not stop it, since the name stays the same while the tool's actual definition changes underneath it. Effective allowlisting has to treat a changed tool definition as a new tool requiring re-approval, and pairing that discipline with a continuous scanner is more reliable than a one-time manual review.

Should I build this myself or just use an MCP security scanner?

Both, for different purposes. The authentication, sandboxing, and allowlisting controls in this guide are configuration you have to build into the server and its deployment regardless of tooling; no scanner substitutes for actually implementing audience validation or sandboxed execution. An MCP security scanner adds ongoing, automated checking for known risk patterns like poisoned tool descriptions and some rug pull activity on top of that foundation. See our comparison of [MCP security scanners from Cisco, Invariant, and Akto](/blog/mcp-server-security-scanners-cisco-invariant-akto) if continuous automated checking is what you are missing.

Sources & references

  1. Model Context Protocol: Authorization specification (2025-06-18)
  2. OWASP MCP Top 10 Project
  3. Checkmarx: MCP Security Risks, Real-World Incidents & Controls
  4. WorkOS: MCP Authorization Patterns: Per-Tool Scopes, Consent, and Least Privilege
  5. Permit.io: When AI Subagents Call MCP Tools, Who Owns the Permission Decision?
  6. Modal: Best Code Execution Sandboxes for MCP Servers in 2026

Free resources

25
Free download

Critical CVE Reference Card 2025–2026

25 actively exploited vulnerabilities with CVSS scores, exploit status, and patch availability. Print it, pin it, share it with your SOC team.

No spam. Unsubscribe anytime.

Free download

Ransomware Incident Response Playbook

Step-by-step 24-hour IR checklist covering detection, containment, eradication, and recovery. Built for SOC teams, IR leads, and CISOs.

No spam. Unsubscribe anytime.

Free newsletter

Get threat intel before your inbox does.

50,000+ security professionals read Decryption Digest for early warnings on zero-days, ransomware, and nation-state campaigns. Free, daily, no spam.

Unsubscribe anytime. We never sell your data.

Eric Bang
Author

Founder & Cybersecurity Evangelist, Decryption Digest

Cybersecurity professional with expertise in threat intelligence, vulnerability research, and enterprise security. Covers zero-days, ransomware, and nation-state operations for 50,000+ security professionals every morning.

Giveaway: InfoSec World 2026 All Access Pass ($3,895 value)

Details →
Daily Briefing

Subscribe to enter the giveaway

Every subscriber is automatically entered. You also get daily threat intel every morning: zero-days, ransomware, and nation-state campaigns. Free. No spam.

Already subscribed? You're already entered.

Giveaway

Win a $3,895 InfoSec World 2026 pass.