Cybersecurity

Securing MCP Servers: A Hardening Checklist After the Exposed-Instance Disclosure

TuniCyberLabs Team
6 min read

A practical MCP hardening checklist: OAuth 2.1 authentication, localhost binding, a logging gateway, tool allowlists, package auditing after the postmark-mcp lesson, and where the OWASP MCP Top 10 fits.

What is the fastest way to secure an MCP server?

Do four things first: require authentication with OAuth 2.1 and audience-bound tokens; bind the server to localhost and validate the Origin header; put it behind a gateway that logs and allowlists tools; and pin and audit the server package. Those four close the exposed-instance, confused-deputy, and supply-chain gaps that cause most Model Context Protocol incidents.

  • Everything below expands these four moves into a checklist you can test.
  • The ordering matters: an unauthenticated, internet-exposed server is exploitable before any of your fancier controls matter.
  • A useful framing is to treat each MCP server as a privileged microservice with an untrusted client on one side and untrusted tool output on the other. Every control below follows from that stance.

Why are so many MCP servers exposed on the internet?

Because early MCP servers often shipped with no authentication and bound to 0.0.0.0, exposing them to any host that can reach the port. Public scans through 2025 reportedly found hundreds of unauthenticated instances. The default favored convenience, and the result was unauthenticated remote tool execution.

  • Bind locally: local servers should listen on 127.0.0.1, never 0.0.0.0. Binding to all interfaces is the mistake researchers nicknamed NeighborJack.
  • Validate Origin: check the Origin header so a malicious browser tab cannot reach a localhost server via DNS rebinding.
  • Pick the right transport: prefer stdio for local integrations; for remote, use the Streamable HTTP transport (introduced in the 2025-03-26 spec revision) behind real authentication, and never assume the network is trusted.

How should an MCP server handle authentication and authorization?

Treat the MCP server as an OAuth 2.0 resource server. The 2025-06-18 MCP specification revision classifies servers this way, requires Resource Indicators (RFC 8707) so tokens are audience-bound to your server, mandates PKCE, and forbids token passthrough. Use short-lived tokens and validate the audience on every request. Verify the current text against the primary MCP spec, since it is still moving.

  • Do not let one server act as both authorization server and resource server, the flaw critics flagged in the earlier draft.
  • Reject any token that was not minted for your resource. This is what stops confused-deputy token reuse across services.
  • Publish Protected Resource Metadata (RFC 9728) so clients can discover the correct authorization server automatically. For the broader shift away from static credentials, see The End of the Long-Lived API Key: Workload Identity and Secretless Architecture in 2026.

Why do I need an MCP gateway?

A gateway is a single choke point in front of your MCP servers where you centralize authentication, tool allowlisting, rate limiting, egress control, and audit logging. Without one, every server enforces its own policy inconsistently and you have no unified record of what the agent actually did.

  • Allowlist tools: permit only explicitly approved tools and block everything else by default.
  • Terminate auth once: authenticate at the edge, then inject scoped, short-lived credentials to downstream servers.
  • Log everything: record each request and response for detection and forensics.
  • Filter egress: restrict outbound destinations so a poisoned tool cannot phone home with your data.
  • Rate-limit and quota: cap tool-call volume per session so a hijacked agent cannot enumerate or exfiltrate a whole dataset in one burst.
  • A gateway is also the cheapest place to add later controls, from anomaly detection to policy-as-code, without touching each server. It is the difference between securing one boundary and securing ten.

How do I audit MCP server packages before I trust them?

Verify provenance before you install. The postmark-mcp incident was an unofficial clone of a trusted vendor's server that later added a hidden BCC exfiltrating every email the agent sent. Confirm the publisher, pin the version, read the source, and watch for typosquats of official package names.

  • Prefer first-party servers: choose vendor-published packages and verify the npm or PyPI publisher and the linked repository.
  • Pin and lock: pin exact versions, commit lockfiles, and re-review on every bump. That single habit defeats rug pulls.
  • Generate an SBOM: scan dependencies, check maintainer history, and flag sudden download or ownership anomalies. The mechanics carry over from Supply Chain Attacks: Why Your Dependencies Are Your Biggest Risk and Supply-Chain Attacks 2.0: Hallucinated Packages and Poisoned Models.
  • Sandbox the unknown: run any unvetted server with no real secrets until a human has read the code.
  • Remember that provenance is a moving target. A package that was clean at install can turn hostile at the next release, which is precisely how the postmark-mcp clone slipped its malicious change past teams who had reviewed an earlier, benign version. Continuous re-review, not a one-time check, is the control that actually holds.

How do I enforce tool allowlists and detect rug pulls?

