Privilege escalation with polkit: How to get root on Linux with a seven-year-ol
A flaw in polkit's handling of errors when looking up the UID of a D-Bus connection allowed an unprivileged local user to create a new user account with sudo privileges and then set its password, leading to root access. The vulnerability could be triggered by killing a dbus-send command at a precise moment during polkit's authorization check.
github.blog
Published on github.blog
Kevin Backhouse·@kevinbackhouse
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, polkit failed to check the error returned when looking up the UID of a D-Bus connection that no longer existed, and instead treated the request as coming from UID 0 (root).
Impact
An unprivileged local attacker could gain root privileges on vulnerable systems.
What the attacker needed
Local user account; polkit version 0.113 or later; accountsservice and gnome-control-center installed (or…
How it was found
- Measure how long a dbus-send command takes to create a user normally.
- Run the dbus-send command in the background and kill it after a delay of about half the measured time.
- Repeat until a new user is created.
- Generate a hashed password using openssl.
- Run the dbus-send command to set the password for the new user, again killing it after a delay.
- Log in as the new user and use sudo to become root.
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.
Polkit is a system service that decides whether you are allowed to do privileged actions, like creating a user. A bug meant that if a request came from a process that had already exited, polkit mistakenly treated it as if it came from the root user, so it allowed the action without asking for a password. An attacker could exploit this to create a new user with admin rights and then become root.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.