Runbook: Rotating a Leaked Agent Token¶
Endpoints: POST /v1/agents/:id/rotate-token · POST /v1/agents/:id/report-leaked-token (#1295)
Symptoms¶
- A token appeared somewhere it shouldn't have (a log line, a public repo commit, a Slack message, a CI artifact, a support ticket screenshot).
- A
deny_stormordata_exfil_patternincident (see those runbooks) suggests the agent may be compromised, even without direct evidence of a leaked token. - An
agent_token_leak_detectedSOC event appeared in the audit/event stream from an automated leak-detection integration (e.g. a secret scanner webhook feedingPOST /v1/ingest).
Investigation¶
- Confirm which agent owns the token and its current status:
- Check the tenant's auto-rotate setting.
report-leaked-tokenonly rotates automatically iftenants.auto_rotate_token_on_leak_enabledis true (default: enabled). If it's disabled, reporting records the leak but does not rotate — you must callrotate-tokenexplicitly afterward. - Review recent decisions for this agent to scope the blast radius before rotating (rotation doesn't retroactively undo anything the leaked token already did):
Remediation¶
There are two entry points depending on whether you already know it's compromised or are reporting a signal:
-
You know the token leaked — rotate immediately (always allowed, no leak-policy gating):
The response includes the new plaintext token exactly once — capture it immediately and update the agent's deployed configuration. AegisAgent never re-displays it and never pushes it anywhere (not over a webhook, not in logs) — store it yourself right away or you'll need to rotate again to get a fresh one. -
An automated signal detected a possible leak — report it (lets the tenant's auto-rotate policy decide):
This always emits ancurl -s -X POST -H "Authorization: Bearer $AGENT_TOKEN" \ "http://127.0.0.1:8080/v1/agents/<agent_id>/report-leaked-token" \ -d '{"reason": "gitleaks CI scan flagged a match"}'agent_token_leak_detectedSOC event (so it's visible to the SOC regardless of the rotation outcome), and rotates the token only if auto-rotate is enabled for the tenant.
The old token is rejected immediately on rotation — there is no grace period, so make sure you have the new token ready to deploy before (or immediately after) rotating to avoid an outage for the legitimate agent process.
Verification¶
- The old token is rejected on the very next
/v1/authorizecall using it:401. GET /v1/audit/events?agent_id=<agent_id>shows anagent_token_rotatedevent with yourreason.- The legitimate agent process, reconfigured with the new token, successfully calls
/v1/authorizeagain. - If you used
report-leaked-tokenand auto-rotate was disabled, confirm you followed up with an explicitrotate-tokencall — the leak report alone does not protect you.