Hive is designed with a strict “local-first” security model, but because it executes arbitrary AI-generated code (via Sandboxes and Colonies), multiple layers of hardening are applied.
1. Secrets Management
The Default Model
- Keys (Anthropic, OpenAI, etc.) are saved in
~/.hive/hive.db(mode0600). - The UI masks these values. The Express API never returns cleartext keys to the client.
The Zero-Rest Model (Environment-Backed Secrets)
If storing API keys in SQLite is unacceptable for your threat model:
- Clear the keys from the UI.
- Enter references like
env:MY_COMPANY_OPENAI_KEYin the settings fields. - Launch Hive from an environment populated by your shell, OS secret store, or deployment secret manager.
server/lib/secrets.jsresolves theenv:prefix, meaning the keys exist only in memory, never on disk.
2. API Hardening
The Hive backend (server/) is protected against unauthorized access.
- Authentication: Gated by
HIVE_AUTH_TOKEN. Mutating requests (POST, PUT, DELETE) and WebSocket upgrades are rejected without it. - CORS: Restricted to
localhostand whatever is specified inHIVE_ALLOWED_ORIGINS. - Rate Limiting: Built-in bounding (default 60 requests per minute) on mutating routes to prevent brute-force attacks or runaway scripts.
3. Sandbox Hardening
Agents running code in the sandbox are highly restricted.
See server/lib/sandbox.js.
- Network:
network=noneby default. Agents cannot exfiltrate data or download malicious packages unless explicitly grantedHIVE_SANDBOX_NETWORK=bridge. - Capabilities: Docker containers are run with
--cap-drop=ALLandno-new-privileges. - Resource Limits: Configurable memory and CPU limits prevent fork-bombs or memory leaks from crashing the host machine.
- Path Confinement: The sandbox is mounted specifically to
/workspace. It cannot access the host filesystem outside of this mount.
4. The LiteLLM Gateway
For enterprise or multi-user setups, the bundled LiteLLM gateway (found in gateway/) provides the ultimate layer of control.
By proxying all requests through LiteLLM:
- Spend Limits: You can enforce hard USD caps on individual agents via virtual keys.
- Failover: Ensure reliable Colony runs by routing through
gateway/hive-smart, which will seamlessly fallback to another model if the primary API rate-limits or goes down. - Caching: Identical prompt executions can be cached, significantly reducing costs and latency for repetitive agent tasks.