Maintain an explicit allowlist of approved tools and hash their full definitions at approval time. On every session, re-fetch the definitions and compare hashes; block or force re-approval when a description, schema, or parameter changes. This turns silent server-side mutation into a visible, gated event.

  • Store the canonical description hash and diff it on each load.
  • Deny by default; any new tool requires human review before it can run.
  • Alert on parameter additions, especially hidden fields or free-text fields that can carry exfiltrated data.
  • Where your client supports it, pin server versions and endpoints so a swapped remote cannot quietly change what a trusted tool does.
  • Keep the hashing logic in your gateway rather than the agent, so the check cannot itself be argued away by a poisoned instruction.

What does the OWASP MCP Top 10 cover, and how mature is it?

The OWASP GenAI Security Project and community contributors are drafting MCP-specific guidance covering tool poisoning, rug pulls, tool shadowing, token and credential theft, excessive permissions, command injection, and unauthenticated exposure. It is still evolving, so treat it as guidance rather than a settled standard, and check the primary OWASP source for the current list.

  • The themes overlap the established OWASP LLM Top 10, especially prompt injection (LLM01) and excessive agency (LLM06).
  • Map each item to a concrete control you can test, rather than treating the list as a checklist to admire.

How do I monitor and sandbox MCP servers in production?

Run each server in a locked-down container with a read-only filesystem, no shell, seccomp applied, and no ambient cloud credentials. Log every tool invocation, monitor egress for exfiltration, and require human approval for destructive actions. Assume any server can be compromised and design to contain the blast radius.

  • Sandbox hard: containerize, drop Linux capabilities, and restrict filesystem and network reach.
  • Scope credentials: issue per-tool tokens and separate read access from write access.
  • Watch behavior: centralize audit logs and alert on anomalous egress destinations or request volume. Detection is what turns a silent breach into a caught one.
  • Approve the dangerous: require an explicit human confirmation for irreversible or high-blast-radius actions such as deleting records, sending mail, or moving money.
  • Test the whole chain the way an attacker would, with poisoned descriptions and hostile tool output, before you trust it in production, an exercise closely related to red-teaming any AI system.

How TuniCyberLabs helps

We harden MCP deployments as production services, not experiments: OAuth 2.1 with audience-bound tokens, a logging gateway with tool allowlists, pinned and provenance-checked packages, sandboxed servers, and egress monitoring wired into your alerting. We build and secure custom software, cloud, and AI systems for teams across the EU and North Africa, and we leave you with a tested configuration and evidence you can show an auditor.

Want a hardening review of your MCP servers and agent gateway? See how we can help.

TAGS
MCP securityhardening checklistOAuth 2.1MCP gatewaysupply chainOWASPAI agentspackage auditing

Frequently Asked Questions

How do I secure an MCP server quickly?

+

Start with four controls. Require authentication using OAuth 2.1 with audience-bound tokens; bind the server to 127.0.0.1 and validate the Origin header; put it behind a gateway that logs requests and allowlists tools; and pin and audit the server package. Those close the exposed-instance, confused-deputy, and supply-chain gaps behind most incidents.

Why should an MCP server not bind to 0.0.0.0?

+

Binding to 0.0.0.0 exposes the server on every network interface, so any host that can reach the port can call its tools, often without authentication. Local servers should bind to 127.0.0.1 and validate the Origin header to block DNS rebinding from a browser tab. Public scans in 2025 reportedly found hundreds of exposed instances.

What authentication does the MCP specification require?

+

The 2025-06-18 revision treats the MCP server as an OAuth 2.0 resource server, requires Resource Indicators (RFC 8707) so tokens are audience-bound, mandates PKCE, and forbids token passthrough. Use short-lived tokens and validate the audience on every request. The spec is still evolving, so confirm the current requirements against the primary MCP specification.

What is an MCP gateway and why use one?

+

An MCP gateway is a single choke point in front of your servers where you centralize authentication, tool allowlisting, rate limiting, egress filtering, and audit logging. Without it, each server enforces policy inconsistently and you have no unified record of agent activity. The gateway also lets you inject scoped, short-lived credentials downstream.

What is the lesson from the postmark-mcp incident?

+

Verify provenance before installing. postmark-mcp was an unofficial clone of a trusted vendor's server that later added a hidden BCC exfiltrating outgoing email. Prefer first-party vendor-published packages, verify the publisher and repository, pin exact versions with lockfiles, re-review on every update, and watch for typosquats of official package names.

Is there an OWASP MCP Top 10?

+

Community contributors and the OWASP GenAI Security Project are drafting MCP-specific guidance covering tool poisoning, rug pulls, tool shadowing, credential theft, excessive permissions, command injection, and unauthenticated exposure. It is still evolving, so treat it as guidance rather than a settled standard and check the primary OWASP source for the current list.

Need help with
this topic
?

Our team specializes in the technologies and strategies discussed in this article. Let’s talk about how we can help your business.

Get in Touch