# AnvilRange · Host Isolation & Anti-Prompt-Injection Architecture

## 1. Five-Layer Host Isolation Guarantees
Every AnvilRange cyber-range pod executes inside five enforced kernel and process boundaries:
1. **Unprivileged Account + RootlessKit**: Dedicated `anvil-lab` Linux user wrapped in `/usr/bin/rootlesskit` user namespaces (no host root UID).
2. **Air-Gapped Zero-Egress Network**: `/usr/bin/unshare --net` plus gVisor `runsc --network=none` — zero outbound NICs, zero DNS, zero ability to scan public IPs or host LANs.
3. **User-Space Kernel Interception**: `runsc --platform=systrap` intercepts container syscalls in user space rather than exposing the host Linux kernel directly.
4. **Read-Only Shell-Less Rootfs**: Only a SHA-256 verified static Go `/target` binary is present. All Linux capabilities are empty (`noNewPrivileges: true`), `/bin/sh` is absent, and `/pod` is mounted `nosuid,nodev,noexec`.
5. **Verified Systemd Cgroups v2**: Worker enforces and verifies `MemoryMax=192MB`, `MemorySwapMax=0`, `CPUQuota=50%`, `TasksMax=96`, and `RuntimeMaxSec<=30m` (`KillMode=control-group`).

## 2. Four-Layer Anti-Prompt-Injection Principles
1. **Data/Instruction Plane Separation**: Untrusted prompts have control/bidi characters and angle brackets removed, then are fenced inside `<untrusted_scenario_input>`.
2. **Injection Pre-Screening with Deterministic Bypass**: Imperative prompt-override or host-command patterns (`ignore previous instructions`, `reveal system prompt`, `rm -rf`, `curl`, `/etc/passwd`) bypass the LLM completely and compile locally via Go deterministic parsing.
3. **Closed-Enum Schema Compilation**: Natural language compiles strictly into finite enums (`dmz|app|internal|vault`, `waf|gateway|firewall|siem`, 8 static assets including `supply_chain_pkg`, RFC1918 CIDRs, synthetic `.corp.local` hostnames). Arbitrary shell/code generation is structurally impossible.
4. **Indirect Injection Prevention for MCP Agents**: `CanonicalBytes()` strips raw user prompts before mounting `/pod/topology.json`, preventing downstream Claude/Cursor/Codex Agents from reading poisoned prompt text when probing sandboxes.
