Skip to main content
Menu
Advisories

Local users can gain root on the host through transfer sockets, instance directories and disk staging mounts

GHSA-FXG7-8R76-78R5Published Updated GitHub

Description

Reported from Incus. This advisory was copied from the Incus advisory GHSA-p8fx-6xxm-25wh.

Several places where the daemon and its helpers act as root on the host trusted things that a local, unprivileged user controls.

While an instance or volume is transferred with rsync, the sending side waits for its own helper on an abstract unix socket and takes the first connection it gets, without looking at who connected.

Proxy devices that listen on a unix socket on the host set the socket's owner and mode by path after creating it, and the AppArmor profile generated for the proxy resolves both socket paths on the host and writes the result into the profile as is.

The directory holding a container on the storage pool is what keeps local users away from the setuid files inside its root filesystem. Its owner could be set by whoever supplied the container's content, through a migration, an image or a backup.

Finally, while a container starts or a disk is hot-plugged, the disk's source is briefly mounted under a path any local user can traverse, with setuid bits still honored.

Impact

A member of the incus group, who through incus-user only has access to their own restricted project, can become root on the host. They can do so either by creating a container whose directory they own and then running a setuid-root file from its root filesystem, or by placing a setuid-root file on one of their own custom volumes and running it through the staging mount while their container starts. Both work with the project and profile exactly as incus-user creates them.

A local user who is in no Incus group at all can:

  • Read the full contents of any instance or custom volume while it is copied, moved, refreshed or migrated with rsync, and choose what the receiving side writes. When a container is copied between two pools of the same host, this lets them plant and run a setuid-root file.
  • Take ownership of, or make world-readable, any file on the host when a proxy device listens on a unix socket in a directory they can write to.
  • Add their own rules to an AppArmor profile loaded by the daemon, or prevent a container from starting, when a proxy device names a unix socket path at which they can create files on the host.
  • Run setuid-root files from another user's custom volume through the staging mount while that user's container starts.

Those last four depend on an administrator or another user starting a transfer, starting an instance or having configured such a proxy device; the local user can't trigger them.

Workarounds

Don't give untrusted local accounts membership of the incus group, and avoid proxy devices with unix sockets in directories that other users can write to.

Mounting the filesystem that holds the Incus directory with nosuid prevents the setuid-based escalations, but containers then lose setuid support too unless they use idmapped mounts on a separate filesystem.

There is no workaround for the transfer socket other than not having untrusted local users on hosts where rsync-based transfers are used (dir, lvm and cross-driver copies).

References

GitHub · canonical/lxd