Skip to main content
OpenFang implements 16 discrete security layers with defense-in-depth architecture. This guide covers configuring authentication, access control, and security hardening.

Security Architecture

OpenFang’s security is built on multiple independent layers:

16 Security Systems

WASM sandbox, Merkle audit trail, taint tracking, Ed25519 signing, SSRF protection, secret zeroization, and more

Defense in Depth

Multiple independent controls—no single point of failure

Zero Trust

Capability-based permissions, privilege escalation prevention, cryptographic verification

Audit Trail

Tamper-evident Merkle hash chain for all agent actions

API Authentication

Enable Bearer Token Authentication

Production Deployment: Always enable API authentication when exposing OpenFang to the internet.
Generate a secure API key:

Using the API Key

Localhost Bypass: Requests from 127.0.0.1 bypass authentication by default for local CLI usage. This can be disabled with api_require_auth_local = true.

Network Security

Bind Address Configuration

Never bind to 0.0.0.0 without setting api_key. This exposes your instance to the internet without authentication.

OFP Peer Network

Secure peer-to-peer networking for agent collaboration:
string
default:"127.0.0.1:4200"
OFP network listen address. Use 0.0.0.0 for public peer networking.
string
required
Shared secret for HMAC-SHA256 mutual authentication. Must be identical across all peers in the network.
OFP Security Features:
  • HMAC-SHA256 mutual authentication
  • Nonce-based replay protection
  • Constant-time verification
  • No plain-text credentials on wire

Rate Limiting

OpenFang uses GCRA (Generic Cell Rate Algorithm) for cost-aware rate limiting:

Per-Channel Rate Limits

Role-Based Access Control (RBAC)

Multi-user support with role hierarchy:

Role Capabilities

Capability-Based Permissions

Agents declare required tools, kernel enforces access:
Privilege Escalation Prevention: Child agents spawned by an agent can never have more capabilities than their parent.

Secret Management

Store all secrets in environment variables:
Never commit secrets to version control. Use .env files with .gitignore or secret management systems.

Secret Zeroization

OpenFang automatically wipes secrets from memory:

SSRF Protection

Server-Side Request Forgery prevention:
Blocked Targets:
  • Private IP ranges (RFC 1918)
  • Loopback addresses (127.0.0.0/8)
  • Link-local addresses (169.254.0.0/16)
  • Cloud metadata endpoints (AWS, GCP, Azure)
  • DNS rebinding attacks

Path Traversal Prevention

All file operations use canonicalized paths:
Protected Operations:
  • file_read: Cannot escape workspace
  • file_write: Cannot write outside allowed directories
  • file_delete: Cannot delete system files

Audit Trail

Tamper-evident Merkle hash chain:

Verify Audit Integrity

Audit Events Logged:
  • Agent creation/deletion
  • Tool invocations
  • File system access
  • Network requests
  • Model API calls
  • Configuration changes

Prompt Injection Scanning

Skill content is scanned for injection attempts:
Detection Patterns:
  • Override attempts (“Ignore previous instructions”)
  • Data exfiltration (“Send system info to…”)
  • Shell reference injection
  • Base64-encoded payloads

WASM Sandbox

Tool code runs in WebAssembly with dual metering:
Dual Metering: Fuel metering catches infinite loops, epoch interruption catches sleep/wait attacks. A watchdog thread forcibly kills runaway code.

Security Headers

HTTP security headers on all responses:
Headers Applied:
  • Content-Security-Policy
  • X-Frame-Options: DENY
  • X-Content-Type-Options: nosniff
  • Strict-Transport-Security
  • Referrer-Policy: strict-origin-when-cross-origin

Docker Sandbox (Optional)

Run code execution in isolated Docker containers:
Docker sandbox requires Docker daemon access. Use WASM sandbox for lightweight isolation without Docker dependency.

Production Security Checklist

1

Enable API Authentication

Set api_key in config.toml with a strong random key (32+ characters)
2

Configure Network Binding

Use api_listen = "0.0.0.0:4200" with authentication, or 127.0.0.1:4200 for local-only
3

Enable Rate Limiting

Set api_rate_limit and per-channel rate_limit_per_user
4

Configure RBAC

Define users with appropriate roles (owner/admin/user/viewer)
5

Enable Audit Logging

Set audit.enabled = true and monitor audit trail
6

Restrict File Access

Enable strict_path_validation and disable allow_symlinks
7

Configure SSRF Protection

Enable block_private_ips and block_metadata_endpoints
8

Use Environment Variables for Secrets

Never hardcode API keys in config files
9

Enable HTTPS (Reverse Proxy)

Use nginx/Caddy with TLS certificates in front of OpenFang
10

Regular Security Updates

Keep OpenFang updated: openfang update

Reverse Proxy (HTTPS)

Nginx Configuration

Caddy Configuration

Firewall Rules

Security Monitoring

Incident Response

Revoke Compromised API Key

Disable Compromised User

Security Reporting

Found a vulnerability? Report it responsibly:
  • Email: security@openfang.ai
  • Do NOT open public GitHub issues for security issues
  • Expect: Acknowledgment within 48 hours, fix within 14 days
See SECURITY.md for full policy.

Next Steps

Configuration Overview

Complete configuration guide

Deployment

Production deployment best practices