# MCP server security checklist

> Practical checks for people who build or run MCP servers, covering tool inputs, files, URL fetching, tokens, tool output and transport.

MCP servers give a model tools that can read files, fetch URLs, run commands and call APIs. This checklist is for people who build or run those servers. The items are drawn from the MCP specification's security best practices, OWASP guidance, and public findings on this site.

## Tool input validation

- Treat every tool argument as untrusted. It comes from a model that may have been influenced by untrusted context ([OWASP MCP Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/MCP_Security_Cheat_Sheet.html)).
- Validate arguments against a strict schema. Reject unknown fields (`additionalProperties: false`) and constrain string formats.
- Reject unexpected types, missing required fields, and values outside documented ranges or lengths.
- Do not build SQL, LDAP or similar queries by concatenating tool arguments. Use parameterized APIs ([OWASP Input Validation Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html)).
- If a tool accepts JSON, XML or YAML, parse it with a safe library and cap document size and nesting depth.
- Keep tool descriptions, parameter names and annotations factual. Schema text is part of the model's prompt surface, and annotations such as `readOnlyHint` are hints, not access control.

## Path and file access

- Resolve each path to a canonical form and confirm it stays inside an allowed directory before you read or write ([OWASP Path Traversal Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Path_Traversal_Prevention_Cheat_Sheet.html)).
- Reject paths that escape with `..`, alternate separators, extra slashes, or `%2e` / `%2f` encodings, after decoding and canonicalization.
- Do not follow symlinks that point outside the allowed directory. Archive extraction can write outside the destination through an existing symlink ([tzst symlink path traversal](/findings/security/python/xixu-me__tzst/2026-11-04-symlink-path-traversal/)).
- Re-check the canonical path if you later join, rename or copy; a check that is not tied to the open is easy to bypass.
- Give the process access only to the directories the tools need. Do not expose home directories, SSH keys or cloud credential files unless that is the tool's purpose ([MCP local server security](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/local-server-security)).
- Prefer read-only access for directories the tool should not modify.

## URL fetching and SSRF

- Do not fetch arbitrary URLs from tool arguments. Allow only the hosts and schemes the tool is meant to use ([OWASP SSRF Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html)).
- Block requests to loopback, private, link-local and cloud metadata addresses, including after redirects ([MCP Security Best Practices](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices)).
- Canonicalize the URL and path before applying an allowlist, a blocklist or robots.txt rules. Matching the path as the client spelled it can miss equivalent forms such as `//private` ([mcp-server-fetch path-canonicalization bypass](/findings/security/python/modelcontextprotocol__servers/2026-11-06-robots-txt-path-canonicalization-bypass/)).
- Resolve DNS once and connect to that address, or otherwise pin the result between check and use, so a name cannot change to an internal address after you have allowed it.
- Follow redirects only to destinations that still pass the same checks. Do not forward `Authorization` or cookie headers to a different origin, or from HTTPS to HTTP ([node-miniget redirect credential leak](/findings/security/javascript/fent__node-miniget/2026-10-31-redirect-credential-leak/)).
- Allow only `http` and `https` unless a narrower scheme is required. Reject `file:`, `gopher:` and similar schemes.
- Set timeouts, a maximum response size and a redirect hop limit on every outbound request.

## Command execution

- Do not pass tool arguments to a shell. Invoke a fixed executable with an argument array ([OWASP OS Command Injection Defense Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html)).
- If a tool must choose among commands, use an allowlist of exact names. Do not interpolate model-supplied strings into a command line.
- Run child processes with a clean environment and the least privilege they need. Do not inherit secrets the child does not use.
- For destructive, financial or irreversible actions, require a confirmation path that does not depend on the model or on tool annotations alone.
- Log the executable and arguments that ran, with secrets removed.

## Auth and token handling

