Restricted projects and instances can manipulate host interfaces, other projects' networks and DNS
Description
Reported from Incus. This advisory was copied from the Incus advisory GHSA-fg2p-r659-c4q8.
Several checks around instance NICs, managed networks, network zones and network ACLs did not hold for restricted projects or for the instances themselves.
A client restricted to a project with restricted=true could:
- set the
host_nameoption of a NIC to an arbitrary string, which was used as is in the host's nftables rules and as the name of a host interface to remove before the NIC is created; - set
bridge.external_interfacesandtunnel.*on its own OVN network, attaching host interfaces or tunnels of its choosing to that network, and have an existing host interface removed by deleting a network whose creation had been refused; - point
dns.zone.forwardanddns.zone.reverse.*of its network at a network zone of another project, regardless ofrestricted.networks.zones; - add zone file lines of its choosing to a network zone through line breaks in record entries, record names,
dns.contactordns.nameservers, or break every transfer of a shared zone through a crafted name; - delete an OVN network forward whose address one of its NICs still uses, or create forwards and load balancers on addresses later handed out as another project's router address;
- remove the VLAN interface shared by every NIC of a managed macvlan or SR-IOV network by stopping its own instance, end up on the wrong parent interface when two parents with long names use the same VLAN ID, and keep another project's instance from starting by reusing its name, MAC address or IP address on a stopped instance;
- delete or change network ACLs still in use by NICs of other projects, as bridged NICs on a network shared from the default project and bridged NICs using
parentwere not counted as users; - win a race on container restart that makes an instance port forward connect from the host's network namespace.
Root inside an instance could:
- on a
physicalor SR-IOV NIC, hand back a tap or veth interface of its own under the expected name when the device is removed, which the host then renamed, gave the original MAC address and attached to the next instance using that network; - bypass
security.ipv4_filteringandsecurity.ipv6_filteringwith 802.1ad tagged frames when the NIC also has an ACL with an allow rule or has a family blocked entirely; - have the dynamic NAT proxy and BGP instance announcements use addresses it merely claimed through ARP or neighbor discovery;
- remove or misdirect the DNS name of another instance on the same managed bridge through forged DHCP messages, despite
security.mac_filtering.
A DHCP server on the network of an OCI container could also add lines to that container's resolv.conf, overriding oci.dns.nameservers.
Finally, on clusters, network ACL updates were not sent to the other members when the ACL was only used by instance NICs, and profile changes made through PATCH were not applied on the other members.
Impact
The most severe case is the NIC host_name option. With default project restrictions, a restricted client can add its own rules to the host's bridge firewall, for example dropping the traffic of every instance on every bridge of the server, and can obtain a few lines of files that only root can read through the resulting error message. The same option lets it delete host interfaces by name, including the bridge of a network its project can't use, VLAN and tunnel interfaces, and the host side of another project's NIC.
The OVN options give instances of a restricted project layer 2 access to host networks the administrator never offered to that project, and the pending network issue lets the client remove a host interface it names.
The remaining issues let a tenant or its instances interfere with other tenants on shared networks: taking over the traffic of the next instance attached to a physical network, sending traffic with forged source addresses, publishing DNS records in zones they don't own, removing another instance's DNS name, redirecting a published proxy port or announcing arbitrary host routes over BGP, causing two projects to share one external OVN address, cutting the network of other projects' instances, or preventing them from starting.
On clusters, ACL rules and profile limits that an administrator changed could remain unapplied on some members.
The host's physical interfaces and lo can't be deleted through any of these issues.
Workarounds
Most of the project-level issues can be avoided by setting restricted.devices.nic=block on restricted projects, or by not enabling features.networks and features.networks.zones on them. This prevents those projects from managing their own NICs, networks and zones, which may not be acceptable.
There is no workaround for the issues triggered from inside an instance other than giving each tenant its own networks, nor for the cluster notification issues other than applying ACL and profile changes on each member through PUT.