Secret Rotation and Management
Learn how to rotate secrets safely, organize them effectively, and manage per-environment credentials.Why Rotate Secrets?
Security reasons:- Limit blast radius if compromised
- Meet compliance requirements (PCI DSS, SOC 2)
- Best practice for production systems
- Critical secrets (production API keys): Every 30 days
- Standard secrets: Every 90 days
- Database passwords: Every 90 days
- OAuth tokens: When revoked by provider
Safe Rotation Process
Step-by-Step
1. Create new secret with different name:Why This Works
- Zero downtime
- Easy rollback (keep old secret temporarily)
- Clear audit trail
What NOT to Do
❌ Don’t try to “update” a secret- You can’t update values (by design)
- Must create new secret
- Keep old secret for 48 hours
- Allows rollback if issues
Environment-Specific Secrets
KnoxCall supports two approaches for managing secrets across environments:Approach 1: Environment Configurations (Recommended)
Best for: Single secret with different values per environment Create one secret with environment-specific values:- Create a secret:
stripe_api_key - In the secret detail page, select environment from dropdown
- Add value for each environment:
- Switch to “production” → Enter live key
- Switch to “staging” → Enter test key
- Switch to “development” → Enter dev key
- Route in “production” environment → Uses production value
- Route in “staging” environment → Uses staging value
- Hard fail if missing: Route returns error if secret lacks the environment value
- No fallbacks or defaults (prevents accidental production key usage in dev)
- ✅ One secret name across all environments
- ✅ Impossible to accidentally use wrong key
- ✅ Clear environment isolation
- ✅ Simplified route configuration
Approach 2: Naming Convention (Legacy)
Best for: Backward compatibility or when you prefer separate secrets Create different secrets per environment:- ❌ Must update route config when changing environments
- ❌ Possible to reference wrong secret in wrong environment
- ❌ More secrets to manage
Comparison
| Feature | Environment Configs | Naming Convention |
|---|---|---|
| Secret count | 1 per service | 3+ per service |
| Route config | Same everywhere | Different per env |
| Safety | Hard fail if missing | Silent failure possible |
| Ease of use | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
| Recommended | ✅ Yes | Legacy support |
Organization Strategies
Group by Service
Group by Environment
Multiple Secrets in One Route
Inject multiple credentials:Monitoring Secret Usage
Track Usage
In the Secrets page, check:- Last Used - When secret was last injected
- Associated Routes - Which routes use this secret
Find Unused Secrets
Look for:- Last used > 30 days ago
- No associated routes
- Test/temporary secrets
Set Up Alerts
Get notified when:- Secret not used in 30+ days
- Multiple failed auth attempts (might indicate compromised key)
- Secret approaching rotation date
Common Patterns
API Key Rotation
Database Password Rotation
OAuth Token Refresh
Troubleshooting
Routes failing after rotation:- Verify new secret value is correct
- Check all routes were updated
- Look for cached old values
- Roll back to old secret if needed
- Check spelling (case-sensitive)
- Verify secret exists in Secrets page
- Confirm route is using correct name
- New secret value might be wrong
- API key might be expired/revoked
- Test secret value directly with provider
Rotation Checklist
Use this checklist for each rotation:- Document which routes use this secret
- Generate new credential from provider
- Create new secret with v2 suffix
- Update all routes in staging
- Test thoroughly in staging
- Update routes in production
- Monitor for 48 hours
- Verify no errors
- Delete old secret
- Update documentation
- Schedule next rotation (calendar)
Next Steps
- Set up environments for per-env secrets
- Learn about securing your routes
- Configure monitoring and alerting
📊 Statistics
- Level: intermediate
- Time: 10 minutes
🏷️ Tags
secrets, security, rotation, management