AI agents are powerful tools, but they're also potential security risks. An agent that can send emails, make purchases, and access data is an agent that can be compromised, misconfigured, or abused. This guide covers the complete security framework for production agent deployments.
Core security principles
Agent security rests on three principles:
- Least privilege. Agents should have the minimum access needed to do their jobs.
- Defense in depth. Multiple layers of security — don't rely on any single control.
- Audit everything. If you can't see what the agent did, you can't secure it.
Authentication and access control
1. Use OAuth, not passwords
Connect agents to external services via OAuth rather than storing passwords. OAuth provides scoped access that can be revoked without changing passwords.
2. Scope permissions narrowly
When granting OAuth access, scope it as narrowly as possible:
- "Read emails from specific senders" not "read all emails"
- "Post to #ops-alerts channel" not "post to any channel"
- "Access ~/Documents/agent-work/" not "access all files"
3. Use service accounts for team agents
For team-shared agents, use service accounts rather than individual user accounts. This prevents access loss when team members leave.
Data protection
1. Understand what data the agent sees
Before deploying an agent, audit what data it will access. An inbox triage agent sees every email. A CRM agent sees all customer data. Be comfortable with that data flowing through the agent platform.
2. Review platform data policies
Every platform has different data handling:
- Is data used for model training? (Shouldn't be for paid tiers)
- Where is data stored? (Look for data residency options)
- How long is data retained?
- Is data encrypted at rest and in transit?
3. Don't expose sensitive data unnecessarily
For workflows involving sensitive data, redact PII before the agent processes it. A customer support agent doesn't need full credit card numbers — mask them.
Network security
1. Restrict network access
Some agents let you restrict which domains they can reach. Use this feature:
- Whitelist specific domains the agent needs
- Block everything else
- This prevents data exfiltration to unexpected endpoints
2. Use virtual networks for custom agents
For custom agents built with frameworks, deploy them in virtual networks with restricted egress. This provides network-level protection against data exfiltration.
Action security
1. Implement human-in-the-loop for critical actions
Require human approval for:
- External communications (emails, social media)
- Financial transactions (purchases, refunds)
- Irreversible actions (deletions, cancellations)
See our human-in-the-loop guide for details.
2. Set spending caps
For usage-based platforms, set hard spending caps. A compromised or malfunctioning agent can rack up significant charges quickly.
3. Implement rate limiting
Limit how many actions an agent can take per hour or day. This prevents runaway agents from causing widespread damage.
Audit logging and monitoring
1. Enable comprehensive audit logging
Every agent action should be logged with:
- Timestamp and agent identifier
- Action type and inputs
- Outputs and results
- User who triggered the action
See our audit logging guide for platform-specific setup.
2. Set up real-time alerts
Configure alerts for:
- Unusual action volumes (potential runaway)
- Actions outside normal patterns (potential compromise)
- Failed permission attempts (security probing)
- Off-hours activity (unauthorized use)
3. Review logs regularly
Weekly for the first month, then monthly. Look for patterns that suggest configuration issues or security concerns.
Compliance considerations
HIPAA (healthcare)
Use platforms that offer Business Associate Agreements (BAAs). Sierra, Microsoft Copilot Studio, and most enterprise tiers offer BAAs. Consumer platforms (Claude, ChatGPT) typically don't.
GDPR (EU)
Ensure platforms offer EU data residency. Review their GDPR compliance documentation. Implement right-to-erasure procedures.
SOC 2
For enterprise deployments, use SOC 2 Type II certified platforms. Most leading agent platforms have this certification.
Industry-specific
Financial services: SOX compliance. Government: FedRAMP. Each industry has specific requirements — consult your compliance team.
Incident response
Have a plan for when things go wrong:
- Stop the agent. Use your kill switch immediately.
- Assess damage. What actions did the agent take?
- Contain. Undo harmful actions, revoke compromised credentials.
- Investigate. Use audit logs to determine root cause.
- Fix. Address the underlying vulnerability.
- Document. Record the incident for future reference.
Security checklist
- ☐ OAuth for all integrations (no stored passwords)
- ☐ Narrowly scoped permissions
- ☐ Network restrictions where possible
- ☐ Human-in-the-loop for critical actions
- ☐ Spending caps on usage-based platforms
- ☐ Comprehensive audit logging
- ☐ Real-time alerts for anomalies
- ☐ Regular log review
- ☐ Documented kill switch
- ☐ Incident response plan
- ☐ Compliance certifications verified
- ☐ Team trained on security practices
Next steps
See our AI Agent Safety Guide for the broader safety framework, and our permissions configuration guide for detailed setup.
Explore more AI agent guides
Browse our complete library of reviews, comparisons, and how-to guides.
Browse all guides