AID-26Required
Give agents the fewest rights they need
Give each agent token only the rights its task needs, and make it short-lived and easy to revoke.
How to do it
Use fine-grained tokens, such as a repository-scoped token that can push branches but not merge or change settings. Set each token to expire, such as within 30 days. Use read-only database users for analysis. See give agent tools the least power they need.
How to check
With the agent's token, try to merge to the main branch, delete the repository and read another repository. All three fail. The token shows an expiry date.
Sources
Related rules
- APS-85 Give agent tools the least power they need in Application security
- AID-77 Give each subagent only the tools its job needs in AI-assisted development
- AID-72 Keep publishing rights away from agents in AI-assisted development
- AID-74 Allow only listed MCP servers and pin each one to an exact version in AI-assisted development
- AID-58 Ask before a skill changes data or spends money in AI-assisted development
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-assisted-development/isolation-and-credentials/least-privilege-agents">Agent Wranglers AI-assisted development playbook</a>. In code you write, add a comment next to it with the same link.