🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Cloud Forensics: Snapshots, Audit Trails and Containers

ForensicsđŸŸĸ Free Lesson

Cloud Forensics

Cloud forensics breaks the assumptions that make traditional acquisition simple: there is no chassis to seize, the physical disk belongs to someone else, workloads may be destroyed and recreated at any moment, and the most valuable evidence lives in control-plane APIs rather than in the machine you were about to image. The discipline therefore inverts the usual order — preserve identity, audit and network records first, because they survive the compute instance that generated them, and only then decide whether the instance itself needs imaging.

The shared responsibility trap

Before collecting anything, be precise about who owns the evidence. Under the shared responsibility model the provider secures the physical layer, the hypervisor and the managed service fabric; you secure everything above it — identities, keys, operating systems, applications and the audit configuration that records them. Misunderstanding this boundary produces two opposite failures: teams that assume the provider will hand over a disk image, and teams that never enable logging because they assume the provider already does.

Evidence classWho controls itTypical lead time
Provider-side access and support logsProvider, by request through supportDays to weeks
Control-plane audit trailsYou, if enabledImmediate
Flow logs and DNS query logsYou, if enabledImmediate
Block storage snapshotsYou, via snapshot APIsMinutes
Guest OS memory and diskYou, but instance may be goneMust be captured live
Managed database contentsYou, via point-in-time restoreMinutes to hours

The uncomfortable line in that table is the first row. Provider-side records often require a formal legal request, which is far slower than an incident timeline allows. Anything you might need during an investigation should be streaming into an account you control, ideally one separate from production.

Evidence sources you should already have enabled

Every major cloud writes an audit trail of API activity; the failure is not absence of data but retention and immutability. CloudTrail in AWS, the Activity Log in Azure, and Cloud Audit Logs in GCP record who called what, from which IP, with which result. Add data-plane signals — VPC flow logs, NSG flow logs, VPC packet mirrors, DNS query logs — and identity-provider logs for federated access, and you can reconstruct most incidents without ever touching a virtual disk.

#!/usr/bin/env bash
# Pull the control-plane trail for a suspected account compromise.
set -euo pipefail
START="2026-03-01T00:00:00Z"
END="2026-03-14T00:00:00Z"
OUT=cloud-evidence
mkdir -p "$OUT"

# 1) Every mutating API call in the window, delivered to your evidence account.
aws cloudtrail lookup-events \
  --start-time "$START" --end-time "$END" \
  --max-results 1000 \
  --query 'Events[*].{time:EventTime,user:Username,src:SourceIPAddress,op:EventName,res:Resources}' \
  --output json > "$OUT/cloudtrail-events.json"

# 2) Focus on the calls attackers and administrators both make.
jq -r '.[] | select(.op=="ConsoleLogin" or .op=="AssumeRole" or
     (.op|test("Create|Delete|Put|Authorize"))) | [.time,.user,.src,.op] | @tsv' \
  "$OUT/cloudtrail-events.json" > "$OUT/high-signal.tsv"

# 3) Network evidence: who talked to what, and how much left.
aws ec2 describe-flow-logs --query 'FlowLogs[*].FlowLogId' --output text > "$OUT/flowlog-ids.txt"
while read -r id; do
  aws ec2 get-flow-log-records --flow-log-id "$id" \
    --max-results 1000 >> "$OUT/flow-records.json"
done < "$OUT/flowlog-ids.txt"

