MCPSafe.io
RegistryThreatsMethodologyDocsPricingScanSign in
MCPSafe.io

Security checks for MCP servers — public packages and private repos, fast or deep.

Legal

Privacy PolicyCookie PolicyTerms of ServiceSecurity disclosure

Resources

State of MCP SecuritySupportSystem statusMade in Germany 🇩🇪

© 2026 MCPSafe. All rights reserved.

GDPR — Privacy Policy
← Threat Catalog

Configuration & Environment

Hardcoded cryptographic key

HIGHCWE: CWE-798Rule: MCP-232

MCP server passes a string-literal key to a cryptographic primitive (AES, HMAC, JWT signing, Fernet) — committed to source, the key is permanently compromised.

What it is

Once a cryptographic key lands in a git history, it must be considered public. Rotating requires re-issuing every artifact signed with the key, which most teams never finish. The right pattern is keys-from-environment (or a secret manager): the key never appears in the repo.

Why it matters for MCP

MCP servers ship as packages — published to npm or PyPI, installed by users, sometimes audited via package-scanning tools. A hardcoded key in such a package is broadcast to every install. The trust boundary is implicit but real: an MCP server's signing key should be unique per deployment, not shipped with the code.

Vulnerable example

example.py
1
import jwt
2
3
JWT_KEY = "my-super-secret-key-please-dont-leak"
4
5
def sign(claims: dict) -> str:
6
    return jwt.encode(claims, JWT_KEY, algorithm="HS256")

Secure example

example.py
1
import jwt
2
import os
3
4
JWT_KEY = os.environ["JWT_SIGNING_KEY"]
5
6
def sign(claims: dict) -> str:
7
    return jwt.encode(claims, JWT_KEY, algorithm="HS256")

How MCPSafe detects this

MCPSafe flags calls to `jwt.encode`, `Fernet(...)`, `hmac.new(...)`, `crypto.createHmac`, and similar cryptographic constructors where the key argument is a string literal. Calls reading from `os.environ`, `process.env`, or a secret-manager client are exempted.

See the full threat catalog for every documented detection.

Further reading

  • CWE-798: Use of Hard-coded Credentials
  • 12-Factor App: Config

Scan an MCP server for this issue

MCPSafe runs this check — and every other rule in the catalog — on any MCP server you paste in.

Scan now