Server Implementation
API keys, OAuth tokens, database passwords, or private keys are hardcoded in the package's source or configuration files, so installing the server installs the credential too. Scoped to source files; the same shape inside `.env` files is covered by MCP-210.
A secret checked into git is a secret published to the world. The attack is as simple as `git clone` and `grep`. Removing the secret later does not fix it because the value lives on in history, in every fork, and in every mirror. The canonical shapes are `AKIAβ¦` AWS keys, `ghp_β¦` GitHub PATs, `sk_live_β¦` Stripe keys, `xox[bap]-β¦` Slack tokens, and PEM-formatted private keys.
MCP servers frequently need credentials to talk to backend APIs β GitHub, Slack, databases, cloud providers. Authors reach for the easiest option (drop the key in a constant, or in a `.env.example` that somehow became `.env`) because it works during development. When the repo is made public or installed by another user, the credential goes with it, granting whoever installed the package access to the author's real accounts.
# config.py β committed to the public repo |
STRIPE_SECRET = "sk_live_4eC39HqLyjWDarjtT1zdp7dc" |
AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" |
GITHUB_TOKEN = "ghp_abcdef1234567890abcdef1234567890abcd" |
# config.py β reads from environment; nothing sensitive at rest in the repo. |
import os |
STRIPE_SECRET = os.environ["STRIPE_SECRET"] |
AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"] |
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] |
# In production, load these from a secrets manager (AWS SSM, Vault, 1Password |
# Connect, etc.) and rotate aggressively. Never commit an .env with real values. |
We match canonical credential prefixes (AWS `AKIA`, GitHub `ghp_`/`gho_`, Stripe `sk_live_`, Slack `xox[bap]-`, Google `AIza`), PEM private-key headers, and high-entropy base64 assigned to variables named `api_key`, `secret`, `token`, or `password`. Common placeholder values (`xxx`, `changeme`, `your-key`, `<REDACTED>`) are excluded to keep the false-positive rate low.
See the full threat catalog for every documented detection.
MCPSafe runs this check β and every other rule in the catalog β on any MCP server you paste in.
Scan now