Skip to content

gammahazard/vanguard-ics-guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

92 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WASI 0.2 Rust Component Model Wasmtime IEC 62443 Binary Size Pi Ready

πŸ›‘οΈ Vanguard ICS Guardian

A high-assurance security simulation demonstrating capability-based sandboxing
using WASI 0.2, the Component Model, and a custom "Data Diode" runtime.

Status Tests Demo License Mobile Responsive

Vanguard ICS Guardian Dashboard


πŸ“‘ Contents


🎯 The Scenario: Oil Rig Data Exfiltration

"A 3rd-party sensor driver on an offshore oil rig attempts to read pressure data and secretly exfiltrate it to a vendor cloud. Our WASI runtime acts as a Data Diodeβ€”allowing the read but blocking all outbound network connections."

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    VANGUARD ICS GUARDIAN                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      wasi:filesystem      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚  Malicious  β”‚ ──────────────────────────▢│  βœ“ ALLOW  β”‚  β”‚
β”‚   β”‚   Driver    β”‚                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚   β”‚   (WASM)    β”‚      wasi:sockets/tcp     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚             β”‚ ─────────────────────────▢│  βœ— BLOCK  β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                             β”‚
β”‚   "Data Diode Mode: Read sensor β†’ Block exfiltration"      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—οΈ Architecture

Component Technology Purpose
Guest Rust β†’ WASM Untrusted sensor driver attempting data theft
Host JavaScript (JCO) The "Warden" runtime controlling capabilities
Interface WIT (WASI 0.2) Standard capability contracts
Dashboard Leptos + Real WASM Security console with live policy enforcement + 2oo3 TMR demo

πŸ” Secure Supply Chain (Conceptual)

Vendor Build ───▢ Vanguard Hub ───▢ Edge Device
  (Rust)         (Ed25519 Sign)    (Verify & Load)

Protects against SolarWinds-style supply chain attacks.

πŸ”§ Tech Stack

Layer Technology
Standard WASI 0.2 (Preview 2) Component Model
Guest Language Rust with cargo-component
Host Runtime JavaScript via @bytecodealliance/jco
Dashboard Leptos (Rust reactive web framework)
Interface Definition WIT with wit-bindgen

πŸ“ Project Structure

vanguard-ics-guardian/
β”œβ”€β”€ wit/                    # Polyfill WIT interface definitions
β”‚   └── world.wit           # sensor-fs, sensor-net, sensor-utils
β”œβ”€β”€ guest/                  # Rust WASM component (14.7 KB!)
β”‚   └── src/lib.rs          # The "attacker" with narration
β”œβ”€β”€ host/                   # JavaScript runtime (the "warden")
β”‚   β”œβ”€β”€ shim/
β”‚   β”‚   β”œβ”€β”€ filesystem.js   # Mock filesystem capabilities
β”‚   β”‚   └── sockets.js      # Data diode + secure channel
β”‚   └── test/
β”‚       └── shims.test.js   # 17 unit tests
β”œβ”€β”€ cli/                    # Node.js CLI demo (proves browser β†’ edge portability)
β”‚   └── run.mjs             # Same WASM, measured outside browser
β”œβ”€β”€ dashboard/              # Leptos web UI
β”‚   β”œβ”€β”€ src/lib.rs          # Reactive security console
β”‚   └── styles.css          # Mobile-responsive
β”œβ”€β”€ legacy/                 # Docker "villains" for comparison
β”‚   β”œβ”€β”€ minimal.Dockerfile  # ~200 MB (pyserial)
β”‚   β”œβ”€β”€ full.Dockerfile     # ~800 MB (pandas, numpy)
β”‚   └── ml.Dockerfile       # ~2 GB (tensorflow)
└── docs/
    β”œβ”€β”€ ARCHITECTURE.md     # WASI vs Docker rationale
    β”œβ”€β”€ BRANCHING.md        # Git workflow
    └── SECURITY.md         # Security analysis + IEC 62443

πŸš€ Quick Start

Run the Dashboard:

# Install trunk (build tool for Leptos)
cargo install trunk

# Run dev server with live reload
cd dashboard && trunk serve
# Opens http://localhost:8080

Run the Host Demo:

cd host && npm install && npm run demo

Run the CLI Demo (proves browser β†’ edge portability):

node cli/run.mjs
πŸ“Š Example CLI Benchmark Output
╔══════════════════════════════════════════════════════════════════╗
β•‘           VANGUARD ICS GUARDIAN - WASM PORTABILITY DEMO          β•‘
╠══════════════════════════════════════════════════════════════════╣
β•‘  Same .wasm binary running in Node.js (proves browser β†’ edge)    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

πŸ“¦ Loading: malicious_driver.core.wasm (14.7 KB)

