container-forensics
Investigates containerized environments for signs of compromise, misconfiguration, or container escape. Covers standalone Docker hosts and Kubernetes clusters. Produces a structured findings document with severity tagging.
Triggers
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
- "Falco" / "Tetragon" / "Tracee" → eBPF runtime monitoring tools
- "dive" → Docker image layer analysis
- "crictl" → containerd/CRI-O environment forensics
- "escape" → container escape investigation
Purpose
Container environments introduce unique attack surfaces: privileged containers, host namespace access, writable image layers, and overpermissioned service accounts. Standard host forensics misses these vectors. This skill applies container-aware investigation procedures and maps findings to MITRE ATT&CK for Containers.
Behavior
When triggered, this skill:
Detect environment type:
- Check for Docker:
docker info 2>/dev/null
- Check for Kubernetes:
kubectl cluster-info 2>/dev/null or presence of /var/run/secrets/kubernetes.io/
- Check for containerd-only (no Docker):
ctr version 2>/dev/null
- Check for CRI-O or containerd via CRI:
crictl version 2>/dev/null
- Determine if running inside a container: check for
/.dockerenv, inspect cgroup paths
Container inventory and privilege audit:
- List all containers (running and stopped):
docker ps -a --format '{{json .}}'
- For containerd/CRI-O environments:
crictl pods and crictl ps -a
- Inspect individual containers:
crictl inspect <id> (equivalent of docker inspect)
- List images on CRI nodes:
crictl images and crictl inspecti <image-id>
- Pull container logs via CRI:
crictl logs <container-id>
- Flag containers with dangerous flags:
--privileged: docker inspect <id> | jq '.[].HostConfig.Privileged'
- Host network mode:
NetworkMode == "host"
- Host PID namespace:
PidMode == "host"
- Dangerous capability additions:
CapAdd containing SYS_ADMIN, NET_ADMIN, SYS_PTRACE
- Enumerate bind mounts of sensitive host paths (
/, /etc, /var/run/docker.sock, /proc, /sys)
Docker — image verification:
- List all local images with digests:
docker images --digests
- Check image provenance: compare
RepoDigests against expected registry
- Flag images tagged
latest without a pinned digest
- Inspect image build history for suspicious
RUN layers: docker history --no-trunc <image>
- Check for images not associated with any running or stopped container (orphaned images)
Image layer analysis with dive:
- Run
dive <image> --ci for non-interactive efficiency and layer summary
- Identify layers that delete files immediately after downloading them (evidence wiping pattern)
- Flag layers installing unexpected tooling (
curl, nc, nmap, socat, python)
- Identify unusually large layers inconsistent with the image's declared purpose
- Check for world-writable permissions set in later layers after a trusted base image
Docker — volume and filesystem inspection:
- List named volumes:
docker volume ls
- Inspect volumes mounted into containers for sensitive data paths
- Examine container overlay filesystem changes:
docker diff <container_id>
- Flag containers with writable root filesystems where
ReadonlyRootfs is false
Docker — socket and API exposure:
- Check if Docker socket is bind-mounted into any container — this grants effective root on the host
- Check for TCP Docker API exposure:
ss -tlnp | grep ':2375\|:2376'
- Review Docker daemon configuration:
/etc/docker/daemon.json
Container escape indicators:
- Processes running in container namespaces that share host PID/network: compare namespace inodes in
/proc/1/ns/ vs /proc/<container-pid>/ns/
- Unexpected cgroup escape patterns in
/proc/<pid>/cgroup
- Files written to host paths from within container overlay mounts
runc or containerd-shim process anomalies in host process tree
eBPF runtime monitoring:
- Check for Falco service and alert logs:
journalctl -u falco and /var/log/falco.log
- Review active Falco rules for coverage gaps (shell-in-container, outbound connections, writes below root)
- Collect Tetragon execution traces via
kubectl logs -n kube-system -l app.kubernetes.io/name=tetragon or tetra getevents
- Review active Tetragon
TracingPolicy resources: kubectl get tracingpolicies -A
- Collect Tracee event logs from container or systemd deployment
- If no eBPF tooling was active during the incident, document this gap in the findings
Kubernetes — cluster-level audit:
- List all pods across all namespaces:
kubectl get pods -A -o json
- Flag pods running as root:
.spec.containers[].securityContext.runAsUser == 0 or unset
- Flag pods with
hostPID, hostNetwork, or hostIPC set to true
- Flag pods mounting the Docker socket or host paths
- List privileged containers across the cluster
Kubernetes — RBAC audit:
- List ClusterRoleBindings granting
cluster-admin: kubectl get clusterrolebindings -o json | jq '...'
- Identify service accounts with wildcard permissions or
* verbs on sensitive resources
- Check for default service account token automounting:
automountServiceAccountToken: true
- List RoleBindings in high-value namespaces (kube-system, kube-public)
Kubernetes — pod security and network policy:
- Check for absent NetworkPolicies (pods with unrestricted egress/ingress)
- Review PodSecurityAdmission or OPA/Gatekeeper policy coverage
- List nodes and check for unauthorized node additions:
kubectl get nodes -o wide
etcd security audit (Kubernetes control-plane only):
- Verify etcd is not listening on a non-loopback address:
ps aux | grep etcd | grep listen-client-urls
- Confirm
--client-cert-auth=true is set in the etcd process flags
- Check for encryption-at-rest configuration in the API server manifest (
--encryption-provider-config)
- List etcd client certificates in
/etc/kubernetes/pki/etcd/ and flag any unexpected certs
- Take a read-only snapshot with
etcdctl snapshot save for offline analysis
- Enumerate etcd key paths for secrets and serviceaccount tokens using
etcdctl get / --prefix --keys-only
K8s API server audit log analysis (if audit logging is enabled):
- Locate audit log path from
kube-apiserver.yaml (--audit-log-path)
- Summarize request activity by user and verb to identify outliers
- Detect anonymous (
system:anonymous) API calls to non-public endpoints
- Flag ServiceAccount tokens used outside their home namespace
- Identify bulk
list/get on secrets resources (credential harvesting pattern)
- Flag
exec subresource calls from non-operator users during the incident window
- Detect rapid
create/delete sequences on the same resource (attacker covering tracks)
Write findings document:
- Save to
.aiwg/forensics/findings/container-forensics.md
- Group by: Docker/containerd findings, eBPF runtime events, Kubernetes findings, etcd/API server findings, escape indicators
- Tag each finding: INFO, SUSPICIOUS, MALICIOUS
Usage Examples
Example 1 — Docker host
docker investigation
Audits the local Docker daemon.
Example 2 — Kubernetes cluster
kubernetes forensics
Requires kubectl configured with appropriate credentials.
Example 3 — Inside a container
container forensics
Detects the container context and adjusts collection accordingly.
Output Locations
- Findings:
.aiwg/forensics/findings/container-forensics.md
- Raw Docker inspection:
.aiwg/forensics/evidence/docker-inspect.json
- crictl inspection output:
.aiwg/forensics/evidence/crictl-inspect.json
- K8s pod manifest dump:
.aiwg/forensics/evidence/k8s-pods.json
- Falco alert log:
.aiwg/forensics/evidence/falco-alerts.log
- Tetragon events:
.aiwg/forensics/evidence/tetragon-events.json
- Tracee events:
.aiwg/forensics/evidence/tracee-events.json
- etcd snapshot:
.aiwg/forensics/evidence/etcd-snapshot-<timestamp>.db
- K8s API server audit log (copy):
.aiwg/forensics/evidence/k8s-audit.log
Configuration
container_forensics:
dangerous_capabilities:
- SYS_ADMIN
- NET_ADMIN
- SYS_PTRACE
- SYS_MODULE
sensitive_host_paths:
- /
- /etc
- /var/run/docker.sock
- /proc
- /sys
- /root
high_value_namespaces:
- kube-system
- kube-public
- default
References
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/research-before-decision.md — Detect environment type (Docker, containerd, Kubernetes) before applying collection procedures
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/non-destructive.md — Do not stop or remove containers until all artifacts are collected and hashed
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/red-flag-escalation.md — Escalate immediately when container escape, Docker socket exposure, or privileged escape is confirmed
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/evidence-integrity.md — Hash container logs and filesystem exports immediately after collection
- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/skills/linux-forensics/SKILL.md — Investigate the underlying host after container forensics; container escapes leave traces on the host
1---
2namespace: aiwg
3name: container-forensics
4description: "Docker, containerd/CRI-O, and Kubernetes forensic investigation covering container inventory (docker and crictl), privilege checks, image verification, layer analysis (dive), escape detection, eBPF runtime monitoring (Falco, Tetragon, Tracee), K8s RBAC audit, etcd security audit, and API server audit log analysis"
5tools: Bash, Read, Write, Glob, Grep
6platforms: [all]
7
8metadata:
9 source: https://skillmd.com/skills/aibot88/container-forensics
10---
11
12# container-forensics
13
14Investigates containerized environments for signs of compromise, misconfiguration, or container escape. Covers standalone Docker hosts and Kubernetes clusters. Produces a structured findings document with severity tagging.
15
16## Triggers
17
18
19Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
20
21- "Falco" / "Tetragon" / "Tracee" → eBPF runtime monitoring tools
22- "dive" → Docker image layer analysis
23- "crictl" → containerd/CRI-O environment forensics
24- "escape" → container escape investigation
25
26## Purpose
27
28Container environments introduce unique attack surfaces: privileged containers, host namespace access, writable image layers, and overpermissioned service accounts. Standard host forensics misses these vectors. This skill applies container-aware investigation procedures and maps findings to MITRE ATT&CK for Containers.
29
30## Behavior
31
32When triggered, this skill:
33
341. **Detect environment type**:
35 - Check for Docker: `docker info 2>/dev/null`
36 - Check for Kubernetes: `kubectl cluster-info 2>/dev/null` or presence of `/var/run/secrets/kubernetes.io/`
37 - Check for containerd-only (no Docker): `ctr version 2>/dev/null`
38 - Check for CRI-O or containerd via CRI: `crictl version 2>/dev/null`
39 - Determine if running inside a container: check for `/.dockerenv`, inspect cgroup paths
40
412. **Container inventory and privilege audit**:
42 - List all containers (running and stopped): `docker ps -a --format '{{json .}}'`
43 - For containerd/CRI-O environments: `crictl pods` and `crictl ps -a`
44 - Inspect individual containers: `crictl inspect <id>` (equivalent of `docker inspect`)
45 - List images on CRI nodes: `crictl images` and `crictl inspecti <image-id>`
46 - Pull container logs via CRI: `crictl logs <container-id>`
47 - Flag containers with dangerous flags:
48 - `--privileged`: `docker inspect <id> | jq '.[].HostConfig.Privileged'`
49 - Host network mode: `NetworkMode == "host"`
50 - Host PID namespace: `PidMode == "host"`
51 - Dangerous capability additions: `CapAdd` containing `SYS_ADMIN`, `NET_ADMIN`, `SYS_PTRACE`
52 - Enumerate bind mounts of sensitive host paths (`/`, `/etc`, `/var/run/docker.sock`, `/proc`, `/sys`)
53
543. **Docker — image verification**:
55 - List all local images with digests: `docker images --digests`
56 - Check image provenance: compare `RepoDigests` against expected registry
57 - Flag images tagged `latest` without a pinned digest
58 - Inspect image build history for suspicious `RUN` layers: `docker history --no-trunc <image>`
59 - Check for images not associated with any running or stopped container (orphaned images)
60
614. **Image layer analysis with dive**:
62 - Run `dive <image> --ci` for non-interactive efficiency and layer summary
63 - Identify layers that delete files immediately after downloading them (evidence wiping pattern)
64 - Flag layers installing unexpected tooling (`curl`, `nc`, `nmap`, `socat`, `python`)
65 - Identify unusually large layers inconsistent with the image's declared purpose
66 - Check for world-writable permissions set in later layers after a trusted base image
67
685. **Docker — volume and filesystem inspection**:
69 - List named volumes: `docker volume ls`
70 - Inspect volumes mounted into containers for sensitive data paths
71 - Examine container overlay filesystem changes: `docker diff <container_id>`
72 - Flag containers with writable root filesystems where `ReadonlyRootfs` is false
73
746. **Docker — socket and API exposure**:
75 - Check if Docker socket is bind-mounted into any container — this grants effective root on the host
76 - Check for TCP Docker API exposure: `ss -tlnp | grep ':2375\|:2376'`
77 - Review Docker daemon configuration: `/etc/docker/daemon.json`
78
797. **Container escape indicators**:
80 - Processes running in container namespaces that share host PID/network: compare namespace inodes in `/proc/1/ns/` vs `/proc/<container-pid>/ns/`
81 - Unexpected cgroup escape patterns in `/proc/<pid>/cgroup`
82 - Files written to host paths from within container overlay mounts
83 - `runc` or `containerd-shim` process anomalies in host process tree
84
858. **eBPF runtime monitoring**:
86 - Check for Falco service and alert logs: `journalctl -u falco` and `/var/log/falco.log`
87 - Review active Falco rules for coverage gaps (shell-in-container, outbound connections, writes below root)
88 - Collect Tetragon execution traces via `kubectl logs -n kube-system -l app.kubernetes.io/name=tetragon` or `tetra getevents`
89 - Review active Tetragon `TracingPolicy` resources: `kubectl get tracingpolicies -A`
90 - Collect Tracee event logs from container or systemd deployment
91 - If no eBPF tooling was active during the incident, document this gap in the findings
92
939. **Kubernetes — cluster-level audit**:
94 - List all pods across all namespaces: `kubectl get pods -A -o json`
95 - Flag pods running as root: `.spec.containers[].securityContext.runAsUser == 0` or unset
96 - Flag pods with `hostPID`, `hostNetwork`, or `hostIPC` set to true
97 - Flag pods mounting the Docker socket or host paths
98 - List privileged containers across the cluster
99
10010. **Kubernetes — RBAC audit**:
101 - List ClusterRoleBindings granting `cluster-admin`: `kubectl get clusterrolebindings -o json | jq '...'`
102 - Identify service accounts with wildcard permissions or `*` verbs on sensitive resources
103 - Check for default service account token automounting: `automountServiceAccountToken: true`
104 - List RoleBindings in high-value namespaces (kube-system, kube-public)
105
10611. **Kubernetes — pod security and network policy**:
107 - Check for absent NetworkPolicies (pods with unrestricted egress/ingress)
108 - Review PodSecurityAdmission or OPA/Gatekeeper policy coverage
109 - List nodes and check for unauthorized node additions: `kubectl get nodes -o wide`
110
11112. **etcd security audit** (Kubernetes control-plane only):
112 - Verify etcd is not listening on a non-loopback address: `ps aux | grep etcd | grep listen-client-urls`
113 - Confirm `--client-cert-auth=true` is set in the etcd process flags
114 - Check for encryption-at-rest configuration in the API server manifest (`--encryption-provider-config`)
115 - List etcd client certificates in `/etc/kubernetes/pki/etcd/` and flag any unexpected certs
116 - Take a read-only snapshot with `etcdctl snapshot save` for offline analysis
117 - Enumerate etcd key paths for secrets and serviceaccount tokens using `etcdctl get / --prefix --keys-only`
118
11913. **K8s API server audit log analysis** (if audit logging is enabled):
120 - Locate audit log path from `kube-apiserver.yaml` (`--audit-log-path`)
121 - Summarize request activity by user and verb to identify outliers
122 - Detect anonymous (`system:anonymous`) API calls to non-public endpoints
123 - Flag ServiceAccount tokens used outside their home namespace
124 - Identify bulk `list`/`get` on `secrets` resources (credential harvesting pattern)
125 - Flag `exec` subresource calls from non-operator users during the incident window
126 - Detect rapid `create`/`delete` sequences on the same resource (attacker covering tracks)
127
12814. **Write findings document**:
129 - Save to `.aiwg/forensics/findings/container-forensics.md`
130 - Group by: Docker/containerd findings, eBPF runtime events, Kubernetes findings, etcd/API server findings, escape indicators
131 - Tag each finding: INFO, SUSPICIOUS, MALICIOUS
132
133## Usage Examples
134
135### Example 1 — Docker host
136```
137docker investigation
138```
139Audits the local Docker daemon.
140
141### Example 2 — Kubernetes cluster
142```
143kubernetes forensics
144```
145Requires `kubectl` configured with appropriate credentials.
146
147### Example 3 — Inside a container
148```
149container forensics
150```
151Detects the container context and adjusts collection accordingly.
152
153## Output Locations
154
155- Findings: `.aiwg/forensics/findings/container-forensics.md`
156- Raw Docker inspection: `.aiwg/forensics/evidence/docker-inspect.json`
157- crictl inspection output: `.aiwg/forensics/evidence/crictl-inspect.json`
158- K8s pod manifest dump: `.aiwg/forensics/evidence/k8s-pods.json`
159- Falco alert log: `.aiwg/forensics/evidence/falco-alerts.log`
160- Tetragon events: `.aiwg/forensics/evidence/tetragon-events.json`
161- Tracee events: `.aiwg/forensics/evidence/tracee-events.json`
162- etcd snapshot: `.aiwg/forensics/evidence/etcd-snapshot-<timestamp>.db`
163- K8s API server audit log (copy): `.aiwg/forensics/evidence/k8s-audit.log`
164
165## Configuration
166
167```yaml
168container_forensics:
169 dangerous_capabilities:
170 - SYS_ADMIN
171 - NET_ADMIN
172 - SYS_PTRACE
173 - SYS_MODULE
174 sensitive_host_paths:
175 - /
176 - /etc
177 - /var/run/docker.sock
178 - /proc
179 - /sys
180 - /root
181 high_value_namespaces:
182 - kube-system
183 - kube-public
184 - default
185```
186
187## References
188
189- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/research-before-decision.md — Detect environment type (Docker, containerd, Kubernetes) before applying collection procedures
190- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/non-destructive.md — Do not stop or remove containers until all artifacts are collected and hashed
191- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/red-flag-escalation.md — Escalate immediately when container escape, Docker socket exposure, or privileged escape is confirmed
192- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/rules/evidence-integrity.md — Hash container logs and filesystem exports immediately after collection
193- @$AIWG_ROOT/agentic/code/frameworks/forensics-complete/skills/linux-forensics/SKILL.md — Investigate the underlying host after container forensics; container escapes leave traces on the host