Linux vendors on Tuesday issued patches for a memory corruption vulnerability in a component called polkit that allows an unprivileged logged-in user to gain full root access on a system in its default configuration.
Security vendor Qualys found the flaw and published details in a coordinated disclosure.
Polkit, previously known as PolicyKit, is a tool for setting up policies governing how unprivileged processes interact with privileged ones. The vulnerability resides within polkit’s
pkexec, a SUID-root program that’s installed by default on all major Linux distributions. Designated CVE-2021-4034, the vulnerability has been given a CVSS score of 7.8.
Bharat Jogi, director of vulnerability and threat research at Qualys, explained in a blog post that the
pkexec flaw opens the door to root privileges for an attacker. Qualys researchers, he said, have demonstrated exploitation on default installations of Ubuntu, Debian, Fedora, and CentOS, and other Linux distributions are presumed to be vulnerable as well.
“This vulnerability has been hiding in plain sight for 12+ years and affects all versions of
pkexec since its first version in May 2009,” said Jogi, pointing to commit c8c3d83, which added a
The problem occurs when
main() function processes command-line arguments and
argc – the ARGument Count – is zero. The function tries to access the list of arguments anyway, and ends up trying to use an empty
argv – the ARGument Vector of command-line argument strings. As a result, out-of-bounds memory gets read and written, which an attacker can exploit to inject an environment variable that can cause arbitrary code to be loaded from storage and run by the program as root.
“This out-of-bounds write allows us to re-introduce an ‘unsecure’ environment variable (for example,
pkexec‘s environment,” explains Jogi. “These ‘unsecure’ variables are normally removed (by
ld.so) from the environment of SUID programs before the
main() function is called.”
The fact that these variables can be reintroduced leaves the code vulnerable. At least the exploitation technique proposed by Qualys – injecting the
GCONV_PATH variable into
pkexec‘s environment to execute a shared library as root – leaves traces in log files.
Jogi said that polkit also works with non-Linux operating systems such as Solaris and BSD. Those systems have not been tested for exploitability but OpenBSD, he said, is not affected because the kernel won’t
execve() – execute a program by its pathname – if
argc is 0.
Patches are available for various distributions, including Red Hat and Ubuntu. This isn’t something you’ll want to leave untended particularly if you run a multi-user system. ®