A series of critical vulnerabilities in Ubuntu’s needrestart package, which is installed by default in Ubuntu Server since version 21.04, have been discovered by the Qualys Threat Research Unit (TRU). The needrestart utility, which helps determine which services need to be restarted after applying updates, has been found to contain several flaws that could allow local attackers to escalate their privileges and gain root access. The vulnerabilities, which have existed since the introduction of interpreter support in needrestart version 0.8 in 2014, are trivial to exploit, posing a serious risk to both individuals and organizations using affected versions of Ubuntu and Debian Linux distributions.
The identified flaws involve the improper handling of environment variables such as PYTHONPATH and RUBYLIB, which could be exploited to trick the needrestart package into executing arbitrary code with root privileges. These flaws are related to the execution of Python and Ruby interpreters in needrestart without proper validation, allowing attackers to inject malicious code. Additionally, two vulnerabilities in the libmodule-scandeps-perl package could be used to execute arbitrary shell commands, further escalating the attack. These vulnerabilities have been assigned CVSS scores ranging from 5.3 to 7.8, indicating their potential severity.
Successful exploitation of these vulnerabilities could lead to significant security risks, as attackers could gain complete control over the affected system. Once root privileges are obtained, attackers could execute arbitrary code, potentially leading to data theft, system compromise, or further exploitation of critical infrastructure. Given that needrestart is often run as the root user during package installations or upgrades, the impact of these vulnerabilities could be far-reaching, especially for systems that regularly apply updates or patches.
Ubuntu has issued patches in version 3.8 of needrestart, addressing these flaws and mitigating the risks. Users are strongly urged to update their systems to this version to protect against potential exploitation. For those unable to immediately apply the updates, Ubuntu recommends temporarily disabling interpreter scanners in the needrestart configuration file, though this should be reverted once the patches are applied. The discovery of these vulnerabilities serves as a reminder of the importance of maintaining up-to-date software and securing critical system utilities against exploitation.