Overview
OpenFang doesn’t bolt security on after the fact. Every layer is independently testable and operates without a single point of failure. 16 discrete security systems organized into critical fixes and state-of-the-art defenses:The 16 Security Systems
1. WASM Dual-Metered Sandbox
1. WASM Dual-Metered Sandbox
Tool code runs in WebAssembly with two independent safety mechanisms:This prevents:
Fuel Metering
Every WASM instruction consumes “fuel”. When fuel runs out, execution stops.Epoch Interruption
A watchdog thread increments an epoch counter every second. WASM execution checks the epoch and terminates if too much wall-clock time passes.- CPU-bound runaway code (caught by fuel metering)
- Time-bound hangs (caught by epoch interruption)
crates/openfang-runtime/src/sandbox.rs2. Merkle Hash-Chain Audit Trail
2. Merkle Hash-Chain Audit Trail
3. Information Flow Taint Tracking
3. Information Flow Taint Tracking
4. Ed25519 Signed Agent Manifests
4. Ed25519 Signed Agent Manifests
5. SSRF Protection
5. SSRF Protection
Blocks requests to private IPs and cloud metadata endpoints.Applied in:
Blocked Targets
web_fetchtoolhost_net_fetchWASM host function- All HTTP client calls
crates/openfang-runtime/src/web_fetch.rs6. Secret Zeroization
6. Secret Zeroization
7. OFP Mutual Authentication
7. OFP Mutual Authentication
8. Capability Gates
8. Capability Gates
Role-based access control — agents declare required tools, the kernel enforces it.See the Agents page for full details.TL;DR:
- Every operation requires a capability
- Capabilities are granted at spawn time
- Inheritance validation prevents privilege escalation
- Deny-by-default: if not granted, operation is blocked
crates/openfang-kernel/src/capabilities.rs9. Security Headers
9. Security Headers
All API responses include security headers:Code reference:
crates/openfang-api/src/middleware.rs10. Health Endpoint Redaction
10. Health Endpoint Redaction
11. Subprocess Sandbox
11. Subprocess Sandbox
Python/Node skill runtimes use environment isolation.Prevents:
Environment Clearing
- Secret leakage (subprocess can’t see parent env vars)
- Credential theft (no AWS_*, OPENAI_API_KEY, etc. unless explicitly passed)
crates/openfang-runtime/src/subprocess_sandbox.rs12. Prompt Injection Scanner
12. Prompt Injection Scanner
Detects malicious patterns in skill content before activation.Applied to:
Detection Patterns
- All bundled skills (compile-time check)
- User-installed skills (runtime check)
- SKILL.md auto-conversion from OpenClaw
crates/openfang-skills/src/verify.rs13. Loop Guard
13. Loop Guard
SHA256-based tool call loop detection with circuit breaker.See the Agents page for full details.Code reference:
crates/openfang-runtime/src/loop_guard.rs14. Session Repair
14. Session Repair
7-phase message history validation and automatic recovery.See the Agents page for full details.Code reference:
crates/openfang-runtime/src/session_repair.rs15. Path Traversal Prevention
15. Path Traversal Prevention
Security Dependencies
All security systems rely on well-audited crates:| Dependency | Purpose |
|---|---|
sha2 | SHA-256 hashing (Merkle chain, loop guard) |
hmac | HMAC-SHA256 (OFP authentication) |
hex | Hex encoding/decoding |
subtle | Constant-time comparison (prevents timing attacks) |
ed25519-dalek | Ed25519 signatures (manifest signing) |
rand | Cryptographic random number generation |
zeroize | Memory wiping (secret zeroization) |
governor | Rate limiting (GCRA algorithm) |
wasmtime | WASM sandbox |
Capability-Based Security
The foundation of OpenFang’s security model is capability-based access control. See the Agents page for full details on:- Capability types
- Pattern matching rules
- Inheritance validation
- Enforcement flow
Configuration
~/.openfang/config.toml
Security Best Practices
Defense in Depth
No single security system is perfect. OpenFang uses 16 independent layers so that if one fails, others catch the breach.
Principle of Least Privilege
Agents are granted only the minimum capabilities they need. Default is deny-all.
Fail Secure
When an error occurs, the system defaults to the most restrictive behavior. For example:
- Capability check fails → deny operation
- Session repair fails → terminate agent loop
- Path validation fails → reject file operation
Audit Everything
Every agent action is logged to the Merkle hash-chain audit trail. Tamper-evident logging means you can detect post-hoc manipulation.
Threat Model
OpenFang is designed to defend against:| Threat | Defense |
|---|---|
| Malicious agents | Capability gates + WASM sandbox + subprocess isolation |
| Privilege escalation | Inheritance validation (child ⊆ parent) |
| Secret leakage | Zeroization + env_clear() + taint tracking |
| SSRF attacks | Private IP blocking + DNS resolution checks |
| Path traversal | Canonicalization + symlink escape detection |
| Loop attacks | Loop guard with circuit breaker |
| Session corruption | Session repair with 7-phase validation |
| Replay attacks | Nonce-based HMAC authentication |
| Timing attacks | Constant-time comparison via subtle crate |
| Prompt injection | Prompt injection scanner |
| Audit tampering | Merkle hash chain |
| Rate limit bypass | Per-IP GCRA rate limiter |
| XSS/clickjacking | Security headers (CSP, X-Frame-Options, etc.) |
| Info disclosure | Health endpoint redaction + debug redaction |
| Runaway code | WASM fuel + epoch interruption + tool timeout |
| Memory leaks | Rust’s ownership system + manual memory wipe |
OpenFang is not designed to defend against:
- Physical access to the machine
- OS-level compromise (root/admin access)
- Side-channel attacks (Spectre, Meltdown, etc.)
- Quantum computing attacks (Ed25519 is not post-quantum)
Reporting Security Issues
If you discover a security vulnerability in OpenFang, please report it to: Email: [email protected]PGP Key: Download Please include:
- Description of the vulnerability
- Steps to reproduce
- Impact assessment
- Suggested fix (if any)
Next Steps
Agent Capabilities
Learn about capability-based security
Architecture
Understand the full system architecture
Memory System
Explore the 6-layer memory substrate
Security Hardening Guide
Production security best practices
