1. Threat model
Three attack vectors
User prompt. Content the agent reads. Tool responses. Any of them can lure the LLM into a call you didn't intend.
2. Authentication
App passwords
Per-user, revocable.
JWT
Short-lived, scoped.
OAuth
Best for multi-tenant.
API keys
Server-to-server only.
3. Permissions
A service user with role = Editor + capability filters. Never use admin. Never reuse a real user's password.
4. Sandboxing
Tools that touch the filesystem run in containers. Tools that touch credentials run in a separate process with restricted env.
5. Prompt injection
Strip aggressively
Sanitize HTML before returning it to the agent. Reject tool responses with role-changing content. Never let user-controlled strings into your tool's instruction context.
6. Audit logging
Log every tool call with args, response, latency, and user. Stream to your usual sink. Hold for at least 90 days.