LESSON 61 · ADVANCED8 min read

Cloud Attacks, Logging, and Incident Response

Recognise the identity, storage, metadata, network, and container paths attackers use in the cloud, then investigate and contain an incident with durable logs and least privilege.

OWASP Top 10 · MITRE ATT&CK · NIST CSF 2.0Free to readModule 12 of 14
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Apply the shared responsibility model and identify the cloud control plane as a primary attack surface.
  • Recognise IAM privilege escalation, public storage, metadata SSRF, exposed keys, and weak network controls.
  • Use CloudTrail, GuardDuty, Defender for Cloud, Security Command Center, and audit logs for detection.
  • Run a cloud incident response with containment, evidence preservation, credential rotation, and recovery.

01The Control Plane Is the New Front Door

Cloud security starts with a map of responsibility. The provider secures the physical facility, hardware, hypervisor, and the managed service's underlying platform. The customer secures identities, permissions, data, applications, and configuration. The split moves with the service: on virtual machines you patch the guest operating system; on a managed database the provider patches the engine but you still control access, schema, backups, and network exposure.

Most cloud incidents do not begin with a hypervisor escape. They begin with an identity that can call an API. A leaked access key, an overprivileged role, a public storage policy, or a permissive security group can expose data without exploiting a single line of application code. The control plane is the new front door, and identity is the lock.

Account structure matters. Separate production from development, centralise logging in a dedicated account, and use organisation-level guardrails. Know which accounts exist, who can create identities, where data lives, and which regions are allowed. An inventory that is out of date is worse than no inventory, because it creates false confidence.

02Attack Paths You Must Recognise

Privilege escalation in cloud IAM often uses legitimate features. A role that can pass a role to a compute service may be able to run code with that role's permissions. A user who can create a new policy version or attach a policy can grant themselves more power. A user who can update a trust policy can let an external identity assume a role. These are not bugs in the provider; they are consequences of excessive permissions.

Public storage is another recurring path. A bucket or object that allows anonymous access can be read, and sometimes written, by anyone who learns the address. Block public access at the account and bucket level, review bucket policies and ACLs, and use access analyzers. 'Public' should be a deliberate decision with an owner, a purpose, and a review date, not a default that someone forgot to change.

The instance metadata service is a special risk. Workloads on a virtual machine can fetch temporary credentials from a link-local address. If an application has a server-side request forgery flaw, an attacker may be able to reach that address and steal the instance role's credentials. Require IMDSv2 where available, set the hop limit to one, and avoid long-lived keys on the instance. The same pattern exists in other clouds under different names.

Network and container mistakes compound the problem. A security group open to 0.0.0.0/0 on an administrative port, a database with a public endpoint, or a container running privileged with a host mount can turn a small foothold into a large breach. Container escape is not a single trick; it is the result of weak isolation, excessive capabilities, and a control plane that trusts the workload too much.

03Logging and Detection You Must Turn On

AWS CloudTrail records API activity. Enable it across the organisation, include data events for sensitive buckets where the cost is justified, and deliver logs to a separate account with restricted write access. GuardDuty adds threat detection, and Security Hub aggregates findings. CloudWatch alarms or an SIEM can turn specific events into alerts. The trail is only useful if it is complete, retained, and protected from deletion.

Azure provides Activity Log, Microsoft Entra sign-in and audit logs, and Microsoft Defender for Cloud. Google Cloud provides Cloud Audit Logs and Security Command Center. The names differ, but the questions are the same: who called which API, from where, with what result, and what changed? Send security logs to a central destination, set retention, and test that an alert actually reaches a human.

Detection should focus on high-risk changes: new administrator grants, access key creation, logging disabled, trail deleted, public storage policy, security group opened to the internet, role trust policy changed, and root or global administrator login. Also alert on unusual geography, impossible travel, and a sudden volume of API errors. Tune for your environment; a list of every API call is not a detection strategy.

04Incident Response in the Cloud

Cloud incident response follows the same lifecycle as on-premises response, with different levers. Prepare contacts, access paths, and runbooks before you need them. Keep a break-glass identity that does not depend on the compromised account. Know how to revoke sessions, disable keys, isolate a workload, and preserve logs when the console itself may be untrusted.

Containment can be fast, but it can also destroy evidence. Disabling an access key stops the attacker and preserves the key's metadata. Terminating an instance may remove volatile evidence and the attacker's tooling. Snapshot disks and capture logs before destructive cleanup where possible. Revoke active sessions, not just the key, because temporary credentials may remain valid. Remove public access and restrictive network rules with a documented change.

Preserve identity and audit evidence: CloudTrail, sign-in logs, VPC flow logs, DNS logs, container logs, and object access logs. Record the account, region, time range, and query used. Rotate every credential that may have been exposed, then look for persistence: new users, roles, access keys, Lambda functions, federation trusts, and modified logging. Eradicate only after you understand how the attacker entered and what they created.

Recovery means restoring from a known-good state, not just deleting the compromised resource. Rebuild workloads from infrastructure as code, verify integrity, and monitor closely for recurrence. Write an after-action review with a timeline, impact, root cause, and concrete fixes. Share the lessons with the teams that own the affected identities and pipelines.

05Least Privilege and Organisational Guardrails

Least privilege is a design goal, not a one-time policy edit. Start from the job to be done, grant the smallest set of actions on specific resources, and add conditions where the platform supports them. Use roles and short-lived credentials instead of long-lived access keys. Separate human administration from workload identity, and separate deployment from runtime.

Guardrails make the safe path the default. Service control policies and organisation policies can deny disabling audit logs, creating public buckets, or using prohibited regions. Permission boundaries cap what an identity can be granted. Access analyzers find resources shared outside the intended boundary. Infrastructure-as-code checks catch wildcard policies before they reach production.

