Access Control
Access control restricts who can interact with your bot across different channels.Channel-Level Access Control
Each channel has anallowFrom field that controls which users can interact:
Whitelist of user identifiers. Behavior depends on nanobot version:
- v0.1.4.post3 and earlier: Empty array = allow all users
- Source / newer versions: Empty array = deny all users; use
["*"]to allow all
Examples by Channel
Workspace Sandboxing
Restrict all file and shell operations to the agent’s workspace directory.When
true, restricts all agent tools to the workspace directory:- File read/write/edit operations
- Directory listings
- Shell command execution (cwd set to workspace)
Workspace Sandboxing
- Agent cannot read files outside workspace
- Agent cannot write files outside workspace
- Shell commands run with workspace as working directory
- Path traversal attempts (e.g.
../../../etc/passwd) are blocked
Group/Channel Policies
Control how the bot responds in group chats and channels.Slack Group Policy
How to respond in group channels:
"mention"— Only respond when @mentioned"open"— Respond to all messages"allowlist"— Only respond in specific channels
Allowed channel IDs (used when
groupPolicy is "allowlist").Slack Group Policies
Discord Group Policy
How to respond in Discord servers:
"mention"— Only respond when @mentioned (default)"open"— Respond to all messages
Discord Group Policy
Matrix Room Policy
How to respond in Matrix rooms:
"open"— Respond to all messages (default)"mention"— Only respond when mentioned"allowlist"— Only respond in allowed rooms
Allowed room IDs (used when
groupPolicy is "allowlist").Accept
@room mentions in mention mode (broadcasts to all room members).Matrix Room Policy
Tool Security
Shell Execution
Maximum execution time for shell commands (seconds). Prevents runaway processes.
Extra directories to append to
PATH environment variable. Use this to grant access to system utilities (e.g. /usr/sbin for ufw firewall commands).Shell Execution Limits
MCP Tool Timeouts
Timeout in seconds for MCP tool calls. Prevents hanging tool operations.
MCP Timeouts
Email Security
Explicit consent flag required to enable email access. Must be
true for the email channel to function.If
false, the bot reads emails but doesn’t send automatic replies. Useful for monitoring or analysis mode.Maximum email body characters to process. Prevents processing of extremely large emails.
Email Security
WhatsApp Bridge Security
Shared token for WhatsApp bridge authentication. Recommended for production.
WhatsApp Bridge Token
Matrix E2EE
Enable end-to-end encryption support. When enabled, the bot can participate in encrypted rooms.
Stable device ID needed to persist E2EE session state across restarts. Without this, the bot loses access to encrypted messages after restart.
Maximum attachment size in bytes (default: 20MB). Set to
0 to block all media.Matrix E2EE
Complete Security Configuration
Example production configuration with all security features enabled:Security Checklist
Production Deployment
Production Deployment
- Enable
tools.restrictToWorkspace: true - Configure
allowFromfor all enabled channels - Set appropriate
groupPolicyfor multi-user channels - Use strong API keys and rotate them regularly
- Set
gateway.host: "127.0.0.1"if not exposing publicly - Configure tool timeouts to prevent resource exhaustion
- Enable E2EE for Matrix if handling sensitive data
- Use bridge tokens for WhatsApp connections
- Set email consent flag explicitly
- Review and minimize MCP server permissions
Development/Testing
Development/Testing
- Use separate API keys for dev/prod
- Set restrictive
allowFromeven in dev - Test access control with unauthorized users
- Verify workspace sandboxing blocks escapes
- Test tool timeouts with slow operations
- Monitor logs for security warnings
Multi-User Environments
Multi-User Environments
- Use
groupPolicy: "mention"or"allowlist" - Configure separate DM and group policies
- Maintain user allowlists per channel
- Document user access procedures
- Audit access logs regularly
Best Practices
Principle of Least Privilege
Grant only the minimum permissions needed:
- Use
restrictToWorkspacein production - Set narrow
allowFromlists - Prefer
"mention"policy over"open"in groups - Limit MCP server access to required directories
Defense in Depth
Use multiple security layers:
- Channel-level access control
- Workspace sandboxing
- Tool execution timeouts
- Network isolation (firewall rules)
- Regular credential rotation
Audit and Monitor
Track security-relevant events:
- Review gateway logs regularly
- Monitor for unauthorized access attempts
- Track tool execution patterns
- Audit file access within workspace
- Set up alerts for suspicious activity
Next Steps
Configuration Overview
Return to configuration overview
Providers
Configure LLM provider authentication