✕ Beranda Langganan Per Project Proses Profil FAQ Co-Researcher Blog Carousel SaaS Hubungi
Artikel ini juga tersedia dalam Bahasa Indonesia. Baca versi Indonesia →

The MCP Attack Surface You Already Exposed Without Noticing

The MCP Attack Surface You Already Exposed Without Noticing

Your AI Agent Has More Doors Than You Think

When a team deploys an AI agent on a production server, the conversation usually centres on the model: how smart, how fast, how expensive. What rarely gets discussed is everything installed alongside it. Once an agent gets tool access through the Model Context Protocol (MCP), your server gains a set of new components: MCP server processes, HTTP endpoints, API tokens stored somewhere, a shell that can run commands, and a writable working directory.

Each of these is attack surface. This article is for sysadmins and DevOps engineers running agents in production: how to inventory that surface, why MCP servers end up exposed to the internet by accident, the core hardening principles, workload isolation, and what to log so an incident can be reconstructed.

1. Inventory the Attack Surface

You cannot secure what you do not know exists. Start with these four categories for every host that runs an agent:

Component Questions to answer Primary risk
MCP endpoints Which transport (stdio or Streamable HTTP)? Which address and port does it listen on? Unauthenticated access from outside
Stored credentials Which tokens does the agent hold? Stored in files, env vars, or a secrets manager? What scope? Leaked tokens with excessive rights
Agent shell Can the agent run commands? As which user? Arbitrary command execution, privilege escalation
Working directory Which paths can it read and write? Are secrets inside? Reading .env or SSH keys, overwriting code

The MCP specification defines two standard transports. stdio launches the MCP server as a subprocess of the client and talks over stdin/stdout, so no network port is opened. Streamable HTTP runs the server as an independent process that handles many connections through a single HTTP endpoint (for example /mcp). The second is the usual way in from outside, because it is, quite literally, a web server.

A simple ss -tlnp on each host is enough to start: note every process listening on 0.0.0.0 or :: and match it against the MCP servers you know about.

2. Why MCP Servers Get Exposed by Accident

Almost nobody deliberately puts an unauthenticated MCP server on the public internet. Exposure usually comes from a stack of small decisions that each look reasonable:

  • Binding to all interfaces by default. Many code samples and server templates listen on 0.0.0.0 so they "just work". On a laptop that is harmless; on a VPS with a public IP, the port is open.
  • Published Docker ports. -p 8000:8000 in Docker binds to every host interface. On many distros the iptables rules Docker writes also bypass UFW, so the firewall you thought was closing that port does not apply.
  • Tunnels left running after a demo. A public tunnel gets set up to try an integration, then stays up. The CSA document lists session hijacking risks, including the reassignment of released tunnel subdomains.
  • Authentication treated as optional. The MCP specification says servers SHOULD implement authentication, not MUST. Minimal implementations often skip it.

The MCP specification itself carries a security warning for Streamable HTTP: servers must validate the Origin header to prevent DNS rebinding, should bind only to localhost (127.0.0.1) when running locally, and should implement proper authentication for all connections. Without these, a malicious website opened in a browser can interact with your local MCP server.

On exposure numbers. Several aggregate figures circulate about how many MCP servers are exposed. The CSA document itself cites one such figure from secondary reports and notes that the methodology is not explained. We therefore deliberately do not quote it here. What you can verify yourself is far more useful: scan your organisation's own IP ranges, or look up your server IPs on Shodan or Censys, and check whether any MCP endpoint answers without credentials.

One concrete, documented example: CSA records CVE-2025-6514 (CVSS 9.6) in the mcp-remote package, versions 0.0.5 through 0.1.15. An authorization_endpoint supplied by a malicious server was passed unvalidated to the operating system's open() call, enabling command execution before authentication. The fix shipped in version 0.1.16.

3. Core Hardening Principles

