Security Best Practices
Guidelines for securing your Agent Action Firewall deployment and protecting your AI agents.
Defense in Depth
Multiple layers of security controls
Zero Trust
Verify every action, trust nothing
Full Auditability
Tamper-evident logging of all actions
Least Privilege
Minimal permissions for each agent
API Key Management
Key Rotation
Rotate API keys regularly and immediately if compromised:
- Generate a new key in Settings → API Keys
- Update your agent configuration with the new key
- Verify the agent works with the new key
- Revoke the old key
Key Storage
- Never commit API keys to version control
- Use environment variables or secrets managers (Vault, AWS Secrets Manager)
- Restrict key access to only necessary services
- Use separate keys for development, staging, and production
Key Scoping
Create dedicated keys for each agent with minimal permissions:
// Good: Dedicated key per agent
const orderAgent = new AgentFirewallClient({
apiKey: process.env.ORDER_AGENT_KEY,
agentId: 'order-processor',
});
const supportAgent = new AgentFirewallClient({
apiKey: process.env.SUPPORT_AGENT_KEY,
agentId: 'support-bot',
});Policy Configuration
Default Deny
Start with a deny-all policy and explicitly allow needed operations:
package aaf.policies
default decision = {"action": "deny", "reason": "No matching allow rule"}
# Explicitly allow specific operations
decision = {"action": "allow"} {
input.tool == "http_proxy"
input.operation == "GET"
allowed_domains[input.params.url]
}
allowed_domains[url] {
startswith(url, "https://api.trusted.com/")
}Risk-Based Approvals
Require human approval for high-risk operations:
decision = {
"action": "require_approval",
"risk_level": "high",
"reason": "Write operations require approval"
} {
input.operation in ["POST", "PUT", "DELETE"]
not input.context.pre_approved
}Rate Limiting
Limit action frequency to prevent abuse:
decision = {
"action": "deny",
"reason": "Rate limit exceeded"
} {
rate_limit_exceeded(input.agent_id)
}Network Security
SSRF Protection
The HTTP proxy connector automatically blocks:
- Private IP ranges (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
- Localhost (127.0.0.1, ::1)
- Cloud metadata endpoints (169.254.169.254)
- Internal hostnames
Domain Allowlisting
Restrict outbound requests to approved domains:
// In your policy or connector config
const allowedDomains = [
'api.stripe.com',
'api.github.com',
'slack.com',
];TLS Requirements
- Always use HTTPS for API communication
- Enforce TLS 1.2+ for all connections
- Validate SSL certificates (no self-signed in production)
Data Protection
Sensitive Data Handling
- Redaction: Automatically redact sensitive fields from logs
- Encryption: Sensitive params encrypted at rest
- Retention: Configure audit log retention policies
Configuring Redaction
// Redact sensitive fields before logging
const sensitiveFields = [
'password',
'api_key',
'token',
'credit_card',
'ssn',
];Audit Trail Integrity
Audit events use cryptographic hash chaining for tamper evidence. Each event includes a hash of the previous event, creating an immutable chain.
Access Control
Role-Based Access
| Role | Permissions |
|---|---|
admin | Full access, manage users, policies, billing |
approver | Approve/reject actions, view audit |
auditor | Read-only access to audit trail |
viewer | View dashboard and basic stats |
Organization Isolation
Multi-tenant isolation is enforced at the database level with Row-Level Security (RLS). Each organization can only access its own data.
Monitoring and Alerting
Security Events to Monitor
- Failed authentication attempts
- Policy denials (especially repeated)
- Unusual action patterns
- High-risk action submissions
- Approval timeouts
Setting Up Alerts
// Example: Alert on repeated denials
if (denialCount > 10 && timeWindow < '5m') {
sendAlert({
severity: 'warning',
message: 'Unusual denial rate for agent',
agent_id: agentId,
});
}Incident Response
If an API Key is Compromised
- Immediately revoke the key in Settings → API Keys
- Review audit logs for unauthorized actions
- Generate a new key and update your agent
- Investigate how the key was exposed
- Document the incident
Exporting Evidence
Use Proof Packs to export forensic evidence:
# Export proof pack for an action
curl -H "Authorization: Bearer $TOKEN" \
"https://api.agentactionfirewall.com/v1/proof-pack/action-id" \
-o proof-pack.zipCompliance
Audit Requirements
- All actions are logged with timestamps
- Hash chaining provides tamper evidence
- Proof packs support compliance exports
- Configurable retention periods
Data Residency
Cloud-hosted data is stored in your selected region with full encryption at rest and in transit.
Security Checklist
- API keys stored in secrets manager, not code
- Default-deny policies configured
- SSRF protection enabled
- Domain allowlist configured
- TLS enforced for all connections
- Sensitive field redaction enabled
- Audit log retention configured
- Monitoring and alerting set up
- Incident response plan documented
- Regular key rotation schedule
Need Help?
For security questions or to report vulnerabilities, contact info@agentactionfirewall.com.