Skip to content

AAK-MCP-ENV-DUMP-001: An MCP tool returns the whole process environment to the client

Severity
HIGH
Category
Secret Exposure (secret-exposure)
Scanner
agent_audit_kit/scanners/mcp_server_code.py
Auto-fixable
No.
SARIF name
McpToolEnvironmentDump

What it detects

A tool handler returns the whole environment (dict(os.environ), os.environ.copy(), {**os.environ}, process.env, {...process.env}, JSON.stringify(process.env)), so every API key and token in the server's environment is one tool call from the model, with no prompt injection needed. A read-only annotation makes it worse, since hosts auto-approve those. The rule also reads an MCP config that launches @modelcontextprotocol/server-everything at a stated release below 2.1.0 or on its date line, or with GET_ENV_INCLUDE_SECRETS set: its get-env tool returned the full environment until 2.1.0 masked credential-like values by default. A handler that returns one named variable does not fire.

How to fix

Return the named variables the tool needs, or a filtered copy with secrets masked. Treat server-everything as a demo: leave it out of a real config, or use 2.1.0 or later without GET_ENV_INCLUDE_SECRETS.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-MCP-ENV-DUMP-001

Limitations

Python: a function decorated @<name>.tool(...) or @<name>.call_tool(...) whose own return holds os.environ whole, directly or through a local assigned from it; a helper it calls is not followed, and neither is a filtered copy, which may still hold secrets. TypeScript and JavaScript: a file that registers a tool and holds JSON.stringify(process.env) or returns process.env whole within 120 characters on one line, read by pattern and not tied to the handler. The config half reads .mcp.json, mcp.json, claude_desktop_config.json and *.mcp.json, leaves out configs below a tests, fixtures, examples, samples or demo directory, and does not report an unpinned launch, which gets latest, though a launcher's cache may still hold an older release. A source file over 512 KB or a config over 1 MB is not read.

References

  • OWASP MCP Top 10: MCP01:2025 (Token Mismanagement & Secret Exposure)
  • OWASP Agentic Top 10: ASI03 (Identity and Privilege Abuse)
  • Adversa AI MCP Top 25 (AAK-defined ids): ADV-AUTH-01 (Missing Authentication)

All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-MCP-ENV-DUMP-001.md: the page then shows that text, with the registry reference appended under it.