container_escape_audit GitHub ↗
read-only · docker & kubernetes · v4.4

Find the way out of a container before someone else does.

A single bash script runs inside a Docker or Kubernetes container and reports every viable escape vector — 52 checks plus a config-driven CVE engine. It makes no changes to the system. Built for penetration testers and security teams running real assessments.

For authorised security assessments only. Do not run this on systems you don't have explicit written permission to test.

52
distinct checks
27
CVEs tracked
0
writes to the system
100%
pure bash
// what it inspects

Nine surfaces an attacker would probe first.

Each check maps to an established escape primitive — privileged config, capability abuse, namespace breakout, mount exposure, kernel surface, Kubernetes RBAC, cloud metadata theft, container-runtime escape, and kernel hardening posture.

01 / configuration

Privileged mode

Detects --privileged containers and the full capability set that comes with them — the single fastest path to host root.

--privilegedCapEff
02 / configuration

Capability abuse

Flags 16 dangerous Linux capabilities that enable mount, ptrace, module loading, eBPF, raw-device, and DAC-bypass escapes even without full privilege.

CAP_SYS_ADMINCAP_BPFCAP_PERFMONCAP_MKNOD
03 / namespaces

Namespace breakout

Host PID, network, IPC, and mount namespace sharing, plus root-in-container UID mapping that maps straight to host root.

hostPIDnsenteruserns
04 / filesystem

Mount exposure

Runtime sockets, host filesystem bind mounts, writable auth files and cron dirs, linker config, and OCI hook injection paths.

docker.sock/etc/passwdld.so.preload
05 / kernel

Kernel surface

cgroup release_agent escapes, /proc and /dev/mem exposure, eBPF reachability, debugfs/tracefs, keyring, and page-cache writes.

core_patternrelease_agenteBPF
06 / kubernetes

Kubernetes RBAC

Service account token reach, live RBAC escalation probing (create-pods, secrets, exec, attach, impersonate, clusterrole binding), unauthenticated kubelet API, and exposed secret mount directories.

SA tokenkubelet :10250impersonate
07 / cloud

Cloud metadata theft

Checks whether the AWS, Azure, or GCP instance metadata service is reachable — a direct route to cloud credentials and role assumption.

169.254.169.254IMDSIAM
08 / runtime

Container-runtime escape

Runtime version detection (runc, containerd, cri-o), io_uring reachability, kTLS/sockmap surface, Kata agent socket exposure, and KVM/arm64 guest-to-host vGIC-ITS probing.

runcio_uringKataKVM/arm64
09 / hardening

Kernel hardening posture

Reads sysctl values against a hardening baseline — kptr/dmesg restrict, ASLR, unprivileged userns clone, and a dangerous-module audit.

kptr_restrictrandomize_va_spaceperf_event
// the deliverable

Every finding is a self-contained briefing.

No raw flags to decode. Each result tells you what it is, what an attacker does with it, how hard that is, and exactly how to close it — ready to paste into a report.

CRITICALCVE-2026-31431
What it isAF_ALG socket family reachable; the authencesn AEAD algorithm can be bound and spliced.
ImpactControlled 4-byte writes into the page cache of any readable setuid binary → root.
ExploitabilityTrivial. A ~732-byte Python PoC achieves root reliably. No capabilities required. On CISA KEV.
RecommendationApply distro kernel patches. Interim: unload algif_aead, block AF_ALG via seccomp.

Severity that reflects reality

A single CRITICAL is generally enough for full host compromise. But findings combine — a MEDIUM seccomp gap alongside a HIGH capability becomes a practical escape path the tool flags accordingly.

CRITICALHost escape likely with minimal effort.
HIGHExploitable with moderate effort or in combination.
MEDIUMDefence-in-depth gap; raises other findings' risk.
INFORecorded for context and cross-referencing.
// recent vectors

Current CVEs, not just the 2016 classics.

Checks 24–52 add coverage for vectors most scanners miss — including container-runtime escapes (runtime version detection, io_uring, kTLS/sockmap, Kata, KVM/arm64) — alongside a CVE engine driven by an updatable plain-text database you can version independently of the script.

2026 headliners

  • ITScape — CVE-2026-46316 (CVSS 9.3)
  • Copy Fail — CVE-2026-31431
  • Dirty Frag family — 43284 / 43500
  • io_uring zcrx OOB — CVE-2026-43121

The classics

  • runc escape — CVE-2019-5736
  • Leaky Vessels — CVE-2024-21626
  • DirtyPipe — CVE-2022-0847
  • DirtyCOW — CVE-2016-5195

Hardening posture

  • kptr / dmesg restrict, ASLR
  • unprivileged userns clone
  • perf_event_paranoid
  • 21 dangerous module audit
// quickstart

Two files, same directory, one run.

The script and its CVE database sit side by side. Output goes to a timestamped report — or JSON for piping into CI, SIEM, or jq.

bash
# pull the script and its CVE database curl -O https://raw.githubusercontent.com/liamromanis101/K8s-container_escape_audit/main/container_escape_audit.sh curl -O https://raw.githubusercontent.com/liamromanis101/K8s-container_escape_audit/main/cve_checks.conf chmod +x container_escape_audit.sh # standard run — writes a timestamped report ./container_escape_audit.sh # JSON out, filter to CRITICAL findings only ./container_escape_audit.sh --json --no-report | jq '.findings[] | select(.severity=="CRITICAL")'
// get started

Know your escape paths before the APT does.

Free for personal use, internal assessments, and non-profit work under CC BY-NC 4.0.