Skip to content

Releases

v0.1.3: direct AST parsing and a complete parser bundle

Choose a tag to compare

@madetocreate madetocreate released this 01 Nov 21:41
35b97f8

Uses typescript-estree.parse directly for source auditing and removes the unused ESLint/Inspector layers. Bundles the parser and explicit TypeScript closure so fresh consumers receive a consistent dependency tree. dist/bundled-dependencies.json discloses the typescript-estree 8.72.1 minimatch range adjustment from ^10.2.2 to ^11.0.3; third-party source and version fields remain unchanged.

Validation: 188 tests per Node 20/22 runtime, installed AST/CLI checks, the eight-tool MCP handshake, consistent npm ls and zero findings in fresh-consumer audits. The packed-license guard checks full approved upstream text, including relevant README sections.

The measured archive is about 4.92 MB compressed and 26.04 MB unpacked. Existing audit rules, closed Zod 4 input schemas and the Node engine declaration are retained.

Changes: #20.

mcp-stdio-shellguard v0.1.2

Choose a tag to compare

@madetocreate madetocreate released this 19 Aug 17:52
821c2a5

Security — audit alias-bypass class closed

A cold-cross follow-up review of v0.1.1 found that the AST audit
(mcp-shellguard-audit) attributed a child_process call to its method
only by the callee name (child_process.exec, bare exec, …). Four
false-negative shapes — all common in real MCP servers — therefore
passed the scan with zero findings, giving false confidence that a
server was clean:

  • const execAsync = promisify(exec); execAsync(ls ${x}) — the
    canonical way servers await exec. Now resolved to exec and flagged.
  • import cp from "node:child_process"; cp.exec(ls ${x}) via a
    default/namespace import bound to an arbitrary local name.
  • const { exec: sh } = require("child_process"); sh(ls ${x}) —
    destructure-rename off require.
  • import { exec as run } from "node:child_process"; run(...) —
    named-import alias.

New src/audit/bindings.ts runs a whole-program pre-pass that resolves
every local identifier / namespace member proven to originate from
child_process (import or require("child_process")) to its canonical
method, then the scanner attributes the call accordingly. The resolver
is purely additive on top of the existing name-based matching, so it
can never lose a finding, and it only maps bindings whose origin is
proven — a promisify(readFile) or a destructure off another module
stays clean.

  • String-shell + dynamic-shell bypass. objectHasShellTrue matched
    only the literal shell: true. { shell: "/bin/bash" } (Node runs a
    real shell for a string shell) slipped through as a mere MEDIUM, and a
    dynamic { shell: shVar } was not flagged at all. Both are now HIGH
    shell_true_option. shell: false / shell: "" stay clean.
  • Sync child_process variants. spawnSync and execFileSync were
    uncovered. spawnSync("sh", ["-c", x], { shell: true }) and
    execFileSync(<dynamic>) are now flagged alongside their async forms
    in spawn_dynamic_file_args, exec_file_dynamic, shell_true_option,
    spawn_literal_dynamic_args, unbounded_buffer and missing_timeout.

Security — guard arg-type hardening (defense-in-depth)

guardExec / guardSpawn now reject any non-string element in args.
The TS type is string[], but the library is reachable from untyped JS
and JSON tool paths where an arg can arrive as a number / object / null.
Both the allowlist regex (re.test) and spawn silently coerce such
values, so a non-string arg could slip past an argsPattern the
operator believed constrained the input (most exposed at the MEDIUM tier
where argsPatterns is empty). guardSpawn also gained the explicit
Array.isArray(args) check guardExec already had.

Tests

  • tests/audit-binding-bypass.test.ts (16) — attack-blocked + benign-
    allowed for every alias / sync / string-shell shape, plus binding-
    resolver unit tests.
  • tests/guard-arg-types.test.ts (8) — non-string-arg rejection for both
    guards, with benign string-arg passthrough.
  • tests/audit-patterns.test.ts extended (+2) for string/dynamic-shell
    and isChildProcessMethod.
  • Total test count: 149 -> 167. No existing test weakened; the 12-rule
    catalogue is unchanged (rules broadened, no IDs added or removed).

v0.1.0 — Foundation Pillar 8

Choose a tag to compare

@madetocreate madetocreate released this 07 May 19:25

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-shellguard

Or run the audit CLI directly without installing:

npx -y -p mcp-stdio-shellguard mcp-shellguard-audit scan ./src

What you get

Three layers, opt-in piecewise:

  1. Library API — drop-in guardExec / guardSpawn you 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).
  2. 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.
  3. Reference MCP server — 8 tools with honest readOnlyHint / destructiveHint annotations 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_option audit pattern was position-blind — now scans every ObjectExpression arg, catching spawn(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.