MCP Security

11 rules for MCP server security — 9 regex-based + 2 KERN IR structural rules. TypeScript and Python. Verified 9/9 against the appsecco vulnerable MCP servers lab.

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
mcp-ir-unguarded-effectKERN IR: action has effects without guardsstructural
mcp-ir-low-confidenceKERN IR: action confidence <= 0.3structural

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

Benchmark

Verified against the appsecco/vulnerable-mcp-servers-lab — 9 intentionally vulnerable MCP servers covering OWASP MCP Top 10 scenarios.

  • Score: 9/9 (8 direct hits + 1 indirect)
  • Indirect: outdated-packages — dependency scanning, not our domain
  • Tests: 75 test cases in packages/review-mcp/tests/

See also