Revoking agent keys
Expiry is the main control on an agent's key. Turnkey does not know when a
task ends, so nothing revokes a key on its own; api-key delete revokes it
at once. Revoke through a scoped revoker user, never with root: root signs
only to create the revoker and its policy.
Reference
- resources:
user,user tag,api-key, andpolicy createrecords and flags. - authentication:
profile createandwhoamirecords. - activities:
activity getandpolicy evaluationson a refused or pending delete.
Rules
- Deleting a local key file revokes nothing. Only
api-key deletedoes. - Turnkey keeps one permanent credential per user. Deleting a user's last
non-expiring key fails with
api_error400. A session agent keeps its anchor key, so deleting its session key succeeds. To cut a user off entirely, delete the user with managing-identities. - Policy sees
activity.params.user_idandactivity.params.api_key_idsonACTIVITY_TYPE_DELETE_API_KEYS, not the target's tags. The revoker ALLOW lists every target user id; resolve each withuser getbefore writing it. Never list a root-quorum user. - The revoker carries only the
revokertag. Deleting a key is aCREDENTIALactivity, so the credential DENY on theagent,broker, orprovisionertag overrides the revoker ALLOW. - A leaked revoker credential can delete keys on the listed users and do nothing else: no signing, minting, or export.
Instructions
Inputs: the root profile (admin), AGENT_USER_ID for each agent user to
cover (one quoted entry each in the in [...] list), and the host that runs
the revoker.
Create the revoker's profile and tag. On the revoker host, generate its credential and send
<!-- example: revoking.profile-create -->data.publicKey(PUBLIC_KEY) to root:tk --message-format json --organization-id ORG_UUID profile create --profile-name revokerRoot creates the tag and sets
<!-- example: revoking.tag-create -->REVOKER_TAGtodata.activity.result.createUserTagResult.userTagId:tk --profile admin --message-format json user tag create --name revokerCreate the revoker user. Root.
<!-- example: revoking.user-create -->tk --profile admin --message-format json user create --user-name revoker --tag-name revoker --public-key PUBLIC_KEYSet
REVOKER_USER_IDtodata.activity.result.createUsersResult.userIds[0].Allow deletion on the listed agents. Root. Show each id from
<!-- example: revoking.policy -->user getfirst:tk --profile admin --message-format json user get --id AGENT_USER_ID tk --profile admin --message-format json policy create --name revoker-delete-agent-keys --effect allow \ --consensus "approvers.any(user, user.tags.contains('${REVOKER_TAG}'))" \ --condition "activity.type == 'ACTIVITY_TYPE_DELETE_API_KEYS' && activity.params.user_id in ['${AGENT_USER_ID}']"A new agent user is added to this list, as to the provisioner's mint ALLOW.
Revoke. Revoker host. List first and pick the key to cut off; on a session agent it is the key with a non-null
<!-- example: revoking.delete -->expiresAt:tk --profile revoker --message-format json api-key list --user-id AGENT_USER_ID tk --profile revoker --message-format json api-key delete --user-id AGENT_USER_ID --id API_KEY_IDProceed when
data.activity.result.deleteApiKeysResult.apiKeyIdsnamesAPI_KEY_ID. The deleted key now failswhoamiwithunauthorized; a sidecar holding it stops signing.Hand off. Report
REVOKER_USER_ID, the policy id, the covered agent user ids, and each deleted key id. A revoked session agent resumes only after a new key is provisioned. Stop.
Verified by
| Examples | Test |
|---|---|
| revoking.profile-create, revoking.tag-create, revoking.user-create, revoking.policy, revoking.delete | api_keys::revoking_agent_keys_scoped_revoker_deletes_listed_session_key |
| revoking.policy, revoking.delete | api_keys::revoking_agent_keys_credential_deny_blocks_tagged_revoker |
Troubleshooting
api-key deletefailsunauthorized403: the target user is not in the ALLOW's list, or the revoker also carries a tag with the credential DENY. Check withpolicy evaluationswhen an activity id exists. Do not widen the condition to every user; do not fall back to root.api-key deletefailsapi_error400 "missing valid credential": the key is the user's last permanent credential. Register a replacement first, or delete the user.whoamiwith the deleted key still succeeds: the delete is pending or ran against another key id.activity getthe delete and compare ids.
Related Skills
- managing-identities: rotate a key without losing access, or delete the whole user.
- provisioning-session-agent: mint the next session key after a revocation.
- managing-policies: debug a denied revocation.
- inspecting-agents: list which agents hold keys and when each expires.