⏱️  WASM Performance Metrics
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Load from disk:    2.15 ms
   Compile (V8):     12.45 ms
   Instantiate:       0.18 ms  ← This is what 2oo3 TMR measures!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ” Instantiation Benchmark (10 iterations)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Min:    0.12 ms
   Max:    0.31 ms
   Avg:    0.18 ms
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ›‘οΈ  Security Policy Tests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   [DATA DIODE]    FS: βœ“ ALLOW  Net: βœ— BLOCK
   [SECURE CHAN]   FS: βœ“ ALLOW  Net: βœ“ internal only
   [FULL LOCKDOWN] FS: βœ— BLOCK  Net: βœ— BLOCK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

βœ… WASM component verified: same binary, same security, any runtime

πŸ“Š Security Modes

Mode Filesystem External Internal Description
πŸ›‘οΈ Data Diode βœ“ Allow βœ— Block βœ— Block Production mode
πŸ”— Secure Channel βœ“ Allow βœ— Block βœ“ Allow Internal SCADA only
πŸ”’ Full Lockdown βœ— Block βœ— Block βœ— Block Zero trust
⚠️ Breach βœ“ Allow βœ“ Allow βœ“ Allow Security failure demo

Approved Internal Endpoints (Secure Channel mode):

  • 10.0.0.50:502 - SCADA server (Modbus)
  • 10.0.0.51:102 - PLC gateway (S7)
  • 192.168.100.10:443 - Data historian

🎬 Attack Simulation Gallery

Watch the malicious driver attempt data exfiltration under different security policies

πŸ›‘οΈ Data Diode Mode β€” Exfiltration Blocked

Data Diode Attack

Sensor read succeeds βœ“ | Network exfiltration blocked βœ—


πŸ”— Secure Channel Mode β€” Internal SCADA Only

Secure Channel Attack

External blocked βœ— | Internal SCADA endpoints allowed βœ“


πŸ”’ Full Lockdown Mode β€” All Access Denied

Full Lockdown Attack

Zero trust: filesystem blocked, network blocked


⚠️ Breach Simulation β€” Security Failure Demo

Breach Simulation

What happens when security is misconfigured β€” data exfiltrated!


❓ Invalid Config Mode β€” Policy Enforcement

Invalid Config

Runtime blocks execution when configuration is invalid

πŸ“¦ Docker vs WASI Deployment Comparison

See the size difference in action

Deployment Comparison

PLC Firmware: Docker 50 MB vs WASI 15 KB


Full System Package (Docker: 4 GB vs WASI: 8 MB)

Full System Deployment

Even at scale, WASI remains 500x smaller with 500x faster download

πŸ§ͺ Testing

# JavaScript host tests (17 tests)
cd host && npm test

# Rust guest tests
cd guest && cargo test

🏭 IEC 62443 Alignment

This project demonstrates key principles from the IEC 62443 industrial cybersecurity standard, mapped to the Purdue Model:

IEC 62443 Principle Our Implementation Code Reference
Zone & Conduit Model OT zone (L0-2) isolated from IT (L4-5) via data diode sockets.js
Unidirectional Gateway Data Diode: read IN from sensors, block OUT to cloud sockets.js
Defense in Depth WASI capability model adds runtime-level security filesystem.js
Least Privilege Components only receive explicitly granted capabilities WIT interface definitions
Secure by Default Network access denied unless specifically whitelisted Policy config in shims

⚠️ Note: This is a demonstration of IEC 62443 concepts, not a certified implementation. Formal compliance requires third-party assessment.

πŸ“‘ Bandwidth Reality: Remote Deployments

For offshore oil rigs with limited satellite connectivity (~1 Mbps):

Package Docker (~500 MB) WASI (~15 KB)*
Download Time ~67 minutes ~0.12 seconds
Network Impact Saturates link Negligible
Failover Speed Minutes Milliseconds

*Actual measured size of our compiled malicious-driver component: 14.7 KB

This is why WASI matters for remote ICS environments.

⚑ 2oo3 Fault Tolerance Demo

The dashboard includes a Triple Modular Redundancy (TMR) visualization demonstrating WASM's fault tolerance advantages for safety-critical systems:

πŸ“Ή Watch: Fault Injection β†’ Instant WASM Recovery

Fault Injection Demo

Click "Inject Fault" β†’ WASM rebuilds in 0.2ms while Python takes 3+ seconds

Metric WASM Hot-Swap Python Multiprocessing
Instance Rebuild ~0.1-1 ms (measured) 2-5 seconds
Frames During Fault βœ“ Processed (2 healthy) βœ— Lost
Downtime 0 ms (hitless) 2-5 sec per restart

Try it: Click "πŸ’₯ Inject Fault" in the live demo to corrupt one instance and watch:

  • Majority voting still produces correct output (2oo3 consensus)
  • WASM rebuilds the faulty instance in <1ms (real measurement shown)
  • Python would lose in-flight frames during its 3+ second restart

πŸ“– Aligns with IEC 61508 SIL 2/3 patterns for safety-critical systems.

πŸ”— Want to see 2oo3 in action with attack simulations? Check out the companion project: Protocol Gateway Sandbox β€” Watch buffer overflows, truncated headers, and illegal function codes get isolated by WASM voting while Python crashes.

