Security: The Confused Deputy Problem in MCP Proxies

RoadmapsAI Engineering

Overview

A vulnerability where an MCP proxy server with valid credentials to a third-party API is tricked into misusing those credentials on behalf of a malicious or unauthorized client.

Because relying solely on a third-party API's one-time consent cookie and a static client ID allows attackers to bypass authorization screens and hijack the proxy's privileges.

Where used: Enterprise MCP proxies, OAuth integration layers, Multi-tenant agent architectures

Why learn this

Code walkthrough

def handle_auth_secure(request):
    client_id = request.query.client_id
    
    # The proxy enforces its OWN consent boundary per-client
    if not has_user_consented(user_id=request.user.id, client_id=client_id):
        return render_proxy_consent_screen(client_id)
    
    # Only forward to the third-party AFTER the proxy validates consent
    return redirect(
        f'https://oauth.example.com/auth'
        f'?client_id={STATIC_CLIENT_ID}'
        f'&redirect_uri={request.query.redirect_uri}'
    )

Focus: Notice how the secure version blocks the forwarding until the user explicitly consents to the *specific* requesting client.

Common mistakes

Recall questions

Understanding checks

A security team audits an MCP proxy and ensures that all tool descriptions are sanitized and no prompt instructions can be injected into the LLM context. Does this secure the proxy against confused deputy attacks?

No. Sanitizing tool outputs prevents tool poisoning, but it does nothing to fix authorization boundary flaws. If the proxy still uses a static client ID without per-client consent tracking, it is still vulnerable to confused deputy attacks.

Confused deputy is about who the proxy authorizes with its credentials, not what content it feeds back to the LLM.

A proxy uses a static client ID and the user's browser holds a consent cookie from yesterday. An attacker sends the user to the third-party authorization endpoint with a malicious `redirect_uri`. Will the user see a warning screen?

No. The third-party server sees the valid cookie and assumes consent was already granted, silently redirecting the authorization code to the attacker's URI.

The third-party server cannot distinguish between the proxy making a legitimate request and the attacker piggybacking on the existing session unless the proxy enforces per-client consent.

Practice tasks

Trace the Attack Flow

Explain how a static client ID and a consent cookie combine to bypass the OAuth consent screen in a confused deputy attack.

Continue learning

Previous: Security: MCP Tool Poisoning and Schema Attacks

Return to AI Engineering Roadmap