teamssix / twiki-vssue

1 stars 0 forks source link

[Vssue]容器逃逸方法检测指北 | T Wiki #5

Open teamssix opened 2 years ago

teamssix commented 2 years ago

http://localhost:8080/CloudNative/Docker/container-escape-check.html

azraelxuemo commented 2 years ago

您好,我对于挂载宿主机根目录有点疑问 就是如果没有挂载,那么/etc/passwd只有一份,如果挂在了,可能/etc/passwd不止1分,我这里就有10份如下,所以我建议比较改成是否等于1 但是由于我这里10包括1,所以grep 1也不可以,不知道有没有什么好的建议

/etc/passwd /host_fs/etc/passwd /host_fs/usr/src/glibc/glibc-2.34/grp/tst-initgroups1.root/etc/passwd /host_fs/usr/src/glibc/glibc-2.34/grp/tst-initgroups2.root/etc/passwd /host_fs/usr/src/glibc/glibc-2.34/nss/tst-nss-compat1.root/etc/passwd /host_fs/var/lib/docker/overlay2/fd251d8ca7a728395186ea402d21fbc82b6ae1d2b0513ef34ab0b2fdfdde171c/diff/etc/passwd /host_fs/var/lib/docker/overlay2/15f3d4e9ceb4bf7c8e2708417c74294a5da8ca1c533fd761ce2c84cf1ed1c60c/merged/etc/passwd /host_fs/var/lib/docker/overlay2/b9888cd97c84e743a11df8a040103935515944d425eff0cde996174dd7b9069b/diff/etc/passwd /host_fs/snap/core20/1581/etc/passwd /host_fs/snap/core20/1587/etc/passwd

我觉得可以写成这样 find / -name passwd 2>/dev/null | grep /etc/passwd | wc -l | grep -q ^1$&&echo "Root directory is not mounted."|| echo "Root directory is mounted."