πŸ§ͺ Verification & Testing

This project includes a comprehensive test suite using Vitest to verify the security invariants of the WASI shim. We test the Host implementation directly to ensure permissions are enforced before the Guest code even runs.

Running Tests:

cd host && npm test

What We Test

The test suite (test/shims.test.js) verifies the critical states of the Data Diode:

Scenario Filesystem Network Expected Result
πŸ›‘οΈ Data Diode βœ… Allow ❌ Block Read sensor, fail exfiltration
🧊 Full Lockdown ❌ Block ❌ Block All I/O rejected
🚨 Breach Simulation βœ… Allow βœ… Allow Exfiltration succeeds (bad config)

Security Invariants

We also verify specific capability granularities:

  • Path Isolation: wasi:filesystem cannot access paths outside /mnt/
  • IP Whitelisting: Even in "Secure Channel" mode, connections to unapproved IPs (like 1.1.1.1) are rejected at the shim level
  • Port Matching: Approved IPs must also use approved ports (e.g., 10.0.0.50:502 βœ“, 10.0.0.50:8080 βœ—)

πŸ’‘ The whitelist tests prove we implemented granular network policies, not just a simple on/off switch.

πŸš€ Production Path: Browser β†’ Edge Hardware

The WASM component is production-portableβ€”the same .wasm binary runs on multiple runtimes:

Runtime Platform Use Case
Browser Any modern browser What we're demoing now (Leptos/Trunk)
Wasmtime Linux, Windows, macOS Server-side, Rust host
WasmEdge ARM, RISC-V, Raspberry Pi Edge devices, CNCF project
wasm3 ESP32, STM32, Arduino Resource-constrained MCUs

What's Real vs Simulated

Component This Demo Production
WASM instantiation βœ… Real (<0.1ms) Same or faster
2oo3 voting logic βœ… Real Same code
Capability enforcement βœ… Real Same code
Modbus/Sensors πŸ”Ά Mock shims Replace with real I/O
Python restart times πŸ”Ά Simulated Based on benchmarks

To deploy on real hardware:

  1. Replace JavaScript host with Rust + Wasmtime (same WASM component works)
  2. Swap mock shims for real protocol stacks (tokio-modbus, rumqttc)
  3. Add hardware watchdog for 2oo3 voter process

πŸ“– The architecture patterns (capability isolation, 2oo3 voting) translate directly to real ICS deployments.

πŸ“ Hardware Demo (Coming Soon)

The same .wasm binary will run on real industrial hardware:

Hardware Sensors What It Proves
Raspberry Pi 4 DHT22, BME280, DS18B20 Same WASM, real data, real security

This works because the project follows the WASI 0.2 Component Model β€” a W3C standard that defines how WASM modules interact with the outside world through capability-based interfaces. The guest component only knows about abstract interfaces (sensor-fs, sensor-net), not whether it's running in a browser or on a Pi.

What stays the same:

  • guest.wasm β€” identical binary, zero changes
  • WIT interface β€” same capability contracts
  • Security model β€” data diode still blocks network

What we'll build:

  • Rust host replacing JavaScript shims with real GPIO/I2C via rppal
  • sensor-fs implementation reads actual sensor data instead of mock JSON
  • sensor-utils::log() writes to RGB OLED display instead of console

🎬 Demo video coming soon β€” split-screen browser dashboard + physical Pi with sensors.

πŸ“– Hardware Setup Guide β†’ β€” Wiring diagrams, GPIO pinouts, implementation code

πŸ”— Related Projects

This project is part of the Reliability Triad β€” a portfolio demonstrating WASI 0.2 Component Model across security, protocol translation, and distributed consensus:

Project Focus Demo
Vanguard ICS Guardian (this) Capability-based sandboxing Live Demo
Protocol Gateway Sandbox Modbus/MQTT translation Live Demo
Raft Consensus Cluster Distributed consensus Live Demo
Guardian-One Hardware implementation Private - in development

Guardian-One is the hardware implementation of these concepts β€” a Rust/Wasmtime host running on Raspberry Pi 4 with BME280 sensors, SainSmart relays, and a 3-node Raft cluster for fault tolerance. Hardware demo coming soon.

πŸ“š Documentation

  • Architecture Deep Dive: WASI vs Docker comparison, Purdue Model, capability isolation
  • Security Analysis: IEC 62443 alignment, attack surface reduction, what each technology solves
  • Hardware Setup: Raspberry Pi wiring, sensor configuration, Rust host implementation

🌿 Branch Strategy

Branch Purpose Deployment
main Stable releases Production
develop Integration Preview
feature/* Feature work β€”

πŸ“œ License

MIT Β© 2026


Built to demonstrate capability-based security for industrial control systems.

About

πŸ›‘οΈ WASI 0.2 security simulation: A data diode runtime that allows sensor reads but blocks network exfiltration. Built with Rust, Leptos, and the Component Model

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors