Skip to content

Conversation

burgerdev
Copy link
Contributor

When the network interface provisioned by the CNI has static ARP table entries, the runtime calls AddARPNeighbor to propagate these to the agent. As of today, these calls are simply rejected.

In order to allow the calls, we do some sanity checks on the arguments.

We must ensure that we don't unexpectedly route traffic to the host that was not intended to leave the VM. In a first approximation, this applies to loopback IPs and devices. However, there may be other sensitive ranges (for example, VPNs between VMs), so there should be some flexibility for users to restrict this further. This is why we introduce a setting, similar to UpdateRoutes, that allows restricting the neighbor IPs further. Note that reverting back to the existing "deny all ARP neighbours" behaviour is as simple as forbidding IP .*.

Forbidding ARP entries for loopback IPs is mostly defence-in-depth - these should be rejected/ignored by the kernel!

The only valid state of an ARP neighbor entry is NUD_PERMANENT, which has a value of 128. This is already enforced by the runtime.

According to rtnetlink(7):

              Valid ndm_flags are:
              NTF_PROXY    a proxy arp entry
              NTF_ROUTER   an IPv6 router

These values are 8 and 128, respectively, thus we allow any combination of these (128 | 8 == 136).

When the network interface provisioned by the CNI has static ARP table entries,
the runtime calls AddARPNeighbor to propagate these to the agent. As of today,
these calls are simply rejected.

In order to allow the calls, we do some sanity checks on the arguments:

We must ensure that we don't unexpectedly route traffic to the host that was
not intended to leave the VM. In a first approximation, this applies to
loopback IPs and devices. However, there may be other sensitive ranges (for
example, VPNs between VMs), so there should be some flexibility for users to
restrict this further. This is why we introduce a setting, similar to
UpdateRoutes, that allows restricting the neighbor IPs further.

The only valid state of an ARP neighbor entry is NUD_PERMANENT, which has a
value of 128 [1]. This is already enforced by the runtime.

According to rtnetlink(7), valid flag values are 8 and 128, respectively [2],
thus we allow any combination of these.

[1]: https://github.com/torvalds/linux/blob/4790580/include/uapi/linux/neighbour.h#L72
[2]: https://github.com/torvalds/linux/blob/4790580/include/uapi/linux/neighbour.h#L49C20-L53

Fixes: kata-containers#11664

Signed-off-by: Markus Rudy <mr@edgeless.systems>
@@ -347,6 +347,14 @@
"^127\\.(?:[0-9]{1,3}\\.){2}[0-9]{1,3}$"
]
},
"AddARPNeighborsRequest": {
"forbidden_device_names": [
"lo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burgerdev, thanks for looking into this!

Do you think forbidden_device_names for both AddARPNeighborsRequest and UpdateRoutesRequest should specify regex values instead of the full interface names?

Users might not need the flexibility of regex, but I guess some of them might want to specify as forbidden:

"^.*$", or
"^eth[0-9]+$", or even
"^lo0?$"

@danmihai1 danmihai1 merged commit ea74024 into kata-containers:main Aug 13, 2025
509 of 546 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants