Skip to content
Pro lab · Incident response

Leaked Cloud Key Lab

A cloud access key is loose: in a public commit, a CI build log, a mobile app, a contractor's laptop or a container image layer. Scripts find public keys within minutes, so assume it is already being used. You have the pager.

Scope the key, deactivate it without breaking the production job that shares it, and read a trail where your own automation and the attacker use the same key. Then remove every key, user and trust change they left in every region, revoke the sessions that outlive a rotation, move the workload to short-lived credentials, and tell counsel what the logs can prove. Your cloud IR lead reacts to every call.

0s

On-call brief

A Kestrel Logistics access key is loose. You have the pager.

Dana Okafor · Cloud IR lead

I'm Dana, cloud IR lead. A leaked key is a race: scripts find public keys in minutes, so assume it's already being used. We'll work it in order: scope the key, contain it without breaking what depends on it, read the trail, rip out whatever the attacker left behind, move the workload off long-lived keys, and give counsel facts they can use. I'll tell you what I'd have done after every call.

Six stages, every case

  1. 1Scope the keyWhich identity, what it can do, when it was last used.
  2. 2ContainDeactivate before you delete, and know what breaks.
  3. 3Investigate the trailSeparate attacker calls from your own automation.
  4. 4EradicatePersistence keys, users, roles; revoke sessions.
  5. 5RecoverShort-lived credentials and guardrails.
  6. 6NotifyWhat the logs prove, and who decides.

Five ways a key leaks (the seed picks your cases)

Public repoCI logMobile appContractor laptopContainer image

The traps Dana is watching for

  • Deleted before checking what uses it
  • Missed the attacker-created key
  • Forgot the other regions
  • Rotated without revoking sessions

Pro: 2 cases at tier 1, 2. Higher tiers add more of your own automation to the trail, a stopped trail in one region, and quieter persistence such as a second key on an existing user or a role that trusts another account. Decisions score 2 for the best call and 1 for a defensible one; the trail scores each event and its tactic. Each stage counts equally. Clear 75% to pass. You finish with an incident timeline and remediation checklist.

Fictional company. Account IDs like 111122223333, access key IDs ending in EXAMPLE, .example domains and RFC 5737 IPs. The AWS behaviour described is real.

Same seed and level = same cases and option order.

Loading…

Sample report · illustrative data

Sample result: leaked cloud key lab scorecard

Example scorecard for a run where an access key leaked into a code repository. The lab scores six stages from 0 to 10 each: scope, contain, investigate the trail, eradicate, recover and notify.

Overall

Score
78 / 100 (47 of 60 stage points)
Band
Contained, with gaps
Pass bar
75%
Weakest stage
Eradicate

By stage

StageScoreWhat it tests
1. Scope the key9 / 10Which identity, what it can do, when it was last used
2. Contain8 / 10Deactivate before you delete, and know what breaks
3. Investigate the trail7 / 10Separate attacker calls from your own automation
4. Eradicate6 / 10Persistence keys, users and roles in every region; revoke sessions
5. Recover9 / 10Short-lived credentials and guardrails
6. Notify8 / 10What the logs prove, and who decides

Where points were lost

Typical slips at this band: a second access key created on an existing user was missed, one region was never swept, or sessions issued from the key outlived the rotation. The debrief names the specific calls and the order to rehearse: scope, deactivate and deny, read the trail, sweep every region, revoke sessions, then clean up.

Made-up example data. Your own run uses your inputs. Downloads of the full report need Pro.

TL;DR

What this lab is

5 points
  • An on-call incident lab for a leaked cloud access key: 5 seeded cases (a public repo, a CI build log, a mobile app, a contractor laptop and a public container image), each worked through 6 stages.
  • Scope the key from the credential report and last-used data, contain it without deleting it first, and decide what to do about the production job that depends on it.
  • Read a CloudTrail-style trail (80 events across the cases) where your own automation uses the same key as the attacker: GetCallerIdentity probes, bucket enumeration, new access keys, GPU instances in unused regions, StopLogging, snapshot sharing and GetObject downloads.
  • Eradicate every persistence key, user and role trust change, revoke sessions that outlive a rotation, move CI to OIDC federation and workloads to roles, and give counsel facts about what the logs can and cannot prove.
  • A cloud IR lead reacts to every decision, four traps are tracked across the run, ?seed= replays a run, and the debrief exports the incident timeline and remediation checklist as Markdown.

