CIDADAXSEC
← All topics
Expert

MCP server vulnerabilities

MCP server vulnerabilities come from over-exposed tools, skipped access checks, fail-open authentication, and unrestricted dynamic client registration.

Material

The Model Context Protocol gives applications a standard way to expose tools, data sources, and external services to an LLM. The server process is trusted by the agent, so a flaw in a tool reaches further than a typical web bug.

How it works

The client negotiates capabilities during initialize, then lists tools with tools/list. Calls arrive as JSON-RPC requests carrying a tool name and arguments. Validating names, argument shapes, and permissions is the server job.

MCP servers often run next to the model, sometimes as a local process or inside a private network. A single careless tool can therefore read files, call internal APIs, or run commands on a host that exposes far more than the chat window suggests.

yaml
mcpServers:
  reports:
    command: npx
    args:
      - "-y"
      - "@modelcontextprotocol/server-filesystem"
      - "/srv/reports"
    env:
      API_TOKEN: "${MCP_TOKEN}"
http
POST /mcp HTTP/1.1
Host: mcp.example
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9
Content-Type: application/json

{"jsonrpc":"2.0","id":7,"method":"tools/call",
 "params":{"name":"read_file","arguments":{"path":"/etc/passwd"}}}

Attack shapes

  • SQL injection inside a tool that concatenates arguments into a database query.
  • Missing per-tool authorization, so a low-privileged user can call an administrative tool.
  • Fail-open authentication, where the server accepts a session that skipped token validation.
  • Dynamic client registration that accepts wildcard redirect URIs and sends the authorization code to the attacker.
  • SSRF through a tool argument that becomes a server-side URL, reaching loopback or link-local services.

Preventing it

  • Keep a strict allowlist of tools and argument schemas, and reject anything that does not match.
  • Require authentication and check the caller role before every tool call, not only when listing tools.
  • Run the server with minimal privileges, without shell access and with outbound traffic restricted.
  • Guard URL arguments against SSRF by resolving them and refusing loopback, private, and link-local addresses.
  • Lock down dynamic client registration with a fixed redirect URI list and verified client identifiers.
http
POST /mcp HTTP/1.1
Host: mcp.example
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/list"}
Note: hiding a tool from tools/list is cosmetic. Authorization must be enforced inside the server on every invocation, because the name is guessable either way.

Labs in this topic

Labs run on a domain separate from this site, so a payload cannot reach your account session.

Labs for this category land in Phase 2. The material is readable now.

Challenges in this category

Challenges from the PortSwigger Web Security Academy. The original labs run on PortSwigger domains, so the link opens there.