---
title: "Give each key the least power · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/secrets-and-configuration/least-privilege-keys
id: APS-62
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1128
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Give each key the least power

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-62
- Level: Recommended
- Chapter: [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md)
- Rule: Give every key, account and service only the access it needs. Use a separate key for each service and each environment.
- Check: The agent uses the app's own database account to try a forbidden action, such as creating a table. The database refuses it. A list of keys in the secret store shows no key shared by two services or by staging and production. A read-only job's key fails to write a test object.
- How: Let the website's database user read and write its own tables, but not drop them or create users. Give a job that only reads a bucket a key that cannot write to it. Where the platform offers workload identity, use its short-lived credentials instead of a stored key, as [keep no long-lived access keys](https://agentwranglers.se/playbook/infrastructure/identity-and-access/no-long-lived-keys.md) says. Replace the stored keys that remain as [rotate secrets automatically](https://agentwranglers.se/playbook/infrastructure/configuration-and-secrets/automatic-secret-rotation.md) says. For more depth, see [a service user](https://agentwranglers.se/playbook/operations/running-the-service/service-user.md) and [a sandbox](https://agentwranglers.se/playbook/operations/running-the-service/service-sandbox.md). Give the server a backup key that can write new backups but never delete them, so an attacker on the server cannot remove them. See [off-site backups](https://agentwranglers.se/playbook/operations/disaster-recovery/off-site-backups.md).

## Sources

- [OWASP Secrets Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)

## Related rules

- AID-25 [Keep production credentials away from agents](https://agentwranglers.se/playbook/ai-assisted-development/isolation-and-credentials/no-production-credentials.md) in AI-assisted development
- ENG-26 [Keep secrets in a secrets store](https://agentwranglers.se/playbook/engineering/running-in-production/secrets-store.md) in Engineering
- OPS-32 [Run each service as its own user](https://agentwranglers.se/playbook/operations/running-the-service/service-user.md) in Operations and observability
- INF-17 [Keep no long-lived access keys](https://agentwranglers.se/playbook/infrastructure/identity-and-access/no-long-lived-keys.md) in Infrastructure and environments
- INF-18 [Give every role the least it needs](https://agentwranglers.se/playbook/infrastructure/identity-and-access/least-privilege-roles.md) in Infrastructure and environments
- INF-27 [Rotate secrets automatically](https://agentwranglers.se/playbook/infrastructure/configuration-and-secrets/automatic-secret-rotation.md) in Infrastructure and environments
- DSK-14 [Ask for the fewest permissions the extension needs](https://agentwranglers.se/playbook/desktop-apps/browser-extensions/extension-permissions.md) in Desktop apps and extensions
- OPS-33 [Lock the service in a sandbox](https://agentwranglers.se/playbook/operations/running-the-service/service-sandbox.md) in Operations and observability
- OPS-45 [Back up off the machine](https://agentwranglers.se/playbook/operations/disaster-recovery/off-site-backups.md) in Operations and observability

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/secrets-and-configuration/least-privilege-keys">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Keep secrets out of the browser](https://agentwranglers.se/playbook/application-security/secrets-and-configuration/secrets-out-of-browser.md)
- Next: [Keep storage buckets private](https://agentwranglers.se/playbook/application-security/secrets-and-configuration/private-storage-buckets.md)
- [Secrets and configuration](https://agentwranglers.se/playbook/application-security/secrets-and-configuration.md)
