kernel-cgroups-v2-forensic
Linux cgroups v2 forensic analysis — resource isolation inspection, container escape detection via cgroup release agents, and cgroup-based persistence hunting.
- License 许可
- MIT
- 最近更新
- 2026-09-01
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- kernel-cgroups-v2-forensic
- tags
- [ "linux", "cgroups", "container-escape", "kernel", "blue-team" ]
- capec
- []
- model
- sonnet
- tools
- [ "Read", "Bash", "Glob", "Grep" ]
- domain
- cybersecurity
- maxTurns
- 15
- nist_csf
- [ "DE.CM-01", "PR.PT-04" ]
- subdomain
- endpoint-forensics
- description
- Linux cgroups v2 forensic analysis — resource isolation inspection, container escape detection via cgroup release agents, and cgroup-based persistence hunting.
- mitre_attack
- [ "T1611", "T1055", "T1543" ]
02 资源文件 1
- 参考文档index.json653 B
03 SKILL.md 正文
Linux cgroups v2 Forensic Analysis
Overview
Control Groups (cgroups) manage resource allocation for process groups. Attackers exploit cgroup release agents for container escapes (CVE-2022-0492) and abuse cgroup namespaces to persist or evade detection. This skill covers forensic inspection of the unified cgroup v2 hierarchy.
When to Use
- When investigating container escape attempts
- When auditing Kubernetes/Docker workloads for cgroup misconfigurations
- When hunting for cgroup release_agent persistence
- When analyzing resource usage anomalies that may indicate cryptomining
Prerequisites
- Access to
/sys/fs/cgroup/(cgroup v2 unified hierarchy) systemd-cgls,systemctl,findmnt
Core Commands
Enumerate cgroup Hierarchy
# Check cgroup version in use
mount | grep cgroup
# Full hierarchy tree
systemd-cgls
# Flat list of all cgroups
find /sys/fs/cgroup -name "cgroup.procs" | xargs -I{} sh -c 'echo "=== {} ==="; cat {}'
Detect release_agent Abuse (CVE-2022-0492 Pattern)
# Check for writable release_agent files (v1 only, but check for presence)
find /sys/fs/cgroup -name "release_agent" 2>/dev/null
# In v2, check for notify_on_release misuse
find /sys/fs/cgroup -name "notify_on_release" -exec cat {} \; 2>/dev/null | grep -v "^0"
# Detect containers with CAP_SYS_ADMIN that can remount cgroup v1
grep -r "SYS_ADMIN" /etc/docker/ /etc/containerd/ 2>/dev/null
Inspect Process-to-cgroup Mapping
# Map all PIDs to their cgroup path
for pid in $(ls /proc | grep '^[0-9]'); do
echo "$pid: $(cat /proc/$pid/cgroup 2>/dev/null | head -1)"
done | grep -v "^$"
# Find processes NOT in a cgroup (possible escape)
awk -F: '{print $3}' /proc/*/cgroup 2>/dev/null | sort -u
# Specific PID cgroup membership
cat /proc/<PID>/cgroup
Resource Anomaly Detection (Cryptomining)
# Find cgroups with excessive CPU usage
cat /sys/fs/cgroup/*/cpu.stat 2>/dev/null | grep usage_usec | sort -t= -k2 -rn | head -20
# Find cgroups with no memory limit (potential abuse)
find /sys/fs/cgroup -name "memory.max" -exec sh -c 'v=$(cat {}); [ "$v" = "max" ] && echo {}' \;
Container Escape Detection
# Check if we're inside a container
cat /proc/1/cgroup | grep -q "docker\|kubepods\|containerd" && echo "CONTAINER DETECTED"
# Check for writable cgroup fs from inside container
mount | grep "cgroup" | grep -v "ro,"
# Detect release_agent write (forensic artifact)
grep "release_agent" /var/log/audit/audit.log 2>/dev/null
Forensic Workflow
- Enumerate all cgroups:
systemd-cgls > cgroup_snapshot.txt - Identify orphaned PIDs (processes not in expected cgroup slice)
- Check
release_agentfiles for scripts — any non-empty file is suspicious - Correlate PIDs in unexpected cgroups with network connections
- Map cgroup resource limits — unlimited memory + high CPU = cryptomining indicator
MITRE ATT&CK Mapping
| Finding | Technique |
|---|---|
release_agent with script payload |
T1611 — Escape to Host |
| Process bypassing cgroup limits | T1055 — Process Injection |
| Service registered in cgroup without systemd unit | T1543.002 — Systemd Service |
04 同仓库更多 Skills
devel-jb-algorithmic-art
- Embed algorithms inline in the HTML artifact (don't create separate .
services-wmi-persistence-detect
Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.
services-wmi-exec-exploit
Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.
registry-artifact-extract
Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.
processes-token-impersonate-detect
Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.
processes-thread-injection-detect
Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.