These four principles close most of the common gaps:

  1. Bind to localhost. An MCP server used only by an agent on the same host should listen on 127.0.0.1, or better still use the stdio transport. In Docker, write -p 127.0.0.1:8000:8000, not -p 8000:8000.
  2. Authenticate at a gateway. If the server genuinely has to be reached from another host, put it behind a reverse proxy or MCP gateway that enforces authentication and TLS. CSA recommends OAuth 2.1 with PKCE for public clients, TLS 1.2 or higher (1.3 preferred), and no self-signed certificates in production. The gateway also becomes a single point for policy, logging and rate limiting. Validate server-supplied OAuth metadata before starting an auth flow; never accept endpoints blindly.
  3. Minimal token scope. Define scopes per tool, not only per server. A file-reading tool does not need deletion rights. CSA suggests access token lifetimes of about an hour or less, rotating refresh tokens on every use, and keeping tokens in a secrets manager rather than plaintext files or environment variables.
  4. Never run as root. Run each MCP server under a dedicated, least-privileged service account. Avoid personal access tokens with admin rights. If the agent has a shell, that shell inherits the process user's rights; root means the whole host.

On top of that, check permissions on every tool invocation, not just at session start, and require re-authorisation for high-privilege operations.

4. Isolate Risky Workloads

Not all MCP servers are equal. A server that only reads internal documentation is very different from one that runs shell commands or sends email. For the risky ones, CSA recommends:

  • Run each server in a container, micro-VM or restricted runtime, and enforce limits at the container or hypervisor layer, not through the server's own code.
  • Block filesystem access by default. Grant read-only access only to the paths the server's documented tools need.
  • Block outbound network access by default, allowing only approved endpoints. This limits the damage from tool poisoning, where hidden instructions in a tool description make the model leak data.
  • Apply CPU and memory quotas and hard timeouts per execution.
  • At the highest maturity level, use hardware-enforced boundaries (VMs) rather than containers alone.

Supply-chain risk is real too. CSA notes the postmark-mcp package that silently added a BCC recipient to outgoing email, and the rug pull pattern: an approved server that later changes its tool definitions without re-review. Pin versions and alert whenever a tool description changes.

5. Audit and Detection: What to Log

When an incident happens, the questions are always the same: which agent called which tool, with which parameters, when, and with what result. CSA recommends logging every invocation with:

  • the agent identity,
  • the tool name,
  • the parameters (with sensitive values redacted),
  • a timestamp,
  • the status, and
  • the duration.

Forward logs to a central SIEM and keep them for at least 90 days. Add anomaly detection for unusual call volumes, off-hours activity, unexpected source IPs, suspicious call sequences and injection-like parameters. At more advanced levels, the audit log should be append-only and isolated from the systems it monitors, so a compromised agent cannot erase its own tracks.

Anthropic's write-up on harnesses for long-running agents offers a useful extra lesson. There, each agent session keeps a progress file and makes git commits with descriptive messages, so the next session can reconstruct what was done and bad changes can be reverted. The agent can also only edit files in its working directory. The original goal was continuity of work, not security, but the pattern translates directly into auditability: confine the agent to one working directory, require every change to land in git, and you get a human-readable trail of every step it took.

Quick Checklist

  • Every MCP server is inventoried, with transport, bind address and owner.
  • No MCP endpoint listens on 0.0.0.0 without an authenticating gateway in front.
  • Docker ports are published to 127.0.0.1, not to every interface.
  • Tokens live in a secrets manager, scoped per tool, with short lifetimes.
  • No agent or MCP server process runs as root.
  • Risky servers run in separate containers/VMs with egress and filesystem locked down.
  • Every tool invocation is logged and shipped to central logging.
  • MCP package versions are pinned, and mcp-remote is on 0.1.16 or later.

Conclusion

MCP attack surface is rarely opened on purpose. It opens through convenient defaults, unrestricted Docker ports and overly broad tokens. The good news is that most of the fix is operational discipline sysadmins already know: bind to localhost, authenticate up front, grant the least privilege, isolate, and log thoroughly. Put it in place before your agent gets access to anything that matters.

References

Share Article