APS-62Recommended
Give each key the least power
Give every key, account and service only the access it needs. Use a separate key for each service and each environment.
How to do it
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 says. Replace the stored keys that remain as rotate secrets automatically says. For more depth, see a service user and a sandbox. 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.
How to 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.
Sources
Related rules
- AID-25 Keep production credentials away from agents in AI-assisted development
- ENG-26 Keep secrets in a secrets store in Engineering
- OPS-32 Run each service as its own user in Operations and observability
- INF-17 Keep no long-lived access keys in Infrastructure and environments
- INF-18 Give every role the least it needs in Infrastructure and environments
- INF-27 Rotate secrets automatically in Infrastructure and environments
- DSK-14 Ask for the fewest permissions the extension needs in Desktop apps and extensions
- OPS-33 Lock the service in a sandbox in Operations and observability
- OPS-45 Back up off the machine in Operations and observability
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/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.