Skip to main content

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:
Every WASM instruction consumes “fuel”. When the budget is exhausted, execution halts:
This prevents CPU-bound attacks and ensures fair resource sharing.
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).
Skills cannot:
  • Access the filesystem
  • Make network requests
  • Call system APIs
  • Read environment variables
  • Escape the sandbox
They can call capability-checked host functions via host_call().

2. Merkle Hash-Chain Audit Trail

Every security-critical action is recorded in an append-only, tamper-evident audit log:
Each entry’s hash includes the previous hash, forming a chain. Tampering with any entry breaks the chain.
1

Record Action

2

Verify Integrity

3

Query via API

The audit log is append-only. There is no API to delete or modify entries. This ensures forensic integrity.

3. Information Flow Taint Tracking

Data from untrusted sources (user input, web scraping, LLM output) is labeled and tracked through the execution pipeline:
Before sensitive operations (shell execution, network requests), the runtime checks if tainted data is reaching a restricted sink:
Example: Blocking Shell Injection
This prevents:
  • 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:
This prevents:
  • 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 to web_fetch or MCP clients is validated before DNS resolution:
Blocked targets:
  • 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 use Zeroizing<String> to wipe memory on drop:
This prevents:
  • 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:
Handshake flow:
  1. Node A generates a nonce and sends: HELLO {node_id} {nonce} {hmac}
  2. Node B verifies HMAC, generates its own nonce, replies: HELLO_ACK {node_id} {nonce} {hmac}
  3. Node A verifies HMAC, replies: ACK_CONFIRM
  4. Authenticated connection established
This prevents:
  • 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:
The kernel enforces this before the runtime executes any tool. Denied calls are audited.

9. Security Headers

The API server sets defense-in-depth HTTP headers on every response:
This mitigates:
  • 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:
This prevents reconnaissance by unauthenticated attackers.

11. Subprocess Sandbox

When agents spawn shell commands, the runtime:
  1. Clears the environment with env_clear()
  2. Passes only whitelisted variables (PATH, HOME, HAND_ALLOWED_ENV)
  3. Isolates the process tree (no access to parent or siblings)
  4. Enforces timeouts with cross-platform kill

12. Prompt Injection Scanner

Skill content (SKILL.md files) is scanned for injection patterns before loading:
Skills with detected patterns are rejected at load time.

13. Loop Guard

Detects when an agent is stuck in a tool-call loop:
When triggered, the guard injects a warning message and allows one more iteration before halting.

14. Session Repair

Corrupted or malformed message histories are automatically repaired:
This prevents session corruption attacks and gracefully handles LLM output errors.

15. Path Traversal Prevention

All file operations use canonical path resolution:
Blocked attempts:
  • ../../../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:
Default limits:
  • 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

Do NOT open public GitHub issues for security vulnerabilities.
Email: security@openfang.ai Include:
  • Description of the vulnerability
  • Steps to reproduce
  • Affected versions
  • Potential impact assessment
  • Suggested fix (if any)
Response timeline:
  • 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