Skip to content

AAK-MCP-003: MCP server environment exposes secrets

Severity
HIGH
Category
MCP Configuration (mcp-config)
Scanner
agent_audit_kit/scanners/mcp_config.py
Auto-fixable
No.
SARIF name
McpEnvExposesSecrets

What it detects

Hardcoded secrets found in mcpServers env block. Secrets in project-scoped MCP config are committed to git.

How to fix

Replace the literal value with a reference of the form ${NAME}, set NAME in your shell or secrets manager, and rotate the secret if it was ever committed.

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

agent-audit-kit scan . --rules AAK-MCP-003

Limitations

Reads the env block of each server in mcpServers, or servers in VS Code's .vscode/mcp.json, and flags a value that is not a bare ${VAR} when the variable name contains KEY, SECRET, TOKEN, PASSWORD, CREDENTIAL, ANTHROPIC, OPENAI or AWS_. A literal secret in headers (Authorization: Bearer ...) or inside a connection string under another name (DATABASE_URL=postgres://user:pass@host/db) is not matched. A value is taken for a setting or a dummy, and not reported, when it is under six characters, holds a ${...}, {{...}} or <...> reference or a placeholder word (your, change-me, placeholder, redacted, dummy, example, sample, _here, four x's), is under 40 characters and contains test, demo, password, 1234 or abcd, or sits under a name ending in _NAME, _ID or _TOKENS or containing TOKENIZER; so a short real password (DB_PASSWORD=Kq7#v) and a 32-character hex key that happens to contain abcd pass.

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-TOKEN-01 (Hardcoded MCP Secrets)

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-003.md: the page then shows that text, with the registry reference appended under it.