GatewayInterceptor is a perimeter admission hook executed by LiopHybridGateway immediately after transport authentication and sliding-window rate limiting, prior to JSON-RPC request dispatch.
It provides an extension point for developers to attach arbitrary semantic filters, neural classifiers (such as TypeSafe Jev or ONNX runtimes), or deterministic rule engines without introducing external dependencies into the LIOP SDK core.
Perimeter admission hook position within LiopHybridGateway pipeline
Pipeline Ordering
The admission hook executes in strict sequential order:Configuration
The hook is configured via the optional fifth parameter ofLiopHybridGateway:
Options Reference
Interceptor Contract
The interceptor function adheres to this signature:Parameters
request: Readonly<McpRequest>
A frozen deep clone (Object.freeze(structuredClone(request))) of the incoming JSON-RPC envelope.
Top-level and nested property modifications performed inside the interceptor operate on an isolated clone, eliminating prototype pollution attacks against the gateway scope.
context: GatewayInterceptorContext
Return Value (GatewayAdmissionResult)
Usage Examples
Architectural Evaluation: Cloud Services vs Local In-Situ Runtime
Perimeter admission filtering can execute via external classification APIs or local in-process models. The table below outlines the operational trade-offs:Example 1: External Cloud Classifier (TypeSafe Jev)
For development environments where external network egress is acceptable, cloud endpoints evaluate semantic context via REST APIs:Example 2: Local ONNX Runtime (Two-Stage Hybrid Pipeline)
For sovereign deployments requiring zero network egress, local ONNX neural classifiers evaluate incoming payloads directly on the host. Because small transformer models evaluate semantic language context rather than syntactic code fragments, the recommended production pattern implements a two-stage hybrid pipeline:- Stage 1A (Syntactic Filter): Deterministic regular expression check (< 0.2 ms) blocking structured attacks (SQL injection, directory traversal, shell metacharacters).
- Stage 1B (Semantic ONNX Classifier): Quantized INT8 neural model (< 2.0 ms) detecting prompt injections, jailbreak attempts, and covert instruction overrides.
Example 3: Deterministic Rule Matcher (Zero Dependencies)
When machine learning inference is unnecessary or hardware constraints preclude running neural models, lightweight regular expressions provide zero-dependency perimeter filtering:Example 4: Unconfigured Default Behavior
When no interceptor is passed toLiopHybridGateway, the perimeter admission stage is bypassed:
Network Topology & Placement Directives
Deploying interceptors within a distributed LIOP mesh requires adhering strictly to network boundary segregation per NIST SP 800-207 Zero-Trust Architecture:LIOP Interceptor Topology: Demarcation between Ingress Admission and Enclave Isolation
1. Perimeter Ingress Gateways (MANDATORY / RECOMMENDED)
- Target Node: Public entrypoints, DMZ ingress proxies, and service discovery seeds (e.g.
Nexus Gateway). - Hook Deployment:
GatewayInterceptoris deployed here to execute Layer 7 application firewalls, neural semantic classifiers (e.g. TypeSafe Jev), and IP/reputation filters. - Objective: Reject hostile probes (SQL injections, Path Traversal, prompt jailbreaks) in < 400 ms with
HTTP 403 Forbiddenand error code-32099before requests traverse the P2P mesh or consume enclave compute budgets.
2. Sovereign Data Enclaves (STRICTLY PROHIBITED)
- Target Node: Private data providers and Tier 1 enclaves (e.g.
The Bank,The Vault). - Policy:
GatewayInterceptorMUST NOT be configured on data enclave servers. - Technical Rationale:
- Prevention of False Positives on Code Payloads: In LIOP, clients send valid logic micro-modules (
@LIOP{...}...@END). Heuristic string-matching or generic WAF filters running inside enclaves inevitably misinterpret mathematical aggregations or analytical loops as code injection attacks. - True Zero-Trust Sandbox Isolation: Enclaves must never assume an upstream proxy neutralized threats. Instead, enclaves must rely entirely on The Shield (Guardian AST allowlist, WASI/V8 Sandbox with 25 poisoned globals, Taint IFC, and Egress PII Shield). Introducing an ingress admission hook on an enclave obscures the sandbox’s actual boundary and invalidates compliance audits.
- Prevention of False Positives on Code Payloads: In LIOP, clients send valid logic micro-modules (
3. Asymmetric Border Gateways (BLG)
- Target Node: Border LIO Gateway (
BLG) bridging Tier 2 (Consortium) into Tier 1 (Private Enclaves). - Policy: Evaluates clearance tiers (
clearanceTier: 4), mTLS client certificates, and the Tier 1 Swarm Key (tier1.psk). Routed logic payloads pass through directly to the target enclave without localGatewayInterceptorfiltering, allowing enclaves to evaluate code in-situ.
Security Model Verification
TheGatewayInterceptor operates solely as an admission gate at the DMZ boundary. It does not replace, alter, or weaken any of the six foundational LIOP security layers:
Related References
- Log & Audit Interceptors: Operational log stream and cryptographic audit ledger hooks.