Linux Privilege Escalation via snapd (dirty_sock exploit)
A flaw in snapd's handling of socket peer credentials allowed any local user to inject a fake UID into the parsed connection string, granting access to privileged API functions. An attacker could then create a local user or sideload a snap to gain root access.
initblog.com
Published on initblog.com
In January 2019, I discovered a privilege escalation vulnerability in default installations of Ubuntu Linux. This was due to a bug in the snapd API, a default service.
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 UID was extracted from a concatenated string by splitting on semicolons, and a second 'uid=' token from the attacker-controlled socket path overwrote the real UID.
Impact
Any local user could gain root access; the exploit works on default Ubuntu installations, though version two may only work once if core snap pieces are missing.
What the attacker needed
Local user account; snapd installed and running
The fix
The snapd team fixed the vulnerability after disclosure.
How it was found
- Create a socket file with a name containing ';uid=0;'
- Bind the socket to that file
- Connect to the snapd API socket
- Use the privileged API to create a user or install a malicious snap
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.
Snapd is a background service on Ubuntu that manages software packages. It checks who is connecting to its control socket by looking at the user ID (UID) of the connecting process. A bug let a local user trick snapd into thinking they were the root user, so they could run privileged commands and take over the machine.
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.