part…
Building governance for MCP?
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
The gateway applies what the guide teaches: policies on discovery, invocation and authorisation.
A gateway concentrates tokens, catalogues and traffic from many hosts and servers: it is a high-value target. This lesson walks through the vectors that affect it directly and the mitigation the spec requires or recommends.
| Vector | How it affects the gateway | Mitigation |
|---|---|---|
| SSRF via OAuth discovery | A malicious server makes you visit cloud metadata endpoints or internal services while resolving PRM/AS/CIMD. | Mandatory HTTPS, blocking of private ranges with proven libraries, no following redirects to internal addresses, egress proxy, DNS pinning (10.2). |
| DNS rebinding | If you expose a local endpoint or are reachable from browsers. | Validate Origin (403), bind to localhost locally, authentication (6.2). |
| Prompt injection via catalogue/results/instructions | You forward text from servers to the hosts' models. | Treat it as untrusted; filters; pin definitions and re-approve; flag instructions. |
Abuse of x-mcp-header |
Routing by headers that do not match the body, or sensitive parameters exposed to intermediaries. | Validate header vs body if you process the body; require a version that guarantees it; reject invalid annotations; do not route by sensitive parameters. |
Tampered requestState |
A compromised host alters a server's opaque state. | It is not yours: forward it intact; the server provides the integrity. Your own translation state must be signed/encrypted with principal, TTL and digest. |
| State handle hijacking | Server handles or your translation handles reused by another principal. | Bind to the sub; never treat as authentication; high entropy and expiry. |
| Malicious JSON Schemas (DoS) | You validate thousands of third-party schemas. | Depth, sub-schema and time limits; no network $ref (3.6). |
| Icons and SVG | You re-expose icons to hosts. | Sanitise or remove; never with credentials; same origin (3.5). |
| Elicitation URLs | You pass server URLs to users. | Allowed schemes, domain allow-list, no PII in the URL, Punycode, show in full (8.1). |
Improper public cache |
You share between users results that depended on the token. | private when you filter by user; cacheScope never laxer than the original (7.5). |
| Errors that leak information | Error messages with internal paths, versions, addresses. | Normalise errors towards hosts; details only in the audit trail. |
| Token passthrough / confused deputy | Reusing the host's token towards servers; OAuth proxies with a static client_id. |
Token broker per server; per-client consent (9.8, 10.2). |
| Mix-up | A malicious server's AS tries to capture codes from another AS. | iss validation (9.4). |
| Local servers launched by the gateway | Code execution with your privileges. | Container, no mounts, no network, per-server credentials, consent with the exact command (10.4). |
| Open subscriptions and streams | Connection exhaustion; streams that never close. | Per-host and per-server limits; keep-alive; timeouts; backoff on reconnect. |
| MRTR loops / tool loops | Servers that request input indefinitely; sampling loops with tools. | Round and iteration limits; token budget. |
| Abusive scope elevation | A server requests broad scopes on every challenge. | Maximum-scope policies per server; logging; controlled union. |
| The gateway's own dependencies | Supply chain. | Pinning, SBOM, signatures, rapid updates in response to MCP SDK advisories. |
Each vector with: control implemented, test that verifies it, owner, review date. Review the list with every protocol revision and with every security SEP.
1. Who guarantees the integrity of requestState when it passes through the gateway?
The gateway forwards it intact; it must, however, protect its own translation state.
2. What must the gateway do with a server error message that contains internal paths?
It prevents information leakage towards hosts and models.