prompt-shield-eval v1.1.0 — Hybrid LLM Prompt Injection Defense, ONNX INT8 Cascade & MCP Guardrail
Modular 3-export defense-in-depth LLM security engine in strict TypeScript 5.7: zero-dependency sub-millisecond Core (.), optional Layer 3.5 local 104.2 KB ONNX INT8 Semantic Cascade (./semantic), and drop-in MCP Middleware Guardrail (./mcp) targeting autonomous SRE agents (aegis-agent).
Zero-bloat Core + selective ONNX INT8 + MCP Middleware
Built in strict TypeScript 5.7 (ESM) for Node.js 22/24, Vitest, ESLint 9 (--max-warnings=0), and 3-job parallel GitHub Actions CI, aligned with OWASP LLM Top 10 (LLM01, LLM06, LLM07) under the MIT License. Core runtime isolation (0 dependencies) is locked by both a static transitive import-graph check (scripts/verify-core-zero-deps.mjs) and an isolated clean-room npm pack tarball smoke test in CI.
- Core (
prompt-shield-eval— 0 runtime deps): Layer 1–5 deterministic pipeline (NFKC/Unicode Tag/homoglyph/multi-leet normalizer + depth-2 decode,O(N)linear HTML/Markdown anti-ReDoS scanners, 5-turn sliding window, bounded LRU+TTLTaintSessionStore, 16-ID bilingual EN/ID scorerPI-01–PI-14C, 128-bit cryptographic nonce trust boundary, and output canary/4-gram + strictinteger/enumHITL tool gate). - Layer 3.5 Semantic Cascade (
prompt-shield-eval/semantic— optional peeronnxruntime-node): Fast-path short-circuits obvious attacks at0 msONNX overhead; only gray-zone inputs, subtle storytelling/academic framing (PI-06), and cross-lingual cues (PI-09: FR, ES, JA, DE, ID–EN–regional) escalate to a real104.2 KBopset-19 INT8 ONNX mini-encoder (DynamicQuantizeLinear+MatMulInteger, SHA-256 verified againstmodels/manifest.v1.json) with hard25 msAbortControllertimeout and explicitfailMode. - MCP Middleware Guardrail (
prompt-shield-eval/mcp— optional peer@modelcontextprotocol/sdk): Transport-agnostic ingress/egress interceptor (InMemory+ subprocessstdio) with per-session taint tracking,aegis-agent(HYPERION CH06) 4-tool preset blocking compound indirect hijacks (-32001 TAINTED_CONTEXT_BLOCKED), rejecting float/invalid-enum schemas (-32602), verifyinghitl1.*approval tokens, and bridging structured audit events.
Developed with AI coding assistance. All metrics below come directly from deterministic local suites and GitHub Actions CI Run #44668345769.
Core, ONNX INT8 Cascade & MCP Guardrail evidence
- Core Hot Path (26 cases: 20 attacks across 16/16 IDs + 6 hard negatives): 100.00% TPR, 0.00% FPR, 100.00% Exact Decision Match, 0 failures on
PI-02&PI-14B, warmp50 = 0.046 ms/p99 = 0.690 ms;480+deterministic fuzz seeds + 10 pathological 20–50 KB anti-ReDoS payloads completing in< 50 ms. - Hybrid Core + L3.5 ONNX INT8 (60 cases: 44 attacks + 16 hard negatives): 100.00% TPR, 0.00% FPR, 100.00% Exact Decision Match (60/60), selective escalation
37/60(61.7%), hybrid warmp50 = 0.287 ms/p99 = 0.876 ms, ONNX INT8 inferencep50 = 0.299 ms/p99 = 0.762 ms, plus50,000-iteration cascade soak &1,000live ONNX inferences with0memory leak. - MCP Middleware Guardrail (
aegis-agent, InMemory + Subprocessstdio):20/20(100%) compound indirect tool hijacks blocked (-32001),20/20legitimate HITL calls allowed (0false blocks),20/20anti-float schema violations rejected (-32602),121structured audit events emitted, middleware overheadp50 = 0.217 ms/p99 = 0.752 ms(gate< 2.0 ms). - Parallel GitHub Actions CI (Run
#44668345769):ci-core(29s, including static zero-deps & clean-room tarball test),ci-semantic-onnx(21s, SHA-256 model verification), andci-mcp-adapter(25s) all PASS.
Review the implementation
package.json(3 subpath exports, 0 runtime deps) ·.github/workflows/ci.yml(3-job CI) ·scripts/verify-core-zero-deps.mjssrc/normalizer.ts·src/hardened-detector.ts·src/trust-boundary.ts·src/output-tool-gate.ts·src/session-taint.tssrc/semantic/cascade.ts·src/semantic/onnx-provider.ts·src/semantic/tokenizer.ts·models/semantic-mini-encoder.int8.onnx(104.2 KB) ·models/manifest.v1.jsonsrc/mcp/middleware.ts·src/mcp/aegis-preset.ts·src/mcp/aegis-stdio-server.ts·test/*.test.ts(5suites,30/30PASS)
Source audit: 20 November 2026. Commit 9c1aa84 (tag v1.1.0) · github.com/vanovri/prompt-shield-eval · Source evidence index.
Evidence boundary: The evaluation suites verify deterministic rule accuracy, zero-FPR behavior on synthetic hard negatives, local INT8 ONNX cascade latency, fuzz/anti-ReDoS bounds, and MCP taint isolation on synthetic in-memory canaries and mock tools; no guardrail guarantees immunity against novel adaptive LLM attacks without layered model- and infrastructure-level controls.
All projects