AI agents need credentials to access tools, APIs, and data sources. How you manage these credentials determines the blast radius when something goes wrong. A compromised agent with admin credentials is a catastrophic failure. A compromised agent with read-only, scoped credentials is a contained incident.
Every credential should have the minimum permissions needed for the agent's task:
Each agent instance should have its own credentials. Sharing credentials between agents means you cannot revoke one without affecting others, and you cannot attribute actions to a specific agent in the audit trail.
Prefer temporary credentials over long-lived ones:
If a credential is stolen, it stops working after the expiration period.
Never store credentials in code, configuration files, or environment variables in plain text on disk:
// Good: fetch from secrets manager
const dbPassword = await secretsManager.getSecret('agent-db-password');
// Bad: hardcoded
const dbPassword = 'hunter2';
Rotate credentials on a regular schedule:
Automate rotation so it happens without manual intervention.
Track how credentials are used:
Authensor receipts record which tools were called but not the underlying credentials (credentials should not appear in logs). Monitor credential usage at the infrastructure level through API gateway logs and database audit logs.
Have a process for immediately revoking an agent's credentials:
# Revoke all credentials for a specific agent
vault token revoke -accessor <agent-accessor>
Test this process regularly. When an incident occurs, you need to revoke credentials in minutes, not hours.
Even with good credential management, assume credentials can be compromised. Layer credential controls with:
Explore more guides on AI agent safety, prompt injection, and building secure systems.
View All Guides