Responding when a cloud account is abused
Unit 4 of 5 in Cloud logging, detection and response.
You will be able to walk the steps of containing a stolen cloud credential, scope the damage from logs, and say what to automate and what to leave to a person.
Lesson
Response is a loop that starts before the incident
NIST published SP 800-61 Revision 3 in April 2025. It replaces Revision 2 and frames incident response as part of everyday cybersecurity risk management, using the NIST Cybersecurity Framework 2.0. NIST says the goal is to help organizations prepare for incident responses, reduce the number and impact of incidents, and improve incident detection, response and recovery.
A playbook is a written plan for one kind of incident. Microsoft's guidance says playbooks are developed, reviewed and validated before incidents occur, so responders do not have to design a workflow under pressure, and that each includes prerequisites (the logging, roles and permissions needed before an investigation can start), a workflow, a checklist and investigation steps. A sample AWS playbook for credential compromise follows the same shape in five parts: prepare, detect and analyze, contain, eradicate and recover, and post-incident activity. Its own disclaimer says it is a template, not official AWS documentation, so adapt it before you use it.
Prepare: access and evidence before you need them
The sample playbook lists what to have ready. A break-glass role in each account with narrow permissions to list and delete access keys, attach deny policies and query the audit log, tested in advance. A way for the response team to assume it with MFA from a trusted account, checked at least quarterly. A deny-all policy prepared in advance. A separate account for analysing logs. And log storage protected with Object Lock or versioning so an intruder with administrator rights cannot rewrite the trail.
Its reason is practical: providing break-glass access during an active compromise wastes time, may be blocked by the intruder and risks errors under pressure. The unit on trustworthy logs is the same idea applied to evidence.
Contain a credential: disable it, do not delete it
The playbook gives a simple decision. If a credential is confirmed in use by an intruder, or exposed publicly (for example in a public code repository) even without confirmed use, contain it immediately, because the intruder may already hold it. If activity is only anomalous and could be legitimate, investigate first and escalate to help if it is still unclear after about 30 minutes.
For a long-term access key, deactivate it rather than deleting it. Deactivating keeps the key's ID for audit log searches, shows you what legitimate software breaks, and can be reversed quickly if the alert was a false positive. Then watch the audit log for 30 minutes to confirm the key is no longer used. A console password has no deactivate switch, so the playbook attaches an explicit deny-all inline policy to the user and checks whether the intruder registered an MFA device.
Temporary credentials need more thought. The playbook says role session credentials stay valid until they expire (by default up to one hour, configurable up to twelve), and that changing a role's trust policy stops new sessions but does not end existing ones. To end existing sessions, AWS's IAM guide describes revoking them: it attaches an inline policy that denies all actions to anyone who assumed the role before a chosen time. This applies to all users of the role, so legitimate users and applications are cut off too, and AWS notes you cannot revoke sessions for a service-linked role.
Scope with the logs, then remove persistence
After containment, the playbook says to look for what the intruder may have left behind: additional access keys on the same or other users, new roles whose trust policy allows assumption from an external account, and functions or other compute resources with an attached role. If the credential could assume roles in other accounts, check the audit log for role assumption calls to those accounts and repeat the containment there.
Record every containment action with a timestamp, who did it and what it affected. The playbook says this supports the post-incident timeline and any regulatory inquiry. This is also where the first unit pays off: if the data events or the Region you need were never logged, this step is where you find out.
Automate the alert, keep a person on the decision
GuardDuty automatically publishes findings as events to Amazon EventBridge in near real time, and EventBridge can deliver them to targets such as a notification topic, a function or a data stream. GuardDuty keeps findings for 90 days, and EventBridge or an export to storage lets you keep them longer.
What should you automate? Our reasoning, built on the playbook's warning that containment steps cut off legitimate users: automate notifying the right person, opening a ticket and collecting evidence, because those are safe to repeat. Be careful about automating destructive steps such as revoking sessions for a shared role, because a wrong guess becomes an outage. The EventBridge lab below builds the safe half: alert now, contain with a human in the loop.
Review afterwards
The sample playbook ends with a blameless review. It suggests building a timeline within 24 to 48 hours while the audit log is easy to query, and measuring time to detect, time to notify, time to contain and time to recover. It also asks questions worth borrowing: how was the credential exposed, why did it have the permissions it had, what would have detected it sooner, and what single change would most reduce the chance of a repeat.
It adds a detection gap analysis: for every alert that did not fire or was not acted on, write the root cause, the fix and an owner. Feed the result back into preparation. That loop, not any single tool, is what makes a team better each time.
Key points
- Prepare access, deny policies and protected evidence before an incident; tested break-glass access beats improvised access.
- Contain confirmed or exposed credentials at once; investigate unconfirmed anomalies first.
- Deactivate access keys instead of deleting them, deny console users, and revoke role sessions with care because every user of the role is cut off.
- After containment, look for new keys, new trusting roles and new compute with roles, and check other accounts.
- Automate notification and evidence collection; keep destructive steps behind a person.
- Finish with a blameless review: timeline, metrics and a detection gap analysis.
Sources
- NIST SP 800-61 Rev. 3: Incident Response Recommendations and Considerations for Cybersecurity Risk Management
- AWS sample incident response playbooks (GitHub): IAM Credential Compromise
- AWS IAM User Guide: Revoke IAM role temporary security credentials
- Amazon GuardDuty User Guide: Processing GuardDuty findings with Amazon EventBridge
- Microsoft Learn: Plan incident response
Lecture
Alert triage like a SOC analyst: A talk on the six-step routine for working an alert, which is where cloud response starts.
Practice in the labs
Investigate a cloud intrusion from its audit log, build the alert-and-notify half of a response, then practise two clean-up steps: reviewing role trust and rotating keys.
- Investigate a cloud intrusion with CloudTrail and GuardDuty (capstone): You follow an ordered burst of API calls from one access key in Event history, separate read-only recon from a denied write, and finish with an incident write-up. Uses your own AWS free-tier account.
- Auto-respond to GuardDuty findings with EventBridge (alert now, contain with a human in the loop): You route GuardDuty findings through EventBridge to an email alert, with a human in the loop for containment. Uses your own free-tier AWS account.
- Review every IAM role trust policy in an AWS account: who can assume what, and which trusts are too wide: You review a whole account's role trust policies for risky external trust, the persistence check from the playbook. Runs offline on a sample export.
- Rotate AWS IAM access keys with zero downtime: You rotate an access key without downtime, the recovery step after a key is deactivated. Runs on LocalStack on your machine.
Knowledge check
- Why does the sample playbook say to deactivate a compromised access key instead of deleting it? Answer: Deactivation keeps the key ID for audit log searches, shows what breaks and can be reversed. The playbook's reasons are to observe impact, keep the key ID for investigation in the audit log, and be able to reverse the step quickly if the alert is a false positive.
- An intruder has role session credentials. You edit the role's trust policy. What happens to the sessions already issued? Answer: They keep working until they expire; the change only stops new sessions. The playbook states that modifying the trust policy prevents new sessions but valid credentials continue until they expire; AWS's revoke-sessions guide describes the deny-before-a-time policy that ends existing ones.
- Which response step is safest to automate fully? Answer: Notifying the on-call person and opening a ticket with the finding details. Notification and evidence collection are safe to repeat. Revoking sessions for a shared role cuts off every legitimate user and application, so a person should decide.
- A credential is found on a public code site, but no unusual activity has been seen. What does the playbook suggest? Answer: Contain it at once, because the intruder may already hold it. The playbook's decision tree treats an exposed credential like a confirmed one: the intruder may already have it and be waiting, so time matters more than certainty.
Back to the syllabus or see all classes.
Related
- Cloud logging, detection and response
- Investigate a cloud intrusion with CloudTrail and GuardDuty (capstone)
- Auto-respond to GuardDuty findings with EventBridge (alert now, contain with a human in the loop)
- Review every IAM role trust policy in an AWS account: who can assume what, and which trusts are too wide
- Rotate AWS IAM access keys with zero downtime
- All classes
- Free cyber labs