Skip to main content
The 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.
GatewayInterceptor Architecture (Light)GatewayInterceptor Architecture (Dark)

Perimeter admission hook position within LiopHybridGateway pipeline

Pipeline Ordering

The admission hook executes in strict sequential order:
The interceptor executes strictly after JWT authentication and rate limiting. This sequence prevents unauthenticated or abusive client traffic from depleting external inference budgets, API rate quotas, or compute cycles.

Configuration

The hook is configured via the optional fifth parameter of LiopHybridGateway:

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:
Deploying external cloud classifiers such as TypeSafe Jev is not recommended for production environments requiring strict data sovereignty. Routing unencrypted parameters to third-party endpoints compromises the confidentiality required by regulations such as HIPAA and PCI-DSS, introduces availability risks during remote service disruptions, and increases admission latency by over two orders of magnitude compared to local ONNX execution.

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:
  1. Stage 1A (Syntactic Filter): Deterministic regular expression check (< 0.2 ms) blocking structured attacks (SQL injection, directory traversal, shell metacharacters).
  2. 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 to LiopHybridGateway, 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 (Light)LIOP Interceptor Topology (Dark)

LIOP Interceptor Topology: Demarcation between Ingress Admission and Enclave Isolation

  • Target Node: Public entrypoints, DMZ ingress proxies, and service discovery seeds (e.g. Nexus Gateway).
  • Hook Deployment: GatewayInterceptor is 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 Forbidden and error code -32099 before 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: GatewayInterceptor MUST NOT be configured on data enclave servers.
  • Technical Rationale:
    1. 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.
    2. 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.

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 local GatewayInterceptor filtering, allowing enclaves to evaluate code in-situ.

Security Model Verification

The GatewayInterceptor 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: