Restricted projects can bypass their restrictions through instance moves, imports, received snapshots and volatile keys
Description
Reported from Incus. This advisory was copied from the Incus advisory GHSA-5pf7-5wqc-rp52.
Project restrictions (restricted.*) are checked when an instance is created or updated through the normal API paths. Several other paths that create or change instances either skipped those checks or ran them against the wrong data:
- Moving an instance to another cluster member with configuration overrides compared the new configuration with itself, so
volatile.*keys were never refused, and a storage pool override was applied only after the checks had run. - Importing an instance backup with a device override could present one storage pool to the checks while the instance was created on another.
- Snapshots received as part of a migration or a copy were recorded with whatever configuration and devices they carried.
- The
volatile.selinux.contextandvolatile.network.ipv4.address/volatile.network.ipv6.addresskeys were accepted from restricted clients without the validation applied to the regular keys they stand in for. limits.cpu.allowancehad no upper bound.
Impact
A client restricted to a project with restricted=true can:
- Store snapshots carrying configuration and devices the project forbids. In a project that uses the default project's custom volumes but blocks access to them through
restricted.devices.diskorrestricted.storage-pools.access, this allows copying such a volume out to a server the client controls. - Place instance root disks on storage pools excluded by
restricted.storage-pools.access, and exceed per-pool disk limits, through a backup import or, on clusters withrestricted.cluster.target=allow, an instance move. - Set
volatile.*keys blocked byrestricted.containers.lowlevelthrough a cluster move, including the recorded ID map of a stopped container. - On OVN networks, give its network's router any address on the shared uplink, such as the uplink gateway's address or that of another project's router, regardless of
ipv4.ovn.rangesandrestricted.networks.subnets, and so disrupt or intercept traffic on the uplink. - On hosts using the SELinux integration, choose the MCS level its instances run at, removing the separation between its own instances and widening what they may access.
- Give a container up to a hundred times the default CPU weight, starving other instances when CPUs are contended.
None of these on its own gives access to the host.
Workarounds
Setting restricted.cluster.target=block (the default) prevents the move-based bypasses.
Projects which don't share the default project's storage volumes (features.storage.volumes=true, the default) aren't exposed to the volume disclosure through received snapshots.
There is no workaround for the backup import, OVN uplink address, SELinux context or CPU allowance issues other than not granting untrusted clients access to restricted projects with those features available.