by akvadrako · 7y ago · 0 comments
$ docker run -it -u guest alpine
/ $ su
su: must be suid to work properly
/ $ login
login: must be suid to work properly
/ $ find / -perm /4000 -print
find: /root: Permission denied
find: /proc/tty/driver: Permission denied
/ $The link from the CVE says "Due to the nature of this issue, systems deployed using affected versions of the Alpine Linux container that utilize Linux PAM, or some other mechanism that uses the system shadow file as an authentication database, may accept a NULL password for the root user." - so the config would have to install PAM with suid binaries, and configure shadow passwords and not change the password. This is pretty unlikely overall.
On their website they claim docker is "quite secure" if you "run your processes as non-privileged users inside the container", but I do not see how this would be the case given that breakouts happen all the time, AND again, it requires root to run, which gives me the opposite vibe of secure.
Docker is for convenience and it is a security risk.
All a container is, is a linux process with added security constraints. So, if you're talking about an escalation from an unprivileged process inside a container, you need a standard Linux privesc attack (nothing to do with Docker) and you also need to bypass the isolation mechanisms on that process (namespaces, capabilities, seccomp filter, SELinux/AppArmor)
# docker run -it -p 2222:22/tcp alpine
/ # apk add openssh-server
/ # for t in ecdsa ed25519 rsa ; do ssh-keygen -t $t -C root -P '' -f /etc/ssh/ssh_host_${t}_key ; done
/ # echo PermitRootLogin yes >> /etc/ssh/sshd_config
/ # echo PermitEmptyPasswords yes >> /etc/ssh/sshd_config
/ # /usr/sbin/sshd
Then, on another machine: ssh -p 2222 root@host> 9.8 - CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
(Leaving my opinion out of this.)
If you can do what you said with a non-wheel/sudo account, that would be a serious vulnerability.
suid binaries are binaries with a special flag set that will make it run with root privileges regardless of who started it.
sudo is an example of something that would use suid. When a user runs sudo, the binary actually runs with root privileges from the get-go, checks if the user is OK, then executes the command you specified.
However, use of sudo or other suid binaries is entirely pointless in an alpine container. There being no password also does not matter, as you are by default already running everything as root. Who cares if root can become root?
Best practice would have you switch to a non root user before running whatever it is inside the container. Although if you haven’t added any suid binaries by accident then there’s no way to go back.
E.g. the node alpine image adds a “node:node” user and group for the process to run as instead of root. https://github.com/nodejs/docker-node/blob/master/10/alpine/...