What is Dependency Confusion (MCP)?

2 min read Updated

An attack where an AI agent resolves an MCP server name to a malicious package instead of the intended one, mirroring the dependency confusion attacks seen in npm, PyPI, and other package ecosystems.

WHY IT MATTERS

Dependency confusion exploits the gap between a name and what it resolves to. In traditional software, attackers publish malicious packages with the same name as internal libraries to public registries — the build system fetches the attacker's version instead. The same class of attack applies to MCP server resolution.

When an MCP client configuration references a server by name, the resolution process determines which binary, container, or endpoint actually handles traffic. If an attacker publishes a malicious MCP server package with the same name as a legitimate internal one — or a near-identical typosquatted name — agents may connect to the wrong server entirely. Every tool call then goes to an attacker-controlled endpoint.

The consequences are severe: the malicious server can return poisoned data, capture sensitive arguments (credentials, file paths, database queries), or manipulate tool responses to steer agent behaviour. Unlike traditional dependency confusion where the damage is at build time, MCP dependency confusion is at runtime — every agent session is compromised.

This is particularly dangerous because MCP server configurations are often shared across teams via config files, dotfiles, or documentation. A single poisoned server reference propagates to every developer who copies the configuration.

HOW POLICYLAYER USES THIS

Intercept mitigates dependency confusion by acting as the single enforcement point between client and server. Because all MCP traffic routes through Intercept, policies can pin specific server identifiers, restrict which servers are permitted, and enforce allowlists of known-good MCP server endpoints. Even if an agent's configuration is manipulated to reference a malicious server, Intercept's policy denies connections to any server not explicitly listed. The audit trail also surfaces unexpected server connections for investigation.

FREQUENTLY ASKED QUESTIONS

How does MCP dependency confusion differ from traditional dependency confusion?
Traditional dependency confusion happens at build time via package managers. MCP dependency confusion happens at runtime — the agent connects to a malicious server during operation, meaning every tool call in the session is compromised rather than a single build artefact.
Can I prevent dependency confusion without a proxy like Intercept?
You can manually verify server configurations, but this does not scale across teams and environments. A proxy-based approach enforces server allowlists centrally, preventing any client from connecting to an unapproved MCP server regardless of local configuration.
What about typosquatting MCP server names?
Typosquatting is a common vector. Intercept's server allowlist approach prevents this entirely — only explicitly named and approved servers are reachable, so a typo in a configuration file results in a denied connection rather than a connection to an attacker.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.