Review access regularly and remove what is unused. Track who can create identities, who can change logging, and who can reach data. Protect the emergency account with strong MFA and a documented break-glass process. An exception should have an owner, a reason, a compensating control, and an expiry date. Without an expiry date, an exception becomes the new baseline.

06Read-Only CLI Triage in a Sandbox

These commands are read-only examples for a sandbox account. Confirm the identity and account first, then inspect storage, network exposure, and audit events. Some calls will fail because your lab role lacks permission; that is useful information, not a reason to grant more access. Never run exploratory commands against an account you do not own.

Cloud command-line tools respect the credentials in your environment. A wrong profile can point you at the wrong account, so check get-caller-identity or the equivalent before any destructive action. Prefer dry-run modes where supported, and use a read-only role for triage. Log the commands you run and the time window you examined.

The command output is evidence only when you record the account, region, timestamp, and query. A screenshot without context is not reproducible. Store the output in the incident record with the identity that produced it, and redact secrets, tokens, and personal data before sharing.

cloud-triage.shShell
# AWS: confirm the account, identity, and profile before doing anything.aws sts get-caller-identityaws configure listaws s3 lsaws s3 ls s3://example-lab-bucket --summarizeaws s3api get-public-access-block --bucket example-lab-bucket || trueaws ec2 describe-security-groups \  --filters Name=ip-permission.cidr,Values=0.0.0.0/0 \  --query "SecurityGroups[].GroupId" --output tableaws cloudtrail lookup-events \  --lookup-attributes AttributeKey=EventName,AttributeValue=CreateAccessKey \  --max-items 10# Google Cloud: confirm the active account and project.gcloud auth listgcloud config get-value projectgcloud storage buckets listgcloud logging read 'protoPayload.methodName="SetIamPolicy"' --limit=10 --format=json# Azure: confirm the subscription and inspect recent activity.az account showaz storage container list --auth-mode login --account-name examplelabaz monitor activity-log list --max-events 20 --output table
Outputstdout
{
  "UserId": "AIDAEXAMPLEUSER",
  "Account": "123456789012",
  "Arn": "arn:aws:iam::123456789012:user/analyst"
}
2026-11-01 10:00:00 example-lab-bucket
sg-0abc123def456
{
  "eventTime": "2026-11-01T10:05:00Z",
  "eventName": "CreateAccessKey",
  "userIdentity": {"type": "IAMUser", "userName": "analyst"}
}
ACTIVE  analyst@example.com  True
example-lab-project
example-lab-bucket  us-central1  2026-10-30T09:00:00Z
LET IT CLICK

The ideas worth keeping.

  • Cloud identity is the primary control plane; leaked keys and overprivileged roles are common breach paths.
  • Public storage, metadata SSRF, open security groups, and weak container isolation turn small mistakes into large exposures.
  • Durable, centralised audit logs are the foundation of cloud detection and incident response.
  • Contain identities, preserve evidence, rotate credentials, and recover from known-good infrastructure under least privilege.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Exercise 1: Contain a leaked access key

A developer accidentally commits a live cloud access key to a public repository. List the first eight actions in order, and explain which evidence you preserve before deleting anything.

Explore a worked solution
one_possible_solution.mdCybersecurity
1. Confirm the key's account and identity with a read-only call such as aws sts get-caller-identity using that key. 2. Disable or deactivate the key immediately; do not delete it yet, because deletion removes metadata you may need. 3. Revoke active sessions and temporary credentials associated with the identity. 4. Preserve audit logs: CloudTrail events, sign-in logs, storage access logs, and network flow logs, with account, region, and time range. 5. Review what the key did: API calls, new identities, role trust changes, key creation, storage policy changes, and data access. 6. Rotate the key and any related secrets, issuing a replacement with least privilege. 7. Remove the secret from source control and history, and add secret scanning. 8. Write an incident record and notify the owner. Preserve logs and key metadata before cleanup; termination or history rewriting can destroy the only record of what happened.

Disabling limits the attacker while keeping the key record. Logs and metadata answer whether the key was used and what changed; cleanup comes after evidence is secured.

02

Exercise 2: Design detections and guardrails

Design three detections and two preventive controls for a cloud account that stores customer data. For each detection, name the log source and the event you would alert on. For each guardrail, state what it blocks and how an exception would work.

Explore a worked solution
one_possible_solution.mdCybersecurity
Detection 1: CloudTrail event PutBucketPolicy or PutPublicAccessBlock that removes public-access protection, alert on any bucket containing customer data. Detection 2: CloudTrail CreateAccessKey or CreateUser followed by AttachUserPolicy or CreatePolicyVersion, alert when the target is an administrative identity or when it happens outside the deployment role. Detection 3: Entra ID or Cloud Audit Log sign-in from a new country combined with a privileged role activation, or repeated failed API calls followed by success. Guardrail 1: an organisation policy that denies public bucket policies and ACLs, with a time-bound exception approved by the data owner. Guardrail 2: a service control policy that denies disabling or deleting the central audit trail and denies changes to the log archive account. Verify each detection with a synthetic test event in a sandbox, and document the owner, severity, and response runbook.

Detections need a specific log source and event, not a vague category. Guardrails need an exception path; otherwise teams route around them.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 3 answered
01Which AWS service records API calls such as CreateAccessKey and PutBucketPolicy?
02Why is the instance metadata service a target for SSRF attacks?
03Why snapshot a compromised cloud instance before terminating it?

Keep exploring.

The official references behind this lesson, when you want a second angle or the full details.

One lesson closer.

Reading is a start. Trying it yourself makes the connection.

Completion is saved in this browser. It records reading and hands-on practice progress.