The first API key most teams create for a new service is the one with every permission, made in a hurry to get a demo working. Six months later it is in three CI pipelines, a staging server and a teammate's shell history, and nobody remembers which of them actually needed which permission.
For a service that runs untrusted code, that key is worth more to an attacker than most. This post goes through how to scope keys for sandbox access: what each permission covers, which ones common jobs need, and how expiry and rotation fit in. The specifics are Sandscale's, from the authentication docs and the Sandboxes API reference , but the reasoning carries over to any provider.
The rules the server enforces
Some of the hygiene is not optional on Sandscale, which helps. Per the authentication docs:
A key acts as you, with the permissions you pick. It can only hold permissions you hold yourself when you create it; asking for more is refused with 403 scope_exceeds_creator .
Every key expires.…