Frequently asked questions

What should I do first when an AWS access key is leaked?

Find out whose key it is (the IAM credential report or GetAccessKeyLastUsed, from your own session), then set it to Inactive and attach an explicit deny-all policy to the identity. Inactive stops the key at once, can be undone if a production job breaks, and keeps the key ID tied to the user for the investigation. The deny also covers temporary credentials already minted from the key. Then find what legitimately used it and move those jobs to short-lived credentials before you delete anything.

Should I delete or deactivate a leaked access key?

Deactivate first and delete later. Deleting cannot be undone, gives no time to discover the nightly job or depot app that used the same key, and does nothing about sessions or second keys the attacker already created. Delete once every legitimate consumer has moved and the investigation has what it needs.

Does rotating a leaked key end the attacker's access?

Not on its own. Attackers commonly mint temporary credentials (GetFederationToken, GetSessionToken, AssumeRole) and create a second access key, a new user, a console login or a role trust change. Temporary credentials can keep working until they expire, up to 36 hours for federation tokens. Deny the parent user, revoke role sessions with an aws:TokenIssueTime condition (what the console's "Revoke active sessions" adds), remove every attacker-created credential, and confirm AccessDenied in CloudTrail.

How do I tell attacker calls from my own automation in CloudTrail?

Read the source IP, user agent and identity before the API name. The same key may be used by your pipeline from your CI or NAT addresses with an SDK or Terraform agent, and by the attacker from a hosting provider with a different client (a Kali Linux CLI is common enough that GuardDuty has a finding for it). The same API, such as GetCallerIdentity, CreateAccessKey or CreateSnapshot, can be legitimate or malicious depending on who called it.

Why does the attacker launch instances in regions I do not use?

Because nobody looks there. Owners check their home regions, see nothing and assume all is well. Attackers spread GPU instances across unused regions, sometimes stop the trail there first, and add automation that relaunches them. Sweep every enabled region by script, read CloudTrail Event history (which keeps 90 days of management events per region even without a trail), and deny unused regions with an organization policy.

How can I tell whether data was taken with a leaked key?

Only object-level logs can show reads: CloudTrail data events that include reads, or S3 server access logs. Management events show bucket-level calls such as ListBuckets or GetBucketPolicy, and snapshot sharing, but not individual object downloads. Check the data event selector too: write-only data events cannot show reads. If nothing recorded reads, say you cannot rule out access, and give counsel the facts.

Do we have to notify anyone after a leaked key?

That is a decision for counsel, made from the facts: what data was reachable or confirmed read, how many people, the time window and which logs exist. Record when you became aware, because some clocks run from awareness. For example, under the EU GDPR (Article 33) a controller notifies the supervisory authority without undue delay and, where feasible, within 72 hours of becoming aware of a personal data breach, unless it is unlikely to result in a risk to people. Other laws and contracts set their own tests and deadlines. This lab does not give legal advice.

What replaces long-lived access keys afterwards?

Credentials that expire by design. CI pipelines use OIDC federation to a role whose trust policy pins the repository and branch; workloads use instance, task or pod roles; mobile apps get per-user, short-lived credentials or presigned URLs from a backend; people use an identity provider with MFA and short sessions; third parties assume a role with an external ID.

How are the levels and seeds different?

Rookie plays one case at tier 1 with an asset inventory and hints. Pro plays two cases at tiers 1 and 2. Elite plays three cases at tiers 2, 3 and 3 with no asset inventory. Higher tiers add more of your own automation to the trail, a trail stopped in one region, and quieter persistence such as a second key on an existing user, a bucket policy for another account or a role that trusts the attacker's account. The seed picks the cases and the order of the options, so a ?seed= link gives a colleague the same run.

Is any of this real?

No. The company, people, contractors and accounts are invented. Account IDs are documentation-style placeholders such as 111122223333, every access key ID ends in EXAMPLE in the style of the AWS documentation's AKIAIOSFODNN7EXAMPLE, domains use the reserved .example top-level domain and IP addresses come from the RFC 5737 documentation ranges. The AWS behaviour and API names are real and written to be accurate.

Who can use it?

The page is public. It needs Pro, $5/month or $40/year. Exporting the Markdown incident record is part of Pro.

The tools people use most on PlayCISO.

All tools