Security
Security
The SDK provides layered security through HTTP Basic Authentication for all requests and optional per-function token validation for sensitive operations.
Security for voice AI agents requires thinking beyond traditional web application security. Voice interfaces introduce unique attack vectors: social engineering through conversation, toll fraud, unauthorized data access via verbal manipulation, and compliance concerns around recorded conversations.
This chapter covers the security mechanisms built into the SDK and best practices for building secure voice agents.
Threat Model for Voice AI Agents
Understanding potential threats helps you design appropriate defenses:
Security Layers
The SignalWire Agents SDK implements multiple security layers:
Layer 1: Transport Security (HTTPS)
- TLS encryption in transit
- Certificate validation
Layer 2: HTTP Basic Authentication
- Username/password validation
- Applied to all webhook endpoints
Layer 3: Function Token Security (Optional)
- Per-function security tokens
- Cryptographic validation
HTTP Basic Authentication
Every request to your agent is protected by HTTP Basic Auth.
How It Works
- SignalWire sends request with
Authorization: Basic <base64-encoded-credentials>header - Agent extracts header and Base64 decodes credentials
- Agent splits the decoded string into username and password
- Agent compares credentials against configured values
- Result: Match returns 200 + response; No match returns 401 Denied
Configuring Credentials
Option 1: Environment Variables (Recommended for production)
Option 2: Let SDK Generate Credentials (Development)
If you don’t set credentials, the SDK:
- Uses username:
signalwire - Generates a random password on each startup
- Prints the password to the console
Credentials in Your Agent
Function Token Security
For sensitive operations, enable per-function token validation.
How Function Tokens Work
SWML Generation (GET /)
- Agent generates SWML
- For each secure function, generate unique token
- Token embedded in function’s
web_hook_url
Function Call (POST /swaig)
- SignalWire calls webhook URL with token
- Agent extracts token from request
- Agent validates token cryptographically
- If valid, execute function
- If invalid, reject with 403
Enabling Token Security
Token Generation
Tokens are generated using cryptographic hashing:
HTTPS Configuration
For production, enable HTTPS:
Using SSL Certificates
Using a Reverse Proxy (Recommended)
Most production deployments use a reverse proxy for SSL:
Traffic Flow: SignalWire → HTTPS → nginx/Caddy (SSL termination) → HTTP → Your Agent (localhost:3000)
Benefits:
- SSL handled by proxy
- Easy certificate management
- Load balancing
- Additional security headers
Set the proxy URL so your agent generates correct webhook URLs:
Security Best Practices
1. Never Commit Credentials
2. Use Strong Passwords
3. Validate All Inputs
4. Use Secure Functions for Sensitive Operations
5. Log Security Events
6. Implement Rate Limiting
Configuring SignalWire Webhooks
When setting up your phone number in SignalWire:
Voice AI Security Considerations (OWASP-Style)
Voice AI agents face unique security challenges. Apply these principles:
1. Never Trust Voice Input
Voice input can be manipulated through:
- Prompt injection via speech
- Playing audio recordings
- Background noise injection
Mitigation:
2. Limit Function Capabilities
Only give the agent functions it needs:
3. Verify Caller Identity
Don’t assume caller ID is trustworthy for sensitive operations:
4. Implement Action Confirmation
For destructive or financial operations, require verbal confirmation:
Audit Logging
Comprehensive logging is essential for security monitoring and incident response.
What to Log
Log Security Events
Incident Response
Prepare for security incidents with these practices:
1. Detection
Monitor for anomalies:
- Unusual call volumes
- High function call rates
- Failed authentication attempts
- Large transaction attempts
- After-hours activity
2. Response Plan
Document how to respond:
- Identify: What happened and scope of impact
- Contain: Disable affected functions or agent
- Investigate: Review audit logs
- Remediate: Fix vulnerabilities
- Recover: Restore normal operation
- Document: Record lessons learned
3. Emergency Shutdown
Implement ability to quickly disable sensitive operations:
Production Hardening Checklist
Before deploying to production:
Infrastructure
- HTTPS enabled with valid certificates
- Strong Basic Auth credentials (32+ characters)
- Reverse proxy configured (nginx, Caddy)
- Firewall rules limit access
- Monitoring and alerting configured
Application
- All sensitive functions use
secure=True - Input validation on all function parameters
- Rate limiting implemented
- Audit logging enabled
- Error messages don’t leak internal details
Prompts
- Security boundaries defined in prompts
- Confirmation required for sensitive actions
- System prompt instructions protected
- No excessive capability disclosure
Operational
- Credentials rotated regularly
- Logs collected and monitored
- Incident response plan documented
- Regular security reviews scheduled
- Dependencies kept updated
Summary
Next Steps
You now understand the core concepts of the SignalWire Agents SDK. Let’s move on to building agents.