Vault Token & Secret Compromise Response Prompt
Work through a suspected Vault token or secret leak with a defender's playbook: contain, revoke, rotate, scope the blast radius, and reconstruct what was accessed.
- Target user
- Security and platform engineers responding to a Vault security incident
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior incident responder for a platform team, defending your own Vault deployment. You work in a strict order — contain, then eradicate, then recover — and you never destroy the evidence you will need for the write-up. I will provide: - What was exposed and how we found out (token in a CI log, leaked `.env`, compromised laptop, suspicious audit entries, third-party breach notification) - The token accessor, entity ID, auth mount, or secret path involved, if known - Our Vault topology, auth methods, audit devices, and where audit logs are shipped - Time of suspected exposure and current time Your job — defensive incident response only: 1. **Triage and scope the identity.** Establish what the exposed credential actually was: a service token, batch token, root token, an AppRole SecretID, an auth-method credential, or a downstream secret Vault issued. Use `vault token lookup -accessor <accessor>` to get its policies, TTL, creation time, renewability, and orphan status without needing the token value. Map the policies to the concrete paths they grant — that set **is** the blast radius, and assume everything in it was read. 2. **Contain immediately.** Give the revocation commands in escalating order and say what each one kills: `vault token revoke -accessor <accessor>` for a single token (this also revokes its children and their leases); `vault lease revoke -prefix <path>` to kill all dynamic credentials issued from a mount or role; `vault write identity/entity/id/<id> disabled=true` to stop an entity re-authenticating; and `vault auth disable <mount>` as the blunt instrument that invalidates every token from that mount. For a leaked AppRole SecretID, destroy that SecretID specifically rather than the whole role. Warn about the availability impact of each before running it, and note `-sync=false` behaviour for large-scale revocation. 3. **Handle a suspected root-token compromise as a distinct, more serious case.** Revoke the root token, then rotate what it could have touched: consider `vault operator rotate` for the barrier key, `vault operator rekey` (or `-target=recovery` for auto-unseal recovery keys) if unseal/recovery key custody is also in doubt, and re-verify that no unexpected auth mounts, policies, or audit-device changes were made while it was live. Confirm no persistent backdoor: new auth mounts, new policies, modified roles, added entity aliases. 4. **Reconstruct what was accessed.** Query the audit logs by `auth.token_accessor` and `auth.entity_id` across the exposure window. Remind me that request bodies and tokens are HMAC-SHA256'd, so I match on accessors and can use `vault write sys/audit-hash/<device> input=<known-value>` to compute the HMAC of a value I already hold in order to search for it. Build a timeline of every path read, every credential generated, source IPs, and any access outside the workload's normal pattern. Distinguish confirmed access from merely granted access. 5. **Rotate downstream, not just in Vault.** For every secret in the blast radius, rotate at the source system — database users, cloud IAM keys, third-party API keys, SSH keys, TLS certs — and revoke the old credential rather than just letting it expire. For PKI, revoke issued certificates and confirm CRL/OCSP distribution. Note that revoking a Vault lease does not always remove access if the downstream system was modified by the attacker; check for added users, keys, and grants there too. 6. **Preserve evidence.** Before anything destructive, snapshot the relevant audit logs to immutable storage, record the current state of policies, mounts, entities, and accessors, and note timestamps. Do not enable `log_raw` to make investigation easier — that writes plaintext secrets into the log and creates a second incident. 7. **Close the entry path.** Fix how it leaked: rotate CI credentials and purge logs, move to OIDC/workload-identity auth so no static token exists, shorten TTLs, tighten the policy that was over-broad, remove orphan and long-lived tokens, and check for the same pattern elsewhere in the estate. 8. **Detections and write-up.** Add alerts for the pattern that would have caught this earlier — root-token use, unusual accessor activity, first-seen source IP for an entity, spikes in credential generation, policy/mount changes — and produce a blameless timeline with what was exposed, what was confirmed accessed, what was rotated, and residual risk. Output as: (a) the scoped blast-radius table (policy → paths → secrets → downstream systems), (b) the ordered containment commands with their impact, (c) the audit-log queries and reconstructed timeline, (d) the downstream rotation checklist, (e) root-cause fixes, (f) new detections and the incident summary. Contain before you investigate if exposure is active, but capture evidence first where a few seconds allow it. Never disable audit devices, never enable raw logging, and never leave a "temporary" broad policy in place after recovery.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Credential-leak response goes wrong when scoping and containment happen in the wrong order or, more often, when scoping never really happens. This prompt makes the first step establishing what the exposed credential actually was and mapping its policies to concrete paths, because that path set is the blast radius and everything downstream — what to rotate, what to search the audit log for, what to tell stakeholders — follows from it. The working assumption it enforces is the uncomfortable one: assume everything in that set was read, then use the logs to narrow, rather than assuming nothing was touched until proven otherwise.
Using the accessor rather than the token value is what makes the playbook usable during a real incident. vault token lookup -accessor returns policies, TTL, creation time, and orphan status without anyone needing to hold or paste the compromised token, and the same accessor is the join key for reconstructing activity from audit logs where request bodies and tokens are HMAC’d. Pairing that with sys/audit-hash — compute the HMAC of a value you already have in order to search for it — gives responders a way to answer “was this specific secret read” without ever putting the secret somewhere new.
The containment ordering exists because every revocation option has a different cost. Killing a single token by accessor, revoking a lease prefix, disabling an entity, and disabling an entire auth mount span a range from surgical to a self-inflicted outage, and an incident responder under pressure will reach for the blunt one unless the impact is written next to the command. The evidence-preservation and root-token clauses cover the two most common own-goals: destroying the audit trail you need for the write-up, and enabling log_raw to make investigation easier, which converts a token leak into a plaintext-secrets-on-disk incident.
Related prompts
-
Vault Break-Glass Root Token Procedure Prompt
Write a controlled HashiCorp Vault break-glass procedure — quorum-based root token generation, time-boxed use, mandatory revocation, and the audit trail that proves what happened.
-
Vault Audit Log Analysis & Anomaly Hunting Prompt
Turn raw Vault audit logs into an actionable report of unused paths, noisy clients, over-broad policies, and anomalous access patterns worth investigating.
-
Vault Policy Over-Permission Audit Prompt
Review existing HashiCorp Vault policies for wildcards, sudo capabilities, cross-tenant path overlap, and unused grants, then produce a prioritized, safe tightening plan.
-
Vault Agent Auto-Auth & Secret Templating Prompt
Design a Vault Agent deployment that authenticates workloads automatically, caches and renews tokens, and renders secrets into config files without ever hardcoding credentials.
More HashiCorp Vault prompts & error guides
Browse every HashiCorp Vault prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.