Skip to content

Security Model

mik uses a layered capability model to isolate WASM modules from infrastructure.

LayerNetwork AccessPurpose
ScriptsNone - host.call() onlyOrchestration
HandlersHTTP to sidecars onlyBusiness logic
SidecarsNative (full access)Infrastructure adapters

These capabilities are granted to WASM handlers:

CapabilityWASI InterfaceRationale
Wall Clockwasi:clocks/wall-clockTimestamps, TTL calculations
Monotonic Clockwasi:clocks/monotonic-clockPerformance timing
Randomwasi:random/randomUUIDs, cryptographic operations
Logging (stderr)wasi:cli/stderrObservability
Environmentwasi:cli/environmentConfiguration injection
HTTP Clientwasi:http/outgoing-handlerSidecar communication

These are never granted:

CapabilityReason
Filesystem accessBreaks isolation, data exfiltration risk
Raw socketsBypasses HTTP policy enforcement
Process spawningSandbox escape
Direct database driversCredential exposure
ThreatMitigation
Path traversalInput sanitization, path validation
DoS via large bodiesConfigurable body size limits
DoS via slow handlersExecution timeouts, circuit breaker
Resource exhaustionRate limiting (global + per-module)
Unbounded allocationsLRU cache with byte limits
Handler failuresCircuit breaker with half-open recovery
[server]
# Limit request body size
max_body_size_mb = 10
# Limit execution time
execution_timeout_secs = 30
# Rate limiting
max_concurrent_requests = 1000 # Global limit
max_per_module_requests = 10 # Per-handler limit
# Restrict outgoing HTTP
http_allowed = ["*.internal.example.com"]

Control which hosts handlers can reach:

# Disable all outgoing HTTP (most restrictive)
http_allowed = []
# Allow specific hosts
http_allowed = ["api.example.com", "db-sidecar"]
# Wildcard subdomains
http_allowed = ["*.internal.example.com"]
# Allow all (least restrictive)
http_allowed = ["*"]

Scripts can only call handlers via host.call(). This prevents:

  • Scripts from bypassing handler logic
  • Direct database access from orchestration layer
  • Credential leakage through script injection

Handlers use wasi:http/outgoing-handler to call sidecars. Benefits:

  • No database drivers in WASM (smaller binaries)
  • Credentials stay in sidecars
  • All requests are auditable
  • Policy enforcement at sidecar layer

Sidecars are native processes with full access. They:

  • Own database connection pools
  • Enforce authentication and rate limits
  • Translate HTTP to infrastructure protocols
  • Can implement caching and retries

This security model preserves handler portability. The same .wasm file works on any WASI Preview 2 runtime—handlers don’t know they’re running on mik, they just make HTTP requests.