Securing MCP beyond the gateway: InfoQ's four control layers, decoded
A decode of InfoQ's four-layer MCP security model (CI exec gates, isolated tooling, egress limits, manifest pinning) for teams running MCP servers.
Picture a platform engineer at a 40-person SaaS company who has wired four MCP servers into an internal ops agent: GitHub, Postgres, a homegrown web-fetch tool, and a third-party server someone on the team found and liked. She put a gateway with OAuth in front of all of it, wrote the audit logs to the SIEM and moved on. The gateway does its job. It knows who called which tool. It does not notice when the web-fetch tool is handed a URL pointing at an internal service, or when the third-party server quietly rewrites a tool description three weeks after she approved it. It also doesn't cover the MCP inspector she left running on the office network last sprint.
That gap is the subject of Securing MCP in Production: Defense-in-Depth beyond the Gateway, published by InfoQ on July 29, 2026. @bibryam's post credits it to Nik Kale and boils it down to CI gates for tool execution, isolated tooling with scoped tokens, and diff-based manifest reviews. The author's argument is that a gateway is one enforcement point, not a control plane.
What it is
The article isn't a product. It's an architecture write-up from a team that, the author says, chose MCP as the integration layer for a production multi-agent platform at the end of 2025. It splits MCP security into four layers, each with its own "earliest trustworthy enforcement point." The author says every pattern works with the current MCP spec and needs no protocol changes. Mapped to the lede:
- Execution. A tool handler must treat its arguments as data. The author counts 13 of the roughly 30 CVEs reported against MCP deployments in the first sixty days of 2026 as unvalidated input reaching a shell or
eval(). Primary control: pass arguments as arrays, never as interpolated shell strings. Secondary: a CI gate that flagsexec,eval,os.systemandsubprocess(shell=True)reachable from a handler. Cost, per the article: minimal. - Management infrastructure. Inspectors, test harnesses, registration surfaces and admin consoles. The article cites CVE-2026-23744 in MCPJam Inspector, an unauthenticated endpoint that allowed installing arbitrary MCP servers and listened on 0.0.0.0 by default, and CVE-2026-23523 in Dive MCP Host, where crafted deep links installed malicious configurations. The control is mandatory authentication on every management endpoint, plus network isolation of dev tooling. The author says their own test harness was listening unauthenticated on an internal network, and that shutting it down took twenty minutes.
- Outbound trust boundary. This is the web-fetch problem. The article cites CVE-2026-26118, which it describes as a CVSS 8.8 SSRF in the Azure MCP Server that leaked managed identity tokens and was patched by Microsoft on March 10. The control is an egress allow-list at the network layer and scoped identity tokens, one credential class per tool purpose.
- Semantic integrity. This is the rug pull: approved tool definitions changing later. The control is manifest pinning at registration with SHA-256 canonicalization, reviewed as a diff rather than a binary allow or deny, backed by behavioral baselines on endpoint access, data movement and latency.
The author says the gateway takes part in only two of the four layers, and only partially.
Alternatives and complements named in the sources:
- Invariant Labs' open-source mcp-scan, which according to DEV Community scans installed servers for poisoned descriptions and pins a hash of each description to flag later changes. It covers part of layer 4 only.
- AgentBeam's scanner, which explainx.ai says runs 11 heuristic patterns plus version-pin verification. By its own documentation it is not semantic malware analysis.
- Bifrost, Maxim AI's open-source gateway, which Maxim describes as scoping MCP tools to virtual keys with deny-by-default semantics. That strengthens the gateway layer but, by the article's argument, doesn't replace the other three.
Who it's for
Pick this up if you run MCP servers that hold real credentials or reach real networks: cloud identities, internal APIs, databases, anything an SSRF could reach. It also fits if you install third-party servers that can update after you approve them, or if your team already has a gateway and is wondering what it misses. The four-row matrix in the article works as a review checklist.
Skip it, for now, if you run a couple of local stdio servers on your own laptop with no secrets beyond your own environment. Scalar notes that MCP authorization applies to HTTP transports and that stdio servers should read credentials from the environment instead. Layer 1 hygiene still applies to code you write, but egress allow-lists and behavioral baselines are overhead you probably won't recoup.
Before and after
Before:
- Approve a server once, at install.
- Put a gateway in front for authentication and audit.
- Give the server whatever cloud identity makes it work.
- Leave the inspector and test harness on their defaults.
- Find out about a changed tool definition when something breaks.
After, following the article:
- A Semgrep rule in CI blocks builds where a handler parameter reaches a shell or
eval. - Every management endpoint requires authentication, and dev tooling sits on an isolated network.
- Each server gets a network egress allow-list and a token scoped to one purpose.
- Tool manifests are hashed at registration. Any change produces a diff someone reviews before the agent loads it.
- The gateway keeps doing authentication, authorization and audit.
For step 3, the authorization sources fill in the token side. Scalekit's guide to the 2026-07-28 spec says a server should accept only tokens issued for its own URL and never pass a client's token through to upstream APIs. Maxim points out that spec scopes are server-defined strings and the spec does not define which caller may run which tool.
Try it
The smallest real step is the article's execution fix and CI rule. Here is the vulnerable pattern and its fix, as the article shows them:
// VULNERABLE: string interpolation into a shell command
const { username } = toolCall.params;
exec(`docker run maigret ${username}`);
// If username is "; rm -rf /" the shell interprets the semicolon.
// FIXED: array-based argument passing, no shell interpretation
const { username } = toolCall.params;
execFile('docker', ['run', 'maigret', username]);
// Semicolons and metacharacters are passed as literal values.
And the Semgrep rule the author uses to block builds:
rules:
- id: mcp-unsafe-exec-js
languages: [javascript, typescript]
severity: ERROR
message: >
MCP tool handler passes a parameter into a shell interpreter.
Use execFile or spawn with array arguments instead.
pattern-either:
- pattern: exec(`...${$PARAM}...`)
- pattern: exec($CMD + $PARAM)
- pattern: eval($PARAM)
- id: mcp-unsafe-exec-py
languages: [python]
severity: ERROR
pattern-either:
- pattern: subprocess.run(..., shell=True, ...)
- pattern: os.system($CMD)
- pattern: eval($PARAM)
The article doesn't give Semgrep install or CI wiring steps, versions or prerequisites, so plug it into whatever runner you already use. The author calls these rules a starting point that catches common sinks, not full production coverage.
For layer 4, DEV Community describes a staging test you can run today. Approve a clean test tool, record which tools your agent calls and with what arguments, then swap in a poisoned definition under the same name. Check whether the agent's behavior changes and whether anything in your pipeline flags the change. The post names mcp-scan but gives no install command. None of the sources discuss cost for any of this.
Where it breaks
- Layer 4 is expensive. The article rates it high cost: legitimate upgrades need re-approval, and behavioral baselines need two to three weeks of traffic to stabilize.
- Egress lists need upkeep. The article says per-server allow-lists need maintenance and will break servers that need new external endpoints.
- Security middleware is attack surface too. DailyCVE reports an SSRF bypass in mcp-sanitizer v1.3.3 (October 2026). A URL with an explicit port, such as
http://localhost:8080/, skipped the localhost check, and bracketed IPv6 loopback and link-local addresses slipped past string comparisons. That's an argument for enforcing egress at the network layer, as the article recommends, rather than only in application code. - Scanners say less than they seem to. explainx.ai says scanners produce false positives and miss obfuscated instructions. They also can't see toxic flows, where harmless tools chain into a harmful sequence. A clean scan means "no known pattern matched," not safe.
- Single-source numbers. The figure of over thirty CVEs in sixty days is the author's count. The Adversa AI scan figures the article cites (38% of 500+ servers with no authentication on critical endpoints, 43% vulnerable to command execution) appear only in the InfoQ piece. We found no independent coverage of the article itself.
- Unconfirmed CVE details. We couldn't locate Microsoft's own advisory for CVE-2026-26118. Affected versions and fix details are unconfirmed beyond the article's description and its March 10 patch date.
- The spec may not help. The authorization sources describe the 2026-07-28 revision's OAuth changes. Whether the spec addresses signing or pinning tool manifests is unconfirmed. The author's own line is that the spec will catch up and production can't wait.
Sources
- Securing MCP in Production: Defense-in-Depth beyond the Gateway · InfoQ
- What is an MCP rug pull attack? · DEV Community
- mcp-sanitizer, Server-Side Request Forgery (SSRF), VULN-001 (High) -DC-Oct2026-3911 - DailyCVE · DailyCVE
- MCP OAuth: How MCP Authentication Works (2026) — Scalar · Scalar
- What Is an MCP Rug Pull? Tool Poisoning + Scanner Guide | explainx.ai Blog · explainx.ai
- MCP Authorization: OAuth Scopes and Per-Tool Permissions · Maxim Articles
- MCP authorization guide: OAuth 2.1, resource metadata, CIMD and DCR · Scalekit Docs
- @bibryam: Nik Kale on operational MCP security: · @bibryam