Repository navigation
v0.1.0 — Foundation Pillar 8
mcp-stdio-shellguard v0.1.0
Defense-in-depth bundle for MCP stdio servers. Closes the unsanitized child_process.exec / spawn shell-injection class reported in the Ox-Security MCP audit (200k servers exposed) and the LiteLLM CVE-2025-69256 (patched in v1.83.7).
Install
npm install mcp-stdio-shellguardOr run the audit CLI directly without installing:
npx -y -p mcp-stdio-shellguard mcp-shellguard-audit scan ./srcWhat you get
Three layers, opt-in piecewise:
- Library API — drop-in
guardExec/guardSpawnyou call from your own MCP server. Default-deny allowlist, three sandbox profiles (strict / standard / permissive), SHA-256 replay detection over canonicalised(executable, args, cwd, envSubset), trust-tier derivation (LOW/MEDIUM/HIGH/CRITICAL). - Audit CLI —
mcp-shellguard-audit scan <path>walks the AST and reports 12 anti-patterns (LOW/MEDIUM/HIGH/CRITICAL). Outputs markdown, JSON or SARIF 2.1.0. CI gate via--severity-floor. - Reference MCP server — 8 tools with honest
readOnlyHint/destructiveHintannotations so the MCP Inspector / Claude Desktop can drive the bundle.
Suite
| Suite | Purpose |
|---|---|
guard_exec / guard_spawn |
Defended child_process.exec / spawn |
register_allowlist |
Per-tool allowlist with regex args |
audit_source |
AST scan for 12 shell-injection anti-patterns |
audit_report |
Markdown / JSON / SARIF 2.1.0 output |
replay_check |
Canonical SHA-256 + sliding window |
sandbox_status |
Active limits + cgroup-v2 flag |
trust_tier |
LOW/MEDIUM/HIGH/CRITICAL derivation |
Round 2 cold-cross-hardening
Two cold-cross reviewers ran before promotion and flagged 3 HIGH bypass classes; all are closed in v0.1.0:
- Allowlist-Regex Unicode bypass — NFKC + zero-width-strip before
argsRegex.test()so attackers can't substitute fullwidth chars or append zero-width joiners past^log$-style patterns. - Replay-Window Unicode bypass — same normalisation before SHA-256 hashing so two requests differing only by zero-width characters hash identically.
shell_true_optionaudit pattern was position-blind — now scans everyObjectExpressionarg, catchingspawn(cmd, args, { shell: true }, callback).
CI generates Sigstore build provenance via actions/attest-build-provenance@v2 against the packed tarball.
Stats
- 149 vitest tests across 14 files
- 0 findings on self-audit at HIGH severity
- MIT license
- Node >= 20
Hook recipes
See HOOK_RECIPES.md for four Claude Code hook configurations that wire shellguard into your session (PreToolUse Bash-block, PreToolUse Edit/Write audit, PostToolUse audit-trail, SessionStart guard-init).
Why this exists
The Ox-Security audit (May 2026) found that 200k+ MCP stdio servers wrap child_process.exec with template literals carrying user input straight from LLM tool args. LiteLLM v1.83.6 was the canonical example. This bundle is the defensive-security counterpart: a drop-in guard + scanner that closes the class.
Author
Matthias Meyer (StudioMeyer) — MIT.