Restricted project users can read or overwrite host files through special files, hard links or symlinks in backup or image metadata
Description
Reported from Incus. This advisory was copied from the Incus advisory GHSA-5pgx-q9xx-j3qv.
Impact
A client with a restricted certificate that can create images, instances or backups in a project can import a backup or image whose metadata area — the instance volume excluding the guest rootfs, such as metadata.yaml, backup.yaml or any entry beside them — contains a special file, a hard link or a symlink in place of a regular file.
The daemon processes these files as root, outside any container confinement:
- A block or character device special file is read and written as the referenced host device. The major and minor numbers are attacker-chosen, so the node can target any host device. Pointed at a host block device, this corrupts the host's or another instance's storage. A named pipe makes the import block the daemon indefinitely.
- A hard link in place of
backup.yamlis followed when the daemon writes the instance's backup file, so the write lands on the attacker-chosen host file. - A symlink in the metadata area is followed when the instance is later published or exported, so the generated image or backup embeds the contents of the file it points at, including files of other projects or of the host.
Workarounds
Do not grant image, instance or backup creation to restricted certificates or restricted-project users for untrusted tenants until patched. Operators can audit imported instances for non-regular files, hard links or symlinks in the metadata area (everything in the instance volume except the rootfs directory).