MCP Security

12 source-code rule IDs for MCP server security across TypeScript and Python handlers.

Usage

# Scan an MCP server file
kern review --mcp server.ts

# Auto-detect also works
kern review src/ --recursive

# JSON output for CI
kern review --mcp server.ts --json

Rules

All rules are mapped to CWE identifiers and the OWASP MCP Top 10.

RuleWhat it catchesCWEOWASP MCP
mcp-command-injectionexec/eval in tool handlers with user paramsCWE-77MCP04
mcp-path-traversalFile ops without path containmentCWE-22MCP03
mcp-tool-poisoningHidden instructions in tool descriptionsCWE-1427MCP02
mcp-secrets-exposureHardcoded keys/tokens + base64 obfuscationCWE-798MCP01
mcp-unsanitized-responseRaw external data in tool responsesCWE-1427MCP05
mcp-missing-validationTool params used without schema validationCWE-20MCP04
mcp-missing-authRemote HTTP/SSE server without authCWE-306MCP04
mcp-typosquattingPackage/server name similar to known MCP serversMCP06
mcp-data-injectionHidden injection markers in string literalsCWE-1427MCP02

Example

// Vulnerable MCP server
server.tool('run', 'Run command', {}, async (params) => {
  execSync(`${params.cmd}`);
});

// kern review output:
// ! mcp-command-injection: Shell command execution
//   in MCP tool handler [confidence: 0.95]
// ! mcp-ir-unguarded-effect: action "run" has
//   shell-exec effect without any guard [confidence: 0.90]

How it compares

KERN scans the code that makes the server dangerous. mcp-scan and Proximity check running servers. Use both.

Capabilitykern reviewmcp-scanProximity
Analysis typeStatic (source code)Dynamic (running server)Dynamic (running server)
LanguagesTypeScript + PythonAny (protocol-level)Any (protocol-level)
Prompt injectionYes (code + data)Yes (tool descriptions)Yes (tool descriptions)
Command injectionYes (taint + IR)NoNo
Path traversalYes (AST + IR)NoNo
Secrets detectionYes (pattern + base64)NoNo
Auth checksYes (middleware)NoNo
Structural analysisYes (KERN IR)NoNo
Requires running serverNoYesYes
Confidence scoringYes (0.70–0.95)NoNo

Coverage

Mapped to OWASP MCP Top 10 scenarios and generated-code review patterns for dangerous MCP server handlers.

  • Rules: command injection, path traversal, tool poisoning, SSRF, secret leakage, rug-pull detection, and missing auth.
  • Evidence: findings include rule ID, file, line, severity, and confidence.

See also