# 4) Hash the evidence set before anyone analyses it.
sha256sum "$OUT"/* | tee "$OUT/HASHES.txt"

Two configuration details decide whether this works: trails must be delivered to a bucket in a separate account with object lock enabled, and log-file validation must be on so that tampering with an archived file is detectable. Trails that only stream to the production account are writable by the same administrators they are meant to record.

Preserving compute: snapshot before you touch it

Instance memory is gone the moment the instance stops, so live acquisition precedes containment for any host suspected of active compromise. Where imaging is impractical, snapshot the volumes and copy them into the forensic account — snapshots are incremental, fast, and independent of the original instance lifecycle, which lets you keep collecting after the workload has been terminated for business reasons.

#!/usr/bin/env bash
set -euo pipefail
INSTANCE=i-0abc1234def56789
FORENSIC_ACCT=111122223333
REGION=us-east-1

# 1) Suspend automated actions that would destroy evidence mid-collection.
aws ec2 modify-instance-attribute --instance-id "$INSTANCE" --no-disable-api-termination
aws cloudtrail stop-logging   # only if the trail itself is under attack

# 2) Capture memory live through the instance metadata path where supported.
aws ssm send-command --instance-ids "$INSTANCE" \
  --document-name AWS-RunShellScript \
  --parameters 'commands=["sudo dd if=/dev/mem of=/tmp/memory.raw bs=1M status=progress","sudo sha256sum /tmp/memory.raw"]'

# 3) Snapshot each volume, then copy across into the evidence account.
for vol in $(aws ec2 describe-instances --instance-ids "$INSTANCE" \
  --query 'Reservations[*].Instances[*].BlockDeviceMappings[*].Ebs.VolumeId' --output text); do
  SNAP=$(aws ec2 create-snapshot --volume-id "$vol" \
    --description "forensic $INSTANCE $(date -u +%Y%m%dT%H%M%SZ)" \
    --query SnapshotId --output text)
  aws ec2 wait snapshot-completed --snapshot-ids "$SNAP"
  aws ec2 copy-snapshot --source-region "$REGION" --source-snapshot-id "$SNAP" \
    --destination-region "$REGION" \
    --kms-key-id alias/forensics --query SnapshotId --output text
  aws ec2 modify-snapshot-attribute --snapshot-id "$SNAP" \
    --create-volume-permission "ToAdd=[{UserId=$FORENSIC_ACCT}]"
done

Once snapshots live in a second account with restricted IAM, the original instance can be terminated for containment without losing the evidence — which resolves the usual tension between responding quickly and preserving forensics.

Containers and ephemeral state

Containers are the cloud's most perishable evidence: a pod that is rescheduled, a task that is replaced, or an instance that scales in will take its filesystem, its environment and its memory with it. Collection has to trigger from orchestration events rather than from an investigator's arrival, or the state will be gone before anyone knows it mattered.

#!/usr/bin/env bash
# Ephemeral capture for a Kubernetes workload under investigation.
set -euo pipefail
POD=invoice-worker-7d9f8c6b5-x2k4l
NS=payments
OUT=pod-evidence
mkdir -p "$OUT"

# 1) Freeze replacement so the evidence stays where it is.
kubectl -n "$NS" scale deployment invoice-worker --replicas=0

# 2) Pull the exact image identity, not the mutable tag.
kubectl -n "$NS" get pod "$POD" -o jsonpath='{.status.containerStatuses[*].imageID}' \
  | tee "$OUT/image-digest.txt"

# 3) Export the container filesystem, logs and process list before deletion.
CID=$(docker ps -q --filter "name=$POD" | head -1)
docker export "$CID" > "$OUT/container-fs.tar"
docker logs "$CID" > "$OUT/container.log" 2>&1
docker top "$CID" -eo pid,ppid,user,cmd > "$OUT/processes.txt"
docker inspect "$CID" > "$OUT/inspect.json"

# 4) Orchestration context outlives the pod and explains how it was created.
kubectl -n "$NS" get pod "$POD" -o yaml > "$OUT/pod.yaml"
kubectl -n "$NS" get events --sort-by=.lastTimestamp > "$OUT/events.txt"
kubectl -n "$NS" logs "$POD" --previous > "$OUT/previous.log" 2>/dev/null || true

sha256sum "$OUT"/* | tee "$OUT/HASHES.txt"

The image digest deserves emphasis: tags move, and an investigation built on a mutable tag proves nothing about which code actually ran. Record the digest, keep the image itself in a registry that supports retention, and capture the orchestration manifest so you can show how the workload was created and by whom.

Custody across accounts and providers

Evidence in the cloud is copied, not carried, so chain of custody becomes a list of object identifiers, account numbers and access logs rather than signatures on a bag. Each evidence item should record the source account and region, the API call that produced it, the timestamp from the provider, the resulting object identifier and hash, and every subsequent copy with the identity that performed it. Object-lock settings on the evidence bucket keep that record honest even against a compromised administrator.

Cross-account isolation is the control that makes the whole scheme work: a dedicated evidence account with its own KMS keys, restricted IAM roles, and no route back into production. Analysts work there, not on the compromised account, and the separation gives you a defensible answer to the question of who could have altered the data after collection.

âš ī¸Do not turn off logging as a first move

Suspending trails or deleting log groups is a common attacker action. If you disable logging during collection because the trail itself is compromised, record who authorized it and when, snapshot the trail's existing contents first, and re-enable immediately after. An unexplained gap in the trail during an incident is the finding an opposing expert will pursue.

Dead ends worth knowing in advance

Three failure modes account for most wasted effort. The first is arriving to find that flow logs, DNS logs and the audit trail were never enabled, because nothing streamed them and the default retention had expired. The second is imaging an instance after it has stopped, discovering the memory was never captured, and losing the only evidence of a fileless implant. The third is treating the provider's support portal as an incident response channel; formal requests take longer than the incident window and should be raised in parallel rather than instead of your own collection.

The mitigation for all three is the same: rehearse the collection before an incident. Run an annual exercise that inventories which logs exist, confirms the evidence account works, and times how long a snapshot-and-copy takes for a real instance. Teams that have done that exercise once respond in hours; teams that have not spend their first day discovering which parts of their logging they never actually turned on.

Common Mistakes

Assuming the provider holds the evidence you need

Fix: Stream control-plane and data-plane logs into an account you control, with retention you chose.

Stopping an instance before capturing memory

Fix: Acquire memory live first; a stopped instance takes volatile evidence with it.

Storing forensic snapshots in the compromised account

Fix: Copy snapshots into a separate evidence account with its own keys and restricted IAM.

Identifying container images by tag

Fix: Record the immutable image digest and export the filesystem before the pod is replaced.

Disabling logging during an incident without recording why

Fix: Preserve existing trail contents first and document the authorization for any gap.

Best Practices

  • Enable immutable, cross-account log delivery before an incident occurs.
  • Rehearse a full collection exercise annually and time every step.
  • Prefer provider-native APIs — snapshots, exports, audit queries — over manual copying.
  • Record account, region, API call, object identifier and hash for every evidence item.
  • Capture orchestration context alongside container filesystems.

Key Takeaways

  • Under shared responsibility, audit configuration is your evidence, not the provider's.
  • Preserve identity, audit and network records first; compute is the most perishable layer.
  • Snapshots copied to a separate evidence account resolve the containment-versus-preservation tension.
  • Container state must be captured by automation triggered from orchestration events.
  • Cloud chain of custody means object identifiers, accounts and hashes instead of sealed bags.
  • Rehearsal is the only reliable way to discover which logs you never enabled.
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-12

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Cybersecurity Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement