Hackers Hijack Claude Code MCP Traffic For OAuth Tokens

Security researchers have discovered a critical vulnerability in Anthropic’s Claude Code Model Context Protocol (MCP) implementation that allows attackers to intercept unencrypted network traffic and steal OAuth authentication tokens. The flaw affects developers using Claude’s MCP servers for code integration, potentially exposing credentials for GitHub, GitLab, and other services. Organizations using Claude Code MCP should immediately audit their implementations, enforce encrypted connections, and rotate potentially compromised OAuth tokens.

Introduction

Anthropic’s Claude Code has rapidly gained adoption among developers seeking AI-assisted coding capabilities through its Model Context Protocol (MCP). However, a newly identified security vulnerability in MCP’s network communication layer has exposed a dangerous attack vector. Threat actors can perform man-in-the-middle (MITM) attacks against MCP traffic to harvest OAuth tokens, granting unauthorized access to connected development platforms and repositories.

The vulnerability stems from insufficient transport layer security in default MCP configurations, where sensitive authentication data traverses networks without mandatory encryption. This oversight creates opportunities for attackers positioned on the same network—whether through compromised Wi-Fi access points, malicious ISPs, or internal network infiltration—to capture authentication credentials in plaintext.

Background & Context

The Model Context Protocol serves as Claude’s bridge between AI capabilities and external development tools. MCP enables Claude to interact with version control systems, project management platforms, and continuous integration pipelines by maintaining persistent connections authenticated via OAuth tokens.

OAuth 2.0 tokens function as bearer credentials—possession alone grants access without requiring additional authentication. When developers configure Claude Code MCP servers, they typically authorize access to platforms like GitHub or GitLab, generating long-lived tokens that MCP stores and transmits during subsequent operations.

The security community has long emphasized transport encryption as fundamental protection for credential transmission. However, MCP’s initial design prioritized ease of implementation over security defaults. Unlike modern web APIs that enforce HTTPS, MCP servers could establish connections over unencrypted channels, leaving token exchanges vulnerable to interception.

This vulnerability represents a broader pattern in AI tool development, where rapid feature deployment sometimes outpaces security hardening. As organizations integrate AI assistants into sensitive development workflows, authentication security becomes critical to preventing supply chain compromises.

Technical Breakdown

The attack exploits weaknesses in MCP’s client-server communication protocol. When a developer initiates a Claude Code session, the MCP client establishes a connection to MCP servers hosting integrations. During this handshake, OAuth tokens are transmitted to authenticate the session.

