In this section
LX0.4 Three Investigation Environments
The Three Environments Where Linux IR Happens
Why the Environment Changes Everything
The Linux operating system is the same regardless of where it runs. An ext4 filesystem on a bare-metal server has the same inode structure as an ext4 filesystem on an AWS EC2 instance. The auth.log format is identical whether the server is in your data center or in Azure. The commands you run during an investigation are the same.
What changes is how you access the system, how you collect evidence, what additional evidence sources are available, and what evidence is absent. A bare-metal server has a physical disk you can image with a write blocker. A cloud VM has a virtual disk you can snapshot through the provider's API without ever logging into the system. A container has an ephemeral filesystem that is destroyed and recreated every time the pod restarts — there may be no disk to image at all.
# Determine the environment of a compromised system — run these checks first
# Check 1: Is this a cloud VM? (check for cloud metadata service)
curl -s -m 2 http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null && echo "AWS EC2" || true
curl -s -m 2 -H "Metadata: true" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" 2>/dev/null && echo "Azure VM" || true
curl -s -m 2 -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/id 2>/dev/null && echo "GCP VM" || true
# If any of these return data, this is a cloud VM — collect cloud audit trails
# Check 2: Is this a container?
cat /proc/1/cgroup 2>/dev/null | grep -qE "docker|containerd|kubepods" && echo "CONTAINER" || echo "Not a container"
# If output shows docker/containerd/kubepods, you are inside a container
# Evidence collection must use docker export / kubectl cp
# Check 3: Is this a Kubernetes pod?
test -f /var/run/secrets/kubernetes.io/serviceaccount/token && echo "KUBERNETES POD" || true
# If the service account token exists, this is a K8s pod
# Check if the attacker stole this token for RBAC abuse
# Check 4: What is the host system? (useful when exec'd into a container)
cat /etc/os-release | grep -E "^ID=|^VERSION_ID="
# Determines distribution → correct evidence paths (LX0.7)Myth: "Cloud VM investigations are easier because the cloud provider handles security."
Reality: Cloud providers secure the infrastructure (hypervisor, physical hardware, network fabric) under the shared responsibility model. They do not secure the operating system, the applications, or the data inside your VM. A compromised cloud VM contains the same OS-level artifacts as a compromised bare-metal server — and the cloud provider will not collect evidence for you. The investigator must collect OS-level evidence from the VM AND cloud control plane evidence from the provider's audit logs. Ignoring either evidence plane means missing half the story. The cloud provider's audit trail is often the only evidence of how the attacker gained initial access (stolen API keys, compromised IAM role, exposed metadata service).
Decision points: choosing the collection approach by environment
Known bare-metal server: default to hybrid approach — volatile collection first, then disk imaging. If legal proceedings are likely, power off for write-blocked acquisition after volatile capture.
Known cloud VM: snapshot the disk via API first (cleanest acquisition, no system modification), then collect cloud audit trails, then SSH in for volatile collection. If memory evidence is critical, LiME must be deployed via SSH.
Known container: collect immediately — docker export the filesystem before any restart. If the container has already restarted, pivot to runtime logs, K8s audit log, persistent volumes, and host-level Docker data directory.
Unknown environment: run the environment identification commands above. The first 60 seconds of the investigation determine your entire collection approach.
Troubleshooting: environment-specific problems
Cloud VM: disk snapshot fails with permission error. The IAM role or user account you are using does not have ec2:CreateSnapshot (AWS) or equivalent permission. Request elevated permissions from the cloud team — document the time spent waiting as it affects evidence volatility.
Container: docker export fails because the container already terminated. Check if the container was removed: docker ps -a | grep . If it shows as "Exited" (not removed), you can still export. If it was removed (docker rm), check /var/lib/docker/overlay2/ on the host for the writable layer.
Bare-metal: RAID array prevents direct disk imaging. Image at the logical volume level (/dev/mapper/vg0-root) rather than the physical disk level. If the RAID controller presents a logical device, image that device. Document the RAID configuration from the controller (level, stripe size, member disks) for the evidence chain.
Cannot determine the environment from inside the system. The metadata service checks above may fail on hardened systems that block 169.254.169.254. Check /sys/class/dmi/id/product_name — it shows "HVM domU" (AWS), "Virtual Machine" (Azure/Hyper-V), or "Google Compute Engine" (GCP) for cloud VMs. Check /proc/1/cgroup for container indicators.
Try it yourself
Exercise
If you have Docker installed, run a test container and examine the evidence landscape: docker run -d --name forensic-test ubuntu sleep 3600. Then run: docker inspect forensic-test | head -50 (see the configuration data available to an investigator). Run docker diff forensic-test (see what files changed from the base image — currently none because you have not modified anything). Run docker exec forensic-test ls -la /proc/1/ (see the process information available inside the container). Run docker export forensic-test > /tmp/container-export.tar (capture the filesystem). Then docker rm -f forensic-test to clean up. You have just performed the core container evidence collection workflow.
Beyond This Investigation
The three-environment model applies to every investigation in this course. LX4–LX8 focus primarily on bare-metal and VM evidence (filesystem, logs, processes). LX9 focuses specifically on container forensics. LX10 focuses on cloud VM compromise with the cloud control plane evidence. LX11 (Lateral Movement) spans all three environments — the attacker may pivot from a container to the host, from the host to the cloud API, and from the cloud API to other VMs. The investigator who understands all three evidence planes can follow the attacker across all of them.
Check your understanding:
1. A Kubernetes pod was restarted by the liveness probe 15 minutes before you were notified. What evidence from the previous pod instance is still available, and what is lost? 2. An attacker compromises an AWS EC2 instance via SSRF against the metadata service. The SSRF request is in the web server access log on the instance. Where is the evidence of what the attacker did with the stolen IAM credentials? 3. Why is disk snapshot via the cloud provider's API preferred over logging into the VM and running dd? 4. You need to investigate a compromised Docker container that is still running. List the three commands you run first and what each collects.
You are investigating a Linux server and discover evidence of both a cryptominer (resource abuse) and an SSH key theft (lateral movement preparation). The cryptominer is consuming 95% CPU and impacting production. Which do you address first?
Address the lateral movement first. The cryptominer is visible, noisy, and contained to this server — it is causing performance impact but not spreading. The SSH key theft is silent, potentially already exploited, and may have given the attacker access to additional servers. Contain the lateral movement risk: rotate the stolen SSH keys, check the target servers for unauthorized access, and apply network restrictions. Then address the cryptominer: kill the process, remove the binary and persistence mechanisms. Prioritizing the noisy but contained threat over the silent but spreading threat is the most common Linux IR prioritization mistake.
Get weekly detection and investigation techniques
KQL queries, detection rules, and investigation methods — the same depth as this course, delivered every Tuesday.
No spam. Unsubscribe anytime. ~2,000 security practitioners.