Quick Start
security=True:
SecurityConfig
The unified entry point for all security features:Tool Policy
Control which tools an agent can call. Auto-injects aToolGuardrail.
str
default:"full"
"deny" blocks all tools, "allowlist" permits only listed tools, "full" allows everything.Set[str]
Tools permitted in
allowlist mode. Ignored in other modes.bool
default:"false"
In
full mode, block tools in the dangerous registry (shell, file mutation, code execution).Dangerous Tools Registry
The built-inDEFAULT_DANGEROUS_TOOLS set includes:
Rate Limiting
Sliding-window rate limiting for interface messages. Attach as an interface hook.int
default:"10"
Maximum messages allowed per sliding window.
int
default:"60"
Window duration in seconds.
int
default:"3"
Number of rate limit violations before triggering a lockout.
int
default:"300"
Lockout duration in seconds (default: 5 minutes).
Custom Key Extraction
By default, the rate limiter identifies users viasender_id, user_id, or platform_user_id on the message object. Override with a custom function:
Content Defense
Detect and block prompt injection attempts. Auto-injects anInputGuardrail.
Prompt Injection Detection
ThePromptInjectionDetector scans for 16+ patterns including:
- Role override attempts (“you are now”, “act as”)
- Instruction manipulation (“ignore previous instructions”, “forget your instructions”)
- System prompt extraction (“reveal your system prompt”, “repeat your instructions”)
- Format injection (
[INST],<<SYS>>, XML role tags)
XML Content Wrapping
Wrap untrusted content (tool results, knowledge) in XML tags with nonce-based boundary protection:SSRF Protection
Prevent Server-Side Request Forgery in tool HTTP calls.10.x, 172.16-31.x, 192.168.x), loopback (127.x, ::1), link-local (169.254.x), and cloud metadata endpoints (169.254.169.254).
Environment Sanitization
Strip dangerous environment variables before spawning subprocesses.LD_PRELOAD, DYLD_INSERT_LIBRARIES), Python startup (PYTHONSTARTUP, PYTHONPATH), shell injection (BASH_ENV, IFS), and more.
Security Audit
Run an automated security audit on any agent configuration:- Exposed secrets in instructions (API key patterns)
- Dangerous tools without
ToolPolicy - Missing auth on interfaces
- Missing input/output guardrails
- World-readable workspace files
- MCP servers with broad permissions
- Missing rate limiting on interfaces
- Shell/exec tools without confirmation
Scoring
- Base: 100
- Critical finding: -20
- Warning finding: -5
- Final: clamped to [0, 100]