Why Markdown Guardrails Fail Against the MCP Lethal Trifecta — Building AEGIS-MCP with Kiro
This article was written as part of the **Kiroween 2026* hackathon (Frankenstein Category).* AI coding agents have crossed a critical threshold: through the Model Context Protocol (MCP), they no longer just suggest code
This article was written as part of the **Kiroween 2026* hackathon (Frankenstein Category).*
AI coding agents have crossed a critical threshold: through the Model Context Protocol (MCP), they no longer just suggest code—they read local workspaces, ingest untrusted external content, and invoke outbound network tools autonomously.
That shift created a real, measurable supply-chain crisis:
- 1,075 MCP-specific vulnerabilities and advisories (40% of all tracked AI-agent infrastructure advisories across 431 projects).
- 36.82% of audited agent skills (1,467 of 3,984 in Snyk's ToxicSkills audit) contained security flaws, including 76 packages built to steal credentials.
- Up to 84.2% Attack Success Rate on tool-poisoning benchmarks (MCP-ITP / MCPTox), with baseline model detection below 1%.
In March 2026, the MCP maintainers formally named this failure mode The Lethal Trifecta: when an agent combines private data access, untrusted content exposure, and external communication, tool annotations like readOnlyHint: true are merely untrusted hints. Asking an LLM to police itself via Markdown instructions fails the instant a rug-pulled tool schema or a Cyrillic Unicode homoglyph (U+0430 masquerading as Latin a) hijacks model reasoning.
For Kiroween 2026, I built AEGIS-MCP—a zero-trust dual-era MCP governance proxy, monotonic taint engine, and air-gapped Ed25519 verifier that enforces security at the one boundary prompt injection cannot touch: the local host runtime (127.0.0.1).
- Live Air-Gapped Verifier (Browser Crucible): https://aegis-mcp-five.vercel.app
- Open-Source Repository (MIT): https://github.com/Rasslonely/AEGIS-MCP
Why We Entered the Frankenstein Category
Stopping the Lethal Trifecta without leaking developer secrets to a cloud collector required stitching six distinct engineering domains into one local-first TypeScript runtime (with zero @modelcontextprotocol SDK wrapper so every byte on the wire is audited directly):
-
Cryptographic Bootstrap & OS Containment: Launches upstream STDIO servers with
shell: false, verifies tool catalogs against an Ed25519-signed TOFU lockfile (mcp-lock.json), pins OCI digests, and seals secrets behind OS keychain/ACL boundaries. -
Dual-Era MCP Protocol Adapters: Native enforcement for both MCP
2026-07-28(stateless Streamable HTTP,Mcp-Method/Mcp-Name/Originbinding, Multi Round-Trip Requests, W3Ctraceparent) and legacy2025-11-25session/SSE servers. - Killable Schema & Unicode Inspector: Runs bounded JSON Schema 2020-12 validation and Unicode UTR #39 homoglyph + zero-width character detection inside an isolated worker thread, preserving raw byte offsets for forensic evidence.
-
Monotonic Taint Lattice & 1-Shot SQLite WAL Nonces: Once an execution context ingests untrusted content, it locks permanently into
TAINTED_EXTERNALfor the rest of the run. Any outbound exfiltration sink is hard-blocked (DENY -32003) until a human operator consumes a single-use approval nonce bound toagentRunIdand the canonical RFC 8785 (JCS) SHA-256 argument digest. Replay attempts fail atomically withNONCE_CONSUMED. -
Dual-Tier Cryptographic Audit: Keeps host-private HMAC-SHA256 integrity chains inside local SQLite WAL storage while exporting redacted, Ed25519-signed public proof bundles (
aegis-receipt.json). -
Air-Gapped Browser Crucible (
apps/crucible) & Loopback Ops Console (apps/console): A static Web Worker verifier served under strict CSP (connect-src 'none') that recomputes every SHA-256 hash-chain link and Ed25519 signature completely offline—paired with a bearer-authenticated operator approval console and OTLP/SIEM emitters.
How Kiro Changed the Way I Build Security Software
Most hackathon projects use AI assistants for ad-hoc vibe coding. In cryptographic and security boundary engineering, vibe coding is dangerous: a single silent drift across 40 files can break canonicalization, weaken a nonce check, or leak a secret in error logs.
Building AEGIS-MCP with Kiro across 52 execution slices in 17 phases changed my workflow from prompt-and-pray to spec-enforced engineering:
1. Mechanical EARS Specs (.kiro/specs/requirements.md)
Instead of loose prompts, I authored six formal EARS security invariants (REQ-BOOT-01 through REQ-AUD-06) mapping each threat mitigation directly to concrete TypeScript modules and test files. A portable traceability gate (tests/unit/11-03.test.ts) runs in CI and fails the build if any requirement ID drifts or loses test coverage.
2. "Steering Without Illusion" (.kiro/steering/security-invariants.md)
Steering documents (INV-01–INV-08) kept Kiro aligned on security invariants across every slice while enforcing one strict architectural boundary: Markdown steering guides the AI developer at build time, never runtime authorization. Runtime tool execution is authorized only by an Ed25519-signed PolicyProfile JSON file (AEGIS-POLICY-v1).
3. Pre-Dispatch Agent Hooks (.kiro/hooks/aegis.json)
I wired two Kiro hooks directly into the repo:
- A
PreToolUsehook matching@mcpthat invokesaegis-mcp-proxy hook-gate --profile <reviewed-file>inside a bounded deadline and returns exit code2to hard-block unmapped or forbidden MCP calls before dispatch. - A non-mutating
PostFileSavenpm run linthook scoped strictly to TypeScript sources.
Proof Over Claims: 2,943 Tests & Paired Attack Reproduction
Pairing Kiro's EARS specs with seeded fast-check property-based tests uncovered real edge cases in deeply nested RFC 8785 JSON canonicalization, Unicode confusable byte offsets, closed CLI grammars, and concurrent SQLite nonce updates.
Today, the repository ships with:
-
2,943 passing tests across 46 Vitest suites (plus 2 Playwright E2E suites) and
0errors under stricttsc --noEmitand Biome. - A reproducible paired attack benchmark (
npm run bench) proving a synthetic canary SSH-key exfiltration succeeding on an unguarded MCP baseline and deterministically blocked (DENY -32003+ replay rejection) under AEGIS-MCP. -
Zero-network verification: Open https://aegis-mcp-five.vercel.app, verify the
connect-src 'none'CSP header in DevTools, and validateaegis-receipt.jsoncompletely offline.
If you're deploying AI coding agents with MCP tools, don't bet your SSH keys on a Markdown hint. Check out AEGIS-MCP on GitHub and try the Browser Crucible live!
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.