No credential forwarding

From RedHatProductSecurity/prodsec-skills · View interactive version

No credential forwarding is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. Prevent MCP servers from forwarding user credentials or tokens to downstream tools. Use when building, reviewing, or auditing MCP server integrations with external tools or APIs.

How to use this skill

Skill file

No Credential Forwarding in MCP Servers

Security Requirement

MCP servers MUST NOT forward any credentials or authentication tokens received from users to downstream tools or third-party APIs. This is explicitly forbidden by the MCP specification and has a high security impact.

Risks of Credential Forwarding

Required Approach

Instead of forwarding user tokens, MCP servers MUST obtain separate credentials for downstream services through one of:

  1. OAuth client flows: MCP server acts as an OAuth client and initiates its own OAuth flow to obtain tokens for third-party APIs
  2. Pre-registered service accounts: Use API keys or service accounts registered specifically for the MCP server
  3. Token Exchange (preferred): See the token-exchange-for-tools skill for the recommended approach

Implementation Checklist

Anti-Pattern

# FORBIDDEN - never do this
def call_external_tool(user_token, tool_url, params):
    headers = {"Authorization": f"Bearer {user_token}"}  # WRONG
    return requests.post(tool_url, headers=headers, json=params)

Correct Pattern

# CORRECT - use MCP server's own credentials
def call_external_tool(tool_url, params):
    server_token = get_server_credential_for(tool_url)
    headers = {"Authorization": f"Bearer {server_token}"}
    return requests.post(tool_url, headers=headers, json=params)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.