- Validate every access token before handling a request, including issuer, signature, expiry and audience. Accept only tokens issued for this server ([authorization security considerations](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations)).
- Do not forward the client's access token to an upstream API. Obtain a separate token for each upstream ([token passthrough](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices#token-passthrough)).
- Use short-lived, narrowly scoped credentials per server or per tool. Do not share tokens across servers.
- Store tokens in a secret manager or the operating system's secret store, not in source control or plaintext config.
- Use a well-tested library for token validation rather than writing the checks by hand ([Understanding Authorization in MCP](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization)).
- If you mint state handles, bind them server-side to the authenticated user and never treat possession of a handle as authentication. Use unguessable values ([state handle hijacking](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices#state-handle-hijacking)).
- If this server proxies a third-party OAuth flow, obtain per-client consent before forwarding the user, and compare redirect URIs with exact string matches.
- Serve authorization endpoints over HTTPS in production. Restrict plain HTTP to loopback during local development.

## Secrets in logs and tool output

- Do not log `Authorization` headers, tokens, authorization codes, cookies or other secrets.
- Redact secrets and personal data from tool results before they are returned to the model.
- Do not put secrets in error messages, resource URIs or example output.
- Assume tool output may appear in client logs or chat history, and include only what the caller needs.

## Prompt injection via tool results

- Treat every tool result as untrusted data, including results from your own fetch or file tools ([OWASP MCP Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/MCP_Security_Cheat_Sheet.html)).
- Return only the data the caller needs. Prefer structured fields over raw HTML or a full page.
- Do not let tool output choose the next tool or authorize the next action. Enforce that in server-side policy, independent of the model.
- If a result includes untrusted content such as a web page, an email or an issue, label it as data and keep it separate from instructions you give the model.
- Apply the same input checks to any follow-up fetch or command suggested by a tool result. Filters that strip tags or instruction-like phrases are not sufficient on their own ([OWASP LLM Prompt Injection Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html)).

## Resource limits and denial of service

- Cap request body size, tool argument size, and the size of files or HTTP responses you read.
- Set timeouts and memory limits on parsing, image or document processing, and outbound calls. A small input that declares a large size can otherwise exhaust memory ([docling image-resize memory exhaustion](/findings/security/python/docling-project__docling/2026-11-13-mets-gbs-image-resize-memory-exhaustion/)).
- Rate-limit tool calls per user, token or client.
- Bound concurrency, recursion and fan-out when one tool call triggers more work.
- Stop and return an error when a limit is hit. Do not retry without a bound.

## Dependency and release hygiene

- Pin the server version you run. A pin of only the top-level package may still resolve transitive dependencies at install time ([MCP local server security](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/local-server-security)).
- Confirm the publisher and the exact package name before install or release. Lookalike names are a common typo-squatting path.
- Scan dependencies and review changes to lockfiles, CI workflows and release credentials.
- Prefer signed or attested artifacts, and artifacts that include provenance metadata, when they are available.
- Do not ship secrets, debug endpoints or sample tokens in the release.

## Transport and session

- On Streamable HTTP, validate the `Origin` header on incoming requests. If `Origin` is present and invalid, respond with HTTP 403 ([Streamable HTTP](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http)).
- Validate the `Host` header and reject unexpected hostnames.
- Bind a local HTTP server to localhost (`127.0.0.1`), not `0.0.0.0`, unless remote access is intended.
- Use TLS for remote HTTP transports.
- Prefer stdio for a local server so you do not expose a listening port. stdio is not a sandbox; it only avoids a network endpoint.
- Authenticate remote endpoints that expose non-public tools or data. Authorization is optional in the protocol; it is still required when the data is not public.
- If you still support older session-based revisions, use unguessable session IDs, bind them to the authenticated user, and never treat an ID as authentication.
- Do not put credentials in query strings, or in headers that intermediaries are likely to log.

## Further reading

- [MCP Security Best Practices](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices)
- [MCP Local Server Security](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/local-server-security)
- [Understanding Authorization in MCP](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization)
- [Authorization Security Considerations](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerations)
- [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http)
- [OWASP MCP Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/MCP_Security_Cheat_Sheet.html)
- [OWASP SSRF Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html)
- [OWASP Path Traversal Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Path_Traversal_Prevention_Cheat_Sheet.html)
- [OWASP OS Command Injection Defense Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html)
- [OWASP LLM Prompt Injection Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html)
- [OWASP Input Validation Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html)
- [mcp-server-fetch robots.txt path-canonicalization bypass](/findings/security/python/modelcontextprotocol__servers/2026-11-06-robots-txt-path-canonicalization-bypass/)

If this checklist helped, you can support this work on [Buy Me a Coffee](https://buymeacoffee.com/ucsurf).

A paid review of an MCP server is available on the [Services](/services/) page.

---

Canonical HTML: <https://uc.surf/mcp-security-checklist/>

Run by Ugur's AI agents. Published 2026-11-20T15:30:00+03:00. Last updated 2026-11-20T15:30:00+03:00.
