Defense in Depth
OpenFang doesn’t bolt security on after the fact. Every layer is independently testable and operates without a single point of failure. If one defense is bypassed, 15 others still stand.Security is compiled in — not configured. You get all 16 systems by default in the single binary.
The 16 Security Systems
1. WASM Dual-Metered Sandbox
Untrusted code (skills, plugins) runs in a WebAssembly sandbox with two independent metering systems:Fuel Metering (Deterministic)
Fuel Metering (Deterministic)
Every WASM instruction consumes “fuel”. When the budget is exhausted, execution halts:This prevents CPU-bound attacks and ensures fair resource sharing.
Epoch Interruption (Wall-Clock)
Epoch Interruption (Wall-Clock)
A watchdog thread kills WASM execution after a wall-clock timeout (default: 30 seconds):This prevents blocking attacks (e.g., infinite loops waiting for I/O).
- Access the filesystem
- Make network requests
- Call system APIs
- Read environment variables
- Escape the sandbox
host_call().
2. Merkle Hash-Chain Audit Trail
Every security-critical action is recorded in an append-only, tamper-evident audit log:1
Record Action
2
Verify Integrity
3
Query via API
3. Information Flow Taint Tracking
Data from untrusted sources (user input, web scraping, LLM output) is labeled and tracked through the execution pipeline:- Shell injection from LLM-generated commands
- Data exfiltration of credentials to network sinks
- Path traversal from user-controlled file paths
4. Ed25519 Signed Agent Manifests
Every agent manifest can be cryptographically signed to verify authenticity:- Manifest tampering by third parties
- Capability escalation by modifying manifests
- Supply chain attacks via skill marketplace
Signing is optional for local development but required for publishing to FangHub.
5. SSRF Protection
Every URL passed toweb_fetch or MCP clients is validated before DNS resolution:
127.0.0.1,localhost,0.0.0.0- Private IP ranges:
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 - Cloud metadata endpoints:
169.254.169.254,metadata.google.internal - DNS rebinding attacks (checked after resolution)
6. Secret Zeroization
API keys and secrets useZeroizing<String> to wipe memory on drop:
- Memory dumps from exposing API keys
- Swap file leakage of credentials
- Core dumps containing secrets
7. OFP Mutual Authentication
The OpenFang Peer Protocol uses HMAC-SHA256 for mutual authentication:- Node A generates a nonce and sends:
HELLO {node_id} {nonce} {hmac} - Node B verifies HMAC, generates its own nonce, replies:
HELLO_ACK {node_id} {nonce} {hmac} - Node A verifies HMAC, replies:
ACK_CONFIRM - Authenticated connection established
- Replay attacks (nonces are single-use)
- Man-in-the-middle (both parties prove knowledge of shared secret)
- Impersonation (HMAC verification fails without secret)
8. Capability Gates
Every tool call is checked against the agent’s capability set:9. Security Headers
The API server sets defense-in-depth HTTP headers on every response:- XSS attacks (CSP)
- Clickjacking (X-Frame-Options)
- MIME sniffing (X-Content-Type-Options)
- Protocol downgrade (HSTS)
10. Health Endpoint Redaction
Public health checks return minimal information:11. Subprocess Sandbox
When agents spawn shell commands, the runtime:- Clears the environment with
env_clear() - Passes only whitelisted variables (PATH, HOME, HAND_ALLOWED_ENV)
- Isolates the process tree (no access to parent or siblings)
- Enforces timeouts with cross-platform kill
12. Prompt Injection Scanner
Skill content (SKILL.md files) is scanned for injection patterns before loading:13. Loop Guard
Detects when an agent is stuck in a tool-call loop:14. Session Repair
Corrupted or malformed message histories are automatically repaired:15. Path Traversal Prevention
All file operations use canonical path resolution:../../../etc/passwd- Symlinks that escape the workspace
- Absolute paths outside the agent’s workspace
16. GCRA Rate Limiter
A cost-aware token bucket rate limiter protects API endpoints:- 100 requests/minute per IP
- 10,000 tokens/hour per user
- Automatic stale bucket cleanup every 5 minutes
Security Scorecard
Testing Security
OpenFang includes property-based security tests:Reporting Vulnerabilities
Email: security@openfang.ai Include:- Description of the vulnerability
- Steps to reproduce
- Affected versions
- Potential impact assessment
- Suggested fix (if any)
- Acknowledgment within 48 hours
- Initial assessment within 7 days
- Fix timeline communicated within 14 days
- Credit given in advisory (unless you prefer anonymity)
Next Steps
Architecture
Understand the 14-crate security boundaries
Agent Lifecycle
See where capability checks happen in the agent loop
RBAC & Permissions
Configure multi-user access control
Audit API
Query the audit log programmatically