Skip to content

Lesson 13 of 19 · 25m

Cloud Forensics: CloudTrail, SaaS Logs & Ephemeral Evidence

Scope AWS and Microsoft 365 intrusions from control-plane logs — CloudTrail anatomy, the data-events gap, and retention clocks that expire mid-case.

The compromised host was a container node. There's no disk to image, the pod was rescheduled an hour ago, and the "server" is an API call away from existing at all. Cloud forensics flips the model: evidence isn't on a machine you seize — it's in control-plane logs the provider kept for you, until its retention deletes it.

CloudTrail is the flight recorder — if it was on

Every AWS API call writes a CloudTrail event: eventName, userIdentity.arn, sourceIPAddress, userAgent, requestParameters, responseElements, errorCode. The 90-day Event History is free and on by default, which creates the first trap: it only covers management events and only 90 days. A real investigation needs a trail writing JSON to S3 — and data events are off by default. GetObject on your secrets bucket leaves no CloudTrail record unless someone explicitly enabled S3 data events. An "empty" trail during a confirmed S3 exfil usually means the log never existed, not that the reads never happened.

# Who used this access key, and for what?
aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAEXAMPLE \
  --max-results 50

# Console logins with failures, last day
aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=EventName,AttributeValue=ConsoleLogin

Before concluding anything from an empty trail, verify what was being logged: aws cloudtrail get-event-selectors --trail-name org-trail shows whether data events were ever enabled — the difference between 'no evidence' and 'no logging' — and describe-trails plus get-trail-status report whether logging was on. StopLogging and DeleteTrail are themselves CloudTrail events, recorded in a log the attacker can't retroactively erase.

Querying S3-stored trails at scale is Athena's job — SELECT eventname, sourceipaddress FROM cloudtrail WHERE eventtime > '...' — not grep over a million JSON files.

What to read in a confirmed AWS compromise

  • userIdentity — which principal, and was it assumed-role? Follow sessionContext: AssumeRole chains are how one key becomes three identities.
  • Enumeration vs. theft — DescribeInstances/ListBuckets/GetCallerIdentity bursts are the "keys jingling" phase; CreateAccessKey, PutBucketPolicy to Principal: *, AttachUserPolicy are the escalation. GuardDuty flags Exfiltration:S3/* and UnauthorizedAccess:IAMUser/* findings — if GuardDuty was enabled, which is its own scoping question.
  • The key itself — aws iam list-access-keys --user-name + CloudTrail CreateAccessKey events give you creation timestamps to correlate. Response nuance: deactivate the key (UpdateAccessKey Inactive), don't delete it — deletion loses the correlation ID and you can't undelete.
  • VPC Flow Logs — 5-tuples and bytes, no payload, off by default. Combined with CloudTrail they're your lateral-movement map.

Ephemeral evidence doesn't wait for you

The VM you're investigating can be a disposable instance; the container node was rescheduled an hour ago. In cloud, "capture RAM before disk" becomes "snapshot and isolate before the orchestrator reaps it": snapshot the EBS volume (or the node's managed disk), isolate the security group, snapshot before any rebuild — and do it before terminating, because termination deletes the root volume on most defaults. Kubernetes audit logs (/var/log/kubernetes/audit on the API server, control-plane logs in EKS/GKE), container logs under /var/log/containers/, and the node's own syslog all evaporate with the pod or node unless something ships them out.

SaaS and Microsoft 365: the clock is shorter

Microsoft Entra ID sign-in and audit logs retain 30 days on P1/P2, 7 days on Free — an exfil discovered on day 40 is partially unrecoverable regardless of effort. Export to a Log Analytics workspace or SIEM as part of the incident, not a quarterly project.

For mailbox and SharePoint forensics, the Unified Audit Log (Search-UnifiedAuditLog in Exchange Online PowerShell, or Purview) records MailItemsAccessed, Set-Mailbox forwarding rules, and file syncs — which is how you scope a BEC: which messages were read, which rules were added, which files synced down. Okta's System Log API is the equivalent for IdP events. Google Workspace splits admin audit and data-access logs the way AWS splits management and data events — same trap, same fix. GCP repeats the split exactly: Admin Activity audit logs are on for everyone with 400-day retention, while Data Access logs stay off by default — a third console, the same gap.

The meta-lesson

SaaS logs are perishable inventory. Entra: 7–30 days. Okta: ~90. CloudTrail Event History: 90. Any investigation that starts "pull the last quarter" of a log nobody exported is already over. The correct practice is boring: enable the trail, ship every log to somewhere you own, and during the incident export the window immediately — before retention does the attacker's cleanup for free.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.