MCP audit rule · v0.1.0
Secret in env block
Config files get committed, synced and shared; a plaintext credential here leaks with them.
- each server checks
- 3 test fixtures
critical secret-in-env
Flagged
4 "command": "npx",
5 "env": {
6 > "GITHUB_TOKEN": "ghp_••••0000"
7 }
8 }Fix
Pass the variable through from the environment instead, e.g. "GITHUB_TOKEN": "${env:GITHUB_TOKEN}" (VS Code) or the client's env passthrough, and rotate the exposed key.
Fine
{
"mcpServers": {
"s": {
"command": "npx",
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}