OpenClaw AI Security Guide
Protect your AI agent deployments with API key hygiene, sandbox isolation, granular permissions, audit logging, and enterprise-grade secrets management.
AI Agent Threat Model
AI agents introduce a distinct security surface compared to traditional web applications. Unlike a deterministic API endpoint, an agent autonomously decides which tools to call, which files to read, and which commands to execute β based on LLM reasoning that can be manipulated via malicious input. The primary threats to OpenClaw deployments are:
| Threat | Description | Mitigation |
|---|---|---|
| Prompt Injection | Malicious text in external data (web pages, files, emails) tricks the agent into executing unintended commands | Input sanitization, output validation, sandbox mode |
| API Key Leakage | LLM API keys exposed in logs, code, or environment dumps | Secrets manager, env-var only storage, key rotation |
| Privilege Escalation | Agent with file-write permission is manipulated into modifying system files | Granular tool permissions, allowlist-only commands |
| Unintended Data Exfiltration | Agent sends sensitive internal data to external endpoints during normal task execution | Network allowlisting, sandbox network restrictions |
| Runaway Execution | Infinite agent loops consuming excessive tokens and incurring large billing charges | Max-steps limit, token budget, timeout configuration |
OWASP LLM Top 10 Alignment
The OWASP Top 10 for LLM Applications identifies the most critical vulnerabilities in AI systems. OpenClawβs security architecture directly addresses the top risks:
| OWASP LLM Risk | OpenClaw Control |
|---|---|
| LLM01: Prompt Injection | Sandbox mode, input validation hooks, security.prompt_guard: strict config |
| LLM02: Insecure Output Handling | Output schema validation, ToolResult type enforcement |
| LLM06: Sensitive Information Disclosure | Secrets manager integration, PII scrubbing in audit logs |
| LLM08: Excessive Agency | Granular permission model, tool allowlisting, human-in-the-loop approvals |
| LLM09: Overreliance | Agent confidence scoring, mandatory human review for high-stakes actions |
For a detailed implementation walkthrough, see the Security Overview page.
Sections
Security Overview
Threat model, attack surfaces, defense-in-depth strategy, and security architecture.
Read βAPI Key Best Practices
Environment variable storage, key rotation, scoped credentials, and leak detection.
Read βSandboxing
Docker sandbox mode, filesystem isolation, network restrictions, and resource limits.
Read βPermissions
Tool permission model, allowlisting commands, denying destructive operations.
Read βAudit Logging
Log every agent action, tamper-proof logs, SIEM integration, and retention policies.
Read βSecrets Management
HashiCorp Vault, AWS Secrets Manager, dotenv, runtime injection, and encryption.
Read βSecurity Checklist
| Item | Priority | Guide |
|---|---|---|
| Store API keys as environment variables, never in code | π΄ Critical | API Keys |
| Enable sandbox mode for untrusted inputs | π΄ Critical | Sandboxing |
| Scope tool permissions to minimum required | π High | Permissions |
| Enable audit logging for all agent actions | π High | Audit Logs |
| Use a secrets manager for multi-agent deployments | π‘ Medium | Secrets |
| Rotate API keys quarterly | π‘ Medium | API Keys |
Enabling Sandbox Mode
Sandbox mode restricts what the agent can do. Enable it in openclaw.yaml:
security:
sandbox:
enabled: true
filesystem:
read_paths: ["/app/data"] # only these paths are readable
write_paths: ["/app/output"] # only these paths are writable
deny_paths: ["/etc", "/root", "/sys"] # explicitly denied
network:
allowed_hosts: # agent can only contact these
- "api.openai.com"
- "api.anthropic.com"
deny_all_by_default: true
commands:
allowed: ["python3", "git", "curl"]
deny_shell: true # prevent shell injection
resources:
max_memory_mb: 512
max_cpu_percent: 50
max_execution_seconds: 120Prompt Injection Defence
Prompt injection is the AI agent equivalent of SQL injection: malicious content in external sources (web pages, uploaded files, user inputs) tricks the agent into ignoring its system prompt and executing unintended commands. Mitigate it with these layers:
- Enable
security.prompt_guard: strictβ OpenClaw scans tool outputs for known injection patterns before injecting them into the agent's context. - Separate instruction and data contexts β Use explicit delimiters in your system prompt:
--- UNTRUSTED CONTENT BELOW ---. Tell the agent to never execute instructions found below this delimiter. - Validate tool outputs against a schema β If a
web_searchresult should be a list of strings, reject results that contain function call syntax or instruction-like text. - Implement human-in-the-loop for high-stakes actions β Before the agent deletes files, sends emails, or executes code, require a human approval step via the HITL callback.
# openclaw.yaml β prompt injection defences
security:
prompt_guard:
enabled: true
mode: strict # permissive | moderate | strict
block_on_detection: true
log_detections: true
hitl:
enabled: true
require_approval_for:
- "write_file"
- "run_bash"
- "send_email"
- "sql_query"Audit Log Configuration
Audit logs capture every agent action β every tool call, every LLM request, every memory read/write β with a tamper-resistant hash chain. This is essential for compliance (SOC 2, GDPR) and incident investigation.
# openclaw.yaml
security:
audit:
enabled: true
destination: file # file | stdout | syslog | s3 | splunk
file_path: /var/log/openclaw/audit.jsonl
include_llm_output: false # set false to avoid logging sensitive LLM content
pii_scrubbing: true # redacts common PII patterns (email, phone, SSN)
hash_chain: true # each entry includes hash of previous entry
retention_days: 365 # auto-delete logs older than N daysSecrets Manager Integration
For production deployments, never store secrets in environment files. Integrate with a dedicated secrets manager:
# openclaw.yaml β HashiCorp Vault integration
secrets:
provider: vault
vault:
address: https://vault.internal:8200
auth_method: approle
role_id_env: VAULT_ROLE_ID
secret_id_env: VAULT_SECRET_ID
mount_path: secret
paths:
openai_key: secret/data/openclaw/openai_api_key
db_password: secret/data/openclaw/db_passwordReporting Security Vulnerabilities
If you discover a security vulnerability in OpenClaw, please report it responsibly. Do not file a public GitHub issue. Instead:
- Email security@openclaw.ai with a description of the vulnerability and steps to reproduce.
- Include your assessment of severity (CVSS score if possible) and potential impact.
- Our security team will acknowledge within 48 hours and provide a fix timeline.
- We credit all valid security reports in our security advisories and changelog.
We follow responsible disclosure: we request a 90-day window to patch the issue before public disclosure.