In vulnerable configurations, this communication occurs over HTTP rather than HTTPS, or uses WebSocket connections without TLS encryption (ws:// instead of wss://). Attackers positioned to observe network traffic can capture these packets and extract OAuth tokens from the payload.

The attack sequence follows this pattern:

1. Developer initiates Claude Code MCP session
  • MCP client sends authentication request over unencrypted channel
  • Attacker intercepts traffic using packet sniffing tools
  • OAuth tokens extracted from captured packets
  • Attacker replays tokens to authenticate to target platforms

Common packet capture tools like Wireshark can easily identify these tokens. A basic filter to detect OAuth traffic might look like:

tcpdump -i any -A 'tcp port 80' | grep -i 'authorization: bearer'

For WebSocket traffic specifically:

tshark -i wlan0 -Y "websocket" -T fields -e websocket.payload

The tokens typically appear in HTTP headers or WebSocket frames as:

{
  "authorization": "Bearer ghp_xxxxxxxxxxxxxxxxxxxx",
  "x-oauth-token": "gho_xxxxxxxxxxxxxxxxxxxx"
}

Once captured, these tokens remain valid until expiration or revocation. GitHub personal access tokens, for example, often have no expiration by default, while OAuth app tokens may remain valid for 60 days or longer.

Attackers can then use stolen tokens directly via API calls:

curl -H "Authorization: Bearer ghp_stolen_token" \
  https://api.github.com/user/repos

This grants access to private repositories, enables malicious commits, and potentially allows attackers to inject backdoors into codebases.

Impact & Risk Assessment

The consequences of OAuth token theft through MCP traffic interception extend beyond individual account compromise. Development tokens typically carry extensive permissions across organizational resources, making them high-value targets for sophisticated threat actors.

Severity: High to Critical

Organizations face multiple risk vectors:

Supply Chain Compromise: Stolen tokens with repository write access enable attackers to inject malicious code into software projects. This represents a critical supply chain attack vector, potentially affecting downstream users of compromised software.

Intellectual Property Theft: Repository access tokens grant visibility into proprietary source code, algorithms, and business logic. Competitors or nation-state actors could exfiltrate years of development work.

Lateral Movement: Development platform tokens often provide access to CI/CD pipelines, cloud deployment credentials, and infrastructure-as-code repositories. Attackers leverage these to expand access across cloud environments.

Persistence: Long-lived tokens enable attackers to maintain access even after initial compromise discovery. Without comprehensive token rotation, organizations may fail to fully remediate breaches.

Vulnerable populations include:

  • Developers using public Wi-Fi without VPNs
  • Organizations with compromised internal networks
  • Users on ISP networks with malicious traffic inspection
  • Enterprise environments with insufficient network segmentation

The attack requires no user interaction beyond normal MCP usage, increasing exploitation risk. Any attacker with network position between the developer and MCP servers can execute this attack.

Vendor Response

Anthropic has acknowledged the security concerns surrounding MCP transport security. The company has issued updated documentation emphasizing encrypted connection requirements and released patches to enforce TLS in newer MCP server implementations.

According to security advisories, Anthropic recommends:

  • Immediate transition to HTTPS/WSS for all MCP connections
  • Implementation of certificate pinning for MCP clients
  • Regular OAuth token rotation policies
  • Network-level monitoring for unencrypted MCP traffic

The vendor has committed to making encrypted transport mandatory in upcoming releases, eliminating the option for unencrypted configurations. Additionally, Anthropic is developing enhanced token management features including automatic token rotation and scope-limited credentials.

Organizations using official Anthropic MCP servers should update to the latest versions immediately. Third-party MCP server implementations require individual assessment and patching by their respective maintainers.

Mitigations & Workarounds

Organizations should implement layered defenses to protect against MCP traffic interception:

Enforce Encrypted Transport

Configure all MCP servers to require TLS 1.3 or higher. Update connection strings from http:// to https:// and ws:// to wss://:

{
  "mcpServers": {
    "github": {
      "url": "wss://secure-mcp.example.com",
      "strictSSL": true
    }
  }
}

Rotate Compromised Tokens

Immediately revoke and regenerate all OAuth tokens potentially exposed through unencrypted MCP connections:

# GitHub token revocation
gh auth token | xargs -I {} curl -X DELETE \
  -H "Authorization: Bearer {}" \
  https://api.github.com/applications/{client_id}/token

Implement VPN Requirements

Mandate VPN usage for all development activities, particularly when accessing MCP services from untrusted networks. This adds an encryption layer regardless of application-level security.

Network Segmentation

Isolate development networks from general corporate traffic to reduce attacker positioning opportunities.

Token Scope Limitation

Generate OAuth tokens with minimum required permissions. Avoid full repository access when read-only or specific repository tokens suffice.

Detection & Monitoring

Security teams should deploy monitoring to identify potential exploitation:

Network Traffic Analysis

Monitor for unencrypted HTTP/WS traffic containing OAuth patterns:

# Suricata rule for OAuth token detection
alert http any any -> any any (msg:"Potential OAuth Token Leak"; \
  content:"authorization"; nocase; content:"bearer"; nocase; \
  classtype:credential-theft; sid:1000001; rev:1;)

Token Usage Anomalies

Implement GitHub/GitLab webhook monitoring for unusual API activity:

# Monitor for token usage from unexpected IPs
def check_token_usage(event):
    if event['ip_address'] not in KNOWN_IPS:
        alert(f"Token used from unexpected IP: {event['ip_address']}")

Certificate Validation Failures

Log and alert on SSL/TLS validation errors that might indicate downgrade attacks:

# Monitor system logs for certificate errors
journalctl -u claude-mcp | grep -i "certificate\|ssl\|tls"

Audit Log Review

Regularly review platform audit logs for unauthorized repository access, unexpected commits, or permission changes.

Best Practices

Development organizations should adopt comprehensive security practices around AI-assisted coding tools:

Security-First Configuration: Default to maximum security settings rather than convenience. Require explicit configuration to reduce security posture.

Regular Security Audits: Periodically review MCP server configurations, connected services, and token permissions.

Token Lifecycle Management: Implement automated token rotation policies with maximum validity periods of 30-90 days.

Developer Training: Educate development teams about OAuth token security, proper MCP configuration, and recognizing potential compromises.

Zero Trust Networking: Assume network compromise and require end-to-end encryption for all development tool communications.

Credential Scanning: Deploy tools to detect accidentally committed tokens in repositories, CI/CD logs, or configuration files.

Incident Response Planning: Develop specific procedures for responding to OAuth token compromises, including rapid revocation workflows.

Key Takeaways

  • Claude Code MCP’s default configuration allows unencrypted transmission of OAuth tokens, creating interception opportunities for network attackers
  • Stolen OAuth tokens grant extensive access to development platforms, enabling supply chain attacks and intellectual property theft
  • Organizations must immediately enforce encrypted transport (HTTPS/WSS) for all MCP connections
  • All potentially exposed OAuth tokens should be revoked and regenerated as a precautionary measure
  • Comprehensive monitoring for token misuse and network anomalies provides early compromise detection
  • The vulnerability highlights broader security challenges in rapidly deployed AI development tools

References

  • Anthropic Model Context Protocol Documentation
  • OAuth 2.0 Security Best Current Practice (RFC 8252)
  • GitHub Personal Access Token Security Guidelines
  • OWASP API Security Top 10 – Broken Authentication
  • NIST SP 800-63B Digital Identity Guidelines

Stay updated at https://cydhaal.com — Your Daily Dose of Cyber Intelligence.
📧 Subscribe to our newsletter at https://cydhaal.com/newsletter/


Leave a Reply

Your email address will not be published. Required fields are marked *

📢 Join Telegram