Securing Local MCP stdio Pipes with RFC 8785 Schema Locks and NIST FF1 Twins
Enterprise network controls assume AI traffic crosses an HTTP proxy. For roughly a third of Model Context Protocol (MCP) setups on developer laptops, that assumption fails.
When Cursor, Claude Code, VS Code, Windsurf, or OpenAI Codex CLI reads .cursor/mcp.json, .mcp.json, or config.toml, the IDE spawns a child process (npx, uvx, docker, or a local binary) and speaks newline-delimited JSON-RPC 2.0 over OS file descriptors fd 0 (stdin) and fd 1 (stdout). No TLS proxy inspects that pipe.
Cloud CASBs and API gateways sit out of path until the host IDE has already pulled raw database rows, payment card numbers, or poisoned tool schemas into its prompt context.
While writing the IETF Internet-Draft draft-shuliak-sip-zero-egress-01 and building @shuliak-corp/sip1-mcp (v3.1.0, Apache-2.0), I kept two strict rules: zero runtime npm dependencies (pure Node.js >= 20 built-ins so anyone can audit the tarball) and zero outbound network sockets at runtime.
Below are four protocol failure modes we hit on raw MCP stdio streams, why static masking breaks downstream tools, and where this layer stops.
1. JSON.stringify Is Not Canonical: Stopping Tool Rug Pulls (0x06)
An MCP server declares its capabilities via tools/list. A developer approves a benign read-only tool once and moves on. Later (or after an unpinned @latest update), the server mutates a description or flips readOnlyHint: true to destructiveHint: true while injecting instructions into an argument schema.
Hashing JSON.stringify(tool) fails across runtimes and misses two wire-level parser differentials:
- Duplicate JSON keys: A raw frame containing
{"role":"viewer","role":"admin"}behaves differently between lenient scanners and V8JSON.parse(which takes the last key). Our frame guard (detectDuplicateJsonKeys+cleanProtoKeys) rejects duplicate keys and__proto__/constructorfields before routing. - Unicode Plane-14 and BiDi smuggling (SIP-R03): Codepoints in the Tags block (
U+E0000..U+E007F) and bidirectional overrides (U+061C,U+202A..U+202E,U+2066..U+2069) render as blank space in terminal diffs while remaining legible to model tokenizers.
In src/core/jcs.mjs, we implemented RFC 8785 JSON Canonicalization Scheme (JCS): keys sort by UTF-16 code units, lone surrogates (!str.isWellFormed()) throw immediately, and canonical UTF-8 bytes are hashed under domain prefix 0x06 (SIP-v3-STAGE1-SCHEMA-LOCK) and signed with a local Ed25519 key (RFC 8032). Any mid-session schema byte change fails closed before reaching the IDE.
2. Why [REDACTED] Breaks Payment Workflows: BigInt NIST FF1 Twins
Replacing a 16-digit PAN or 22-character SEPA IBAN with [REDACTED] breaks SQL column checks, Luhn Modulo-10 validators, and ISO 7064 MOD 97-10 rules. Worse, if two cardholders appear in one incident log, masking both as [REDACTED] destroys co-reference.
Three constraints shaped src/stage3/nist-ff1-twins.mjs (rawToTwin outbound to the model, twinToRaw inbound on tools/call):
- FF1 only, never FF3 or FF3-1. NIST withdrew FF3-1 after cryptanalytic breaks; only the 10-round Feistel mode FF1 in NIST SP 800-38G Rev. 1 remains standardized.
- Arbitrary-precision BigInt and the 1,000,000 domain floor. JavaScript
Numberloses integer precision above2^53 - 1, corrupting 16-to-19-digit cards and 30-char IBANs in modular rounds. Every radix step runs on nativeBigIntover cachednode:cryptoaes-256-ecb, verified against all 9/9 official NIST CAVP FF1 test vectors. Inputs belowradix^len < 1,000,000bypass FF1 and route to domain-separated HMAC-SHA256. - Stateless check-digit reconstruction. For a valid card
X = P || c_orig, we encrypt the payloadP' = FF1_Encrypt(K, T, P)and appendc_new = Luhn(P'). On inbound rehydration, we stripc_new, invertP = FF1_Decrypt(K, T, P'), and recomputec_orig = Luhn(P)with zero external vault. SEPA IBANs use the same cycle-walking invariant under ISO 7064 MOD 97-10 (98 - (N mod 97)). Median in-RAM latency sits between 0.08 ms and 0.65 ms.
3. Pre-Tool AST Guard and Atomic FinOps Breakers (< 0.25 ms)
System prompts cannot stop an agent loop from running DROP TABLE, mounting /, or burning $200 on a failing query. Before forwarding tools/call, SipPipelineBus (src/stage2/guard-runner.mjs) runs:
- Canary Tripwire (SIP-CANARY): Touching a planted honeytoken locks the workspace and revokes active leases.
- SQL/Shell Blast-Radius Classifier (< 0.25 ms): Blocks
DROP,TRUNCATE, unscopedDELETE, recursiverm,--dangerously-skip-permissions, and/or.envmounts with exit code 2. - Atomic FinOps & Loop Fuse (
finops-fuse.mjs): SIP-F01 trips above 25 calls per 10s or $5.00 session spend; SIP-F02 hashes (server, tool, normalizedActionDigest) and halts the 4th identical retry within 60 seconds.
Stage 3/4 (isep-engine.mjs, pdf-generator.mjs) records zero-PII RFC 9162 Merkle proofs (0x0B), GDPR Art. 17 salt shredding, CycloneDX 1.6 AIBOM JSON, and pure-JS vector %PDF-1.7 certificates verifiable offline via WebCrypto.
4. Quick Offline Check (Zero Sign-Up, 0 Sockets)
# Audit local MCP configs across 12+ AI IDEs offline
npx -y @shuliak-corp/sip1-mcp@3.1.0 audit
# Run the zero-socket tripwire + 3s sandbox demo
npx -y @shuliak-corp/sip1-mcp@3.1.0 demo
# Wrap existing stdio MCP servers (1-cmd rollback)
npx -y @shuliak-corp/sip1-mcp@3.1.0 shield --apply
(For Jira Cloud and JSM teams, we also run the same zero-egress NIST FF1 and WebCrypto engine inside native Runs on Atlassian Forge apps on @forge/kvs, including PII, Credit Card & Secret Shield for JRACLOUD-71685 changelog leaks and AegisVault.)
5. Where This Breaks: Non-Goals and Boundaries
- Structured identifiers, not prose NER. SIP-1 catches keys, DSNs, PANs, IBANs, national/clinical IDs, and
.docx/.xlsx/.pdf/ HL7 / FHIR fields, not free-text narrative secrets without structured tokens. - Same-UID local edits without MDM. On an unmanaged laptop, a user with local write access can edit
~/.cursor/mcp.json. Enforcing non-bypassable configs requires OS MDM profiles (mdm-exportvia Jamf or Intune). - Direct remote HTTP MCP. stdio wrapping covers local tool processes; remote OAuth HTTP endpoints not bridged over stdio sit outside
fd 0/1. - Technical telemetry, not legal certification. Signed ISEP v3.0 PDFs are deterministic software evidence (AS IS), not third-party audit, accounting, or legal opinions.
Links & Specifications
- GitHub (Apache-2.0, SLSA v1 provenance): https://github.com/Shuliak11/sip1-mcp-firewall
- IETF Draft (draft-shuliak-sip-zero-egress-01): https://datatracker.ietf.org/doc/draft-shuliak-sip-zero-egress/
- CERN Zenodo Corpus: https://doi.org/10.5281/zenodo.24159380
- Docs & Offline Verifier: https://shuliak.dev/docs (Open-Core is free under Apache-2.0; engineering teams expensing annual CI or Vanta/Drata compliance seats before Dec 31 can use Q4LOCK20 for 20% off at https://shuliak.dev/pricing).
Comments
No comments yet. Start the discussion.