Skip to content
Access control Write-up Advanced

Privilege Escalation in Ubuntu Linux (dirty_sock Exploit)

A flaw in snapd's parsing of socket peer credentials allowed any local user to spoof their UID as root and access privileged API functions. This enabled the creation of a new sudo user, leading to full root access.

shenaniganslabs.io

Published on shenaniganslabs.io

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.

Chris Moberly, on shenaniganslabs.io

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 is extracted from a concatenated string by splitting on semicolons and taking the last 'uid=' token, allowing an attacker-controlled socket path to inject a second 'uid=0' that overwrites the real UID.

Impact

Any local user could obtain root access, and the exploit works on default Ubuntu installations, though version 2 may only work once if core snaps are missing.

What the attacker needed

Local user account on Ubuntu; snapd service running (default)

The fix

The snapd team fixed this right away after disclosure.

How it was found

  1. Create a socket file with a name containing ';uid=0;'
  2. Bind to that socket file
  3. Connect to the snapd API socket
  4. Send a request to a privileged API endpoint (e.g., create-user or install snap)
  5. The injected uid=0 is parsed as the caller's UID, granting access

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 it by looking at a string that includes the user ID. Because part of that string can be controlled by the attacker, they can insert a fake user ID of 0 (root) and trick snapd into thinking they are the administrator. This lets them run commands as 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.