agentleFS
kaandgnshkaandgnsh/Claude-Blue/skills/container-security/container-incident/SKILL.md

container-incident

Skill0 starsChanged 11 days agoMITView on GitHub

Investigate and contain a compromised container — preserve the container filesystem and metadata (docker/crictl inspect, diff, export, checkpoint), analyze processes and network from the node, determine escape to host or cluster, and redeploy cleanly. Use when a running container is suspected compromised (web shell, miner, reverse shell) on Docker, containerd or Kubernetes nodes.

The file

Files
SKILL.md

Container Incident Response

Containers are ephemeral: if the pod restarts or scales down, evidence disappears. Preserve before you kill.

Preserve (from the node)

# Docker
docker inspect <cid> > inspect.json
docker diff <cid> > diff.txt                       # A/C/D changes vs. image — fast IOC source
docker export <cid> -o container-fs.tar            # filesystem snapshot
docker logs --timestamps <cid> > logs.txt
docker top <cid> -eo pid,ppid,user,args
# containerd / CRI-O (Kubernetes nodes)
crictl inspect <cid> > inspect.json ; crictl logs <cid> > logs.txt
PID=$(crictl inspect --output go-template --template '{{.info.pid}}' <cid>)
nsenter -t $PID -n ss -tupan                       # network namespace sockets
ls -l /proc/$PID/root/tmp /proc/$PID/root/dev/shm  # container FS via host /proc
# Kubernetes: checkpoint (where kubelet checkpoint API is enabled) or snapshot the node volume

Also capture: pod spec (kubectl get pod <p> -o yaml), service account and its RBAC, node name, image digest, events.

Contain

  • Kubernetes: isolate with a deny-all NetworkPolicy selecting the pod label (k8s-network-policy); cordon the node if escape suspected; remove the pod from Service endpoints by relabeling instead of deleting (keeps it running for analysis).
  • Revoke the pod's service account token and any cloud credentials (IRSA/Workload Identity) it could use.

Escape assessment

Privileged container, hostPID/hostNetwork, hostPath mounts (/, /var/run/docker.sock, /var/lib/kubelet), capabilities (SYS_ADMIN, SYS_PTRACE), kernel exploits — if any were present, treat the node as compromised and pivot to k8s-incident-response and node forensics.

Eradicate

Fix the entry point (vulnerable app, exposed dashboard, leaked credentials), rebuild image from clean source, redeploy by digest, rotate secrets mounted in the pod, and replace (not clean) compromised nodes.

Related skills

runtime-detection-falco, k8s-incident-response, k8s-network-policy, linux-incident-triage

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.