MCP security — Hardening checklist
MCP Engineering course · M3
A printable checklist to harden an MCP server, and the host that uses it, before trusting it or publishing it. It follows lesson L14 and the official MCP security guidance (spec 2026-07-28). Go through each area, read the why, and check it off.
The course's mother rule: never trust the content that comes in. Every output from an MCP server is untrusted content until you decide otherwise. A local MCP server runs with your permissions: installing it is an act of trust that has to be earned.
Sources (supply chain)
- [ ] I install servers only from official, well-known sources, and the npm scope / source repository matches the vendor's docs. Why:
postmark-mcpwas an unofficial package impersonating Postmark; v1.0.16 secretly BCC'd emails. - [ ] I pin exact versions:
pkg@x.y.zfor npx (npx @modelcontextprotocol/inspector@2.16.0),mcp==2.3.0in Python. Why: "latest" can change under your feet; a pinned version doesn't mutate on its own. - [ ] I install from a lock file with hashes (
uv sync --locked,npm ci --ignore-scripts), and run Node tools withnpx --no-installor fromnode_modules/.bin. Why: the lock fixes every transitive dependency; no surprise download at launch. - [ ] I check provenance where available (
npm audit signatures). Why: it shows where a package was built (not that it is safe). - [ ] I review known CVEs: Inspector ≥ 2.16.0 (or 1.0.6);
mcp-remote≥ 0.1.16 (CVE-2025-6514, CVSS 9.6). Why: an already-documented vulnerability is a known risk.
Authorization (remote HTTP servers)
Authorization is optional in MCP; HTTP servers SHOULD follow the spec's OAuth 2.1 framework, and a server with private data or actions must not be left open.
- [ ] I publish Protected Resource Metadata (RFC 9728) and answer 401 with
resource_metadata. Why: clients discover how to authorize from it. - [ ] I accept only tokens whose audience is this server (RFC 8707
resource), and check signature, issuer and expiry. Why: a valid token for another service must not work here. (In mcp 2.3.0, setvalidate_token_resource=True.) - [ ] My clients use PKCE
S256and sendresourceto both/authorizeand/token. Why: PKCE stops code interception;resourcebinds the token to this server. - [ ] I never pass tokens through: upstream APIs get my server's own credential. Why: "MCP servers MUST NOT accept or transit any other tokens."
- [ ] Tokens travel only in the
Authorizationheader, never in query strings, and are short-lived and never logged. Why: URLs end up in logs, history and referrers. - [ ] Insufficient scope returns 403
insufficient_scope(step-up), with no omnibus scopes. Why: least privilege; clients can ask for more, with consent. - [ ] If my server is an OAuth proxy to a third party: per-client consent before forwarding, exact
redirect_urimatching,statestored only after consent. Why: that is the official defence against the confused deputy.
Secrets
- [ ] No API keys or tokens in client config JSON committed to a repo, in the repo itself, in tool arguments or in logs. Why: config files get shared and committed; logs get copied.
- [ ] Secrets come from environment variables or a secret manager;
.envis in.gitignoreand never committed. Why: one leaked file is a leaked credential, which you must then rotate. - [ ] I never mark secrets with
x-mcp-header. Why: intermediaries see header values.
Tools
- [ ] I apply least privilege: a few curated tools, not every endpoint; no destructive admin operations exposed. Why: if a tool is abused, the damage is confined to what it could do.
- [ ] I validate every input (schema plus code checks) and return bad input as
isError: true. Why: the spec says servers MUST validate all tool inputs; host consent does not make input valid. - [ ] I rate-limit tool invocations and set timeouts. Why: the spec requires rate limiting; a looping agent can hammer a server.
- [ ] I review tool descriptions for hidden instructions (tool poisoning) and re-review when definitions change (rug-pull). Why: the model reads descriptions as text; a definition can change after approval.
Transport
- [ ] On Streamable HTTP, I validate
Originon every request and return 403 if it is invalid. Why: the defence against DNS rebinding (a web page reaching your server). - [ ] Locally, I bind 127.0.0.1, never
0.0.0.0without authentication. Why:0.0.0.0exposes the server to the whole network. - [ ] Remote requests are authenticated and served over HTTPS. Why: the spec says servers SHOULD authenticate all connections.
- [ ] On stdio, stdout carries only MCP messages; logs go to stderr. Why: one stray print corrupts the stream.
Host and agent
- [ ] I do not auto-approve all tools; I pre-approve only specific, read-only tools from servers I trust. Why: annotations are untrusted hints; consent is the host's job.
- [ ] I do not run permission-bypass modes (e.g.
--dangerously-skip-permissions) with untrusted servers connected. Why: a poisoned result would then trigger actions without any human check. - [ ] I read the full launch command of a local server before adding it, and remove servers I no longer use. Why: a startup command can exfiltrate keys before any tool is called.
Content (the mother rule)
- [ ] I treat every server output as untrusted data, never as instructions. Why: that is exactly the prompt-injection vector.
- [ ] Logs and error messages never contain credentials, PII or internal details. Why: the spec forbids it for log messages; errors reach the model and the user.
To remember
- The threat classes (confused deputy, token passthrough, SSRF, local server compromise, DNS rebinding, tool poisoning, rug-pull, prompt injection, supply chain) come from the official guidance and documented incidents.
- Unsourced percentages that circulate about MCP servers are not evidence; this course does not use them.
- Least privilege + verified, pinned sources + no token passthrough are your foundation, and every output is untrusted content until you decide.
Turning Point Academy · MCP Engineering course · Module 3 · Lesson 14 (L14) · V2, spec 2026-07-28