Security Best Practices
MoFA provides multiple security layers to protect your AI agent deployments. This guide covers credential management, plugin sandboxing, runtime security, and best practices for production deployments.Credential Management
Environment Variables
Store API keys and secrets in environment variables:Secret Management Systems
For production, use dedicated secret managers:Credential Rotation
Implement automatic credential rotation:Rhai Script Sandboxing
Rhai scripts provide runtime programmability but require careful configuration:Resource Limits
Function Whitelisting
Script Validation
Execution Timeout
WASM Plugin Sandboxing
WASM provides strong isolation for untrusted plugins:WASI Configuration
Resource Limits
Plugin Verification
Network Security
TLS for LLM APIs
Certificate Pinning
Request Rate Limiting
Database Security
Connection Encryption
Prepared Statements
MoFA’s persistence layer uses parameterized queries:Row-Level Security
Distributed Security
mTLS for Dora Nodes
Message Authentication
Input Validation
Prompt Injection Prevention
Schema Validation
Audit Logging
Structured Logging
Security Event Logging
Production Checklist
- API keys stored in environment variables or secret manager
- Credential rotation implemented
- Rhai scripts have resource limits configured
- WASM plugins use WASI sandboxing
- TLS enabled for all external connections
- Database connections encrypted
- Input validation on all user inputs
- Rate limiting configured
- Audit logging enabled
- Security monitoring alerts configured
- Regular security updates scheduled
- Secrets never logged or in error messages
- Different credentials for dev/staging/prod
- Row-level security for multi-tenant databases
Security Updates
Stay informed about security updates:- Watch the repository: Enable notifications for security advisories
- Subscribe to releases: Monitor new releases for security patches
- Review SECURITY.md: Check the security policy regularly
- Update dependencies: Run
cargo auditto check for vulnerabilities
Reporting Security Issues
Report security vulnerabilities privately:- GitHub Security Advisories: https://github.com/mofa-org/mofa/security/advisories
- Email: [email protected]
- Do not create public issues for security vulnerabilities
See Also
- Persistence - Secure database configurations
- Distributed Runtime - Secure distributed communication
- Monitoring - Security event monitoring