Crash handling in Linux
The Ubuntu crash handler Apport could be tricked into writing a root-owned coredump file with attacker-controlled content into a directory like /etc/logrotate.d, by manipulating the process name and recycling PIDs. This allowed a local attacker to escalate privileges to root when logrotate later executed the malicious configuration.
alephsecurity.com
Published on alephsecurity.com
In this article we will explore ‘Apport’, the Ubuntu crash handler. When an application crashes Apport is executed by the kernel, reads information about the crashed process, and then creates a crash report that can be sent to Ubuntu developers.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the root cause is that Apport parses /proc/pid/status without properly handling newline characters in the process name, allowing injection of fake Uid and Gid lines, and it also fails to correctly verify the process start time due to the same name injection, enabling PID recycling.
Impact
A local attacker could escalate privileges to root, as demonstrated by obtaining a root shell when logrotate executed the malicious configuration.
What the attacker needed
Local user access; ability to crash processes; logrotate runs daily
The fix
The vulnerabilities were fixed by Ubuntu in a patch to Apport.
How it was found
- Create a FIFO file in /var/crash to stall the first Apport instance.
- Run a decoy process to trigger Apport and lock /var/run/apport.lock.
- Create a symlink to /usr/bin/sudo with a name containing carriage returns and fake Uid/Gid lines.
- Change directory to /etc/logrotate.d/.
- Start the crash program and fork many processes to wrap the PID to crash_pid - 1.
- Send SIGSEGV to the crash program, then SIGKILL it and replace it with the suid symlink process.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Apport is a program that runs when another program crashes, to collect information for debugging. The researchers found that by giving their crashing program a special name and by reusing process IDs, they could make Apport write a file as the root user into a place where root-run programs look for configuration. That file could then be used to run commands as root, giving full control of the system.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.