Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf: Handle ICMPv6 NS/NA in host firewall #12049

Merged
merged 1 commit into from Jun 29, 2020

Conversation

pchaigno
Copy link
Member

@pchaigno pchaigno commented Jun 12, 2020

In IPv6 mode, when the host firewall is enabled and rules are enforced, we start dropping ICMPv6 packets that are required to route packets. In particular, we can notice the following drops in cilium monitor:

xx drop (Policy denied) flow 0x1fc0ef0 to endpoint 0, identity 1->0: fd00::c -> f00d::a0f:0:0:dfa1 DestinationUnreachable(NoRouteToDst)
xx drop (Policy denied) flow 0x0 to endpoint 0, identity 0->0: fd01::c -> fd01::b NeighborAdvertisement

The nodes need to be able to exchange ICMPv6 NS and NA messages to establish routes. We already handle the response to NS messages on ingress, but when the egress policies are enforced, we start dropping outgoing NS and NA messages.

This commit fixes that by allowing and rejecting ICMPv6 messages according to RFC4890 Section 4.4. No other verifications than the types' are performed on the messages' correctness or their source IP addresses. Such messages from the pods are already handled on their egress, so we're not at risk of spoofing from pods here.
Handling of echo request and reply messages does not conform to RFC4890 as they can be filtered by the host firewall. That is to be consistent with our handling of ICMPv4 messages.

With this commit, we also stop answering to NS and echo request messages from the BPF program on ingress to the host. This behavior had been broken by a695f53, but we will now explicitly stop replying to those messages and pass them up the stack instead.

Updates: #11799
Fixes: #10994
Fixes: #11507

@pchaigno pchaigno added sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/bug This PR fixes an issue in a previous release of Cilium. needs-backport/1.8 labels Jun 12, 2020
@pchaigno pchaigno force-pushed the pr/pchaigno/host-fw-handle-icmpv6 branch from 8993991 to 465977d Compare June 12, 2020 13:16
@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.8.0 Jun 12, 2020
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Needs backport from master in 1.8.0 Jun 12, 2020
@pchaigno pchaigno marked this pull request as ready for review June 12, 2020 13:31
@pchaigno pchaigno requested a review from a team June 12, 2020 13:31
@coveralls
Copy link

coveralls commented Jun 12, 2020

Coverage Status

Coverage decreased (-0.02%) to 36.926% when pulling a4755fb on pr/pchaigno/host-fw-handle-icmpv6 into ca767ee on master.

@pchaigno pchaigno force-pushed the pr/pchaigno/host-fw-handle-icmpv6 branch from 465977d to 4365ce3 Compare June 12, 2020 13:55
@pchaigno
Copy link
Member Author

test-me-please

@pchaigno
Copy link
Member Author

K8S-1.17-Kernel-4.19 hit #10231. All other pipelines are passing.

@joestringer
Copy link
Member

@jedsalazar @joestringer Since you looked into these sort of things recently, are there any concerns with allowing ICMPv6 NS/NA messages through the host firewall?

The recent issues were specifically for router solicitations/advertisements, for what it's worth. But similar to the logic you point out in your commit messages, this program is in the wrong place to have any security impact from pods generating such messages. (I note also that the reason this was bad for pods was based on a threat model of someone gaining arbitrary execution access to a pod; that's a different threat model than someone having access to your physical network)

I see the Host FW as an L3 security feature here, where routed traffic destined to the node is subject to policy. ICMPv6 NS/NA, RS/RA are more about L2 adjacency. I don't think it's our job to handle L2 network security here; users could legitimately configure their nodes directly adjacent to a router that sends IPv6 RAs and we will trust the underlying network. I think it's up to the user to configure their Linux boxes with the right settings for handling these messages. I note that in the PR as-is, this network configuration would actually break because we'd be dropping the router advertisements from the network. Fortunately, Cilium will log the drops pretty clearly in cilium monitor so if someone hit an issue with this, they should be able to find out reasonably quickly.

If we want to involve ourselves in L2 security features like this, we probably need to think it through and actually design it, complete with some clear way for users to configure it with what they anticipate the underlying network to legitimately allow; if we step in here and start messing with people's ICMPv6 peer discovery then I think we'll more likely break IPv6 in weird&wonderful ways while not actually improving security.

Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

Couple of discussion points, I think we should be really careful on how Cilium steps into L2 here.

bpf/bpf_host.c Show resolved Hide resolved
bpf/bpf_host.c Outdated Show resolved Hide resolved
@pchaigno pchaigno force-pushed the pr/pchaigno/host-fw-handle-icmpv6 branch from 4365ce3 to 8495e8c Compare June 16, 2020 14:23
@pchaigno pchaigno requested a review from a team as a code owner June 16, 2020 14:23
@pchaigno
Copy link
Member Author

test-me-please

@pchaigno
Copy link
Member Author

pchaigno commented Jun 17, 2020

Re-running 4.9 test now that the host firewall is enabled there by default (cf. #11969):
retest-4.9

@anfernee
Copy link
Contributor

Just a friendly ask: Is there anything blocking this change to be merged?

@aanm
Copy link
Member

aanm commented Jun 23, 2020

Just a friendly ask: Is there anything blocking this change to be merged?

@anfernee only the review from @joestringer 😄

@pchaigno
Copy link
Member Author

All tests are passing. The pending tests are just because some of the GitHub Actions were renamed, but they were already executed under their old names before.

@joestringer joestringer removed this from In progress in 1.8.0 Jun 26, 2020
@joestringer joestringer removed this from Needs backport from master in 1.8.0 Jun 26, 2020
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

Looks good, minor nits on consistent use of CTX_ACT_OK / IS_ERR(...).

bpf/bpf_host.c Outdated Show resolved Hide resolved
bpf/bpf_host.c Outdated Show resolved Hide resolved
bpf/lib/icmp6.h Outdated Show resolved Hide resolved
bpf/lib/icmp6.h Outdated Show resolved Hide resolved
In IPv6 mode, when the host firewall is enabled and rules are enforced,
we start dropping ICMPv6 packets that are required to route packets. In
particular, we can notice the following drops in cilium monitor:

  xx drop (Policy denied) flow 0x1fc0ef0 to endpoint 0, identity 1->0: fd00::c -> f00d::a0f:0:0:dfa1 DestinationUnreachable(NoRouteToDst)
  xx drop (Policy denied) flow 0x0 to endpoint 0, identity 0->0: fd01::c -> fd01::b NeighborAdvertisement

The nodes need to be able to exchange ICMPv6 NS and NA messages to
establish routes. We already handle the response to NS messages on
ingress, but when the egress policies are enforced, we start dropping
outgoing NS and NA messages.

This commit fixes that by allowing and rejecting ICMPv6 messages
according to RFC4890 Section 4.4. No other verifications than the types'
are performed on the messages' correctness or their source IP addresses.
Such messages from the pods are already handled on their egress, so we're
not at risk of spoofing from pods here.
Handling of echo request and reply messages does not conform to RFC4890
as they can be filtered by the host firewall. That is to be consistent
with our handling of ICMPv4 messages.

With this commit, we also stop answering to NS and echo request messages
from the BPF program on ingress to the host. This behavior had been
broken by a695f53 ("Endpoint for host"), but we will now explicitly stop
replying to those messages and pass them up the stack instead.

Fixes: a695f53 ("Endpoint for host")
Fixes: 489dbef ("bpf: Enforce host policies for IPv6")
Signed-off-by: Paul Chaignon <paul@cilium.io>
@pchaigno pchaigno force-pushed the pr/pchaigno/host-fw-handle-icmpv6 branch from 8495e8c to a4755fb Compare June 29, 2020 19:24
@pchaigno
Copy link
Member Author

test-me-please

@joestringer joestringer merged commit 5244b68 into master Jun 29, 2020
@joestringer joestringer deleted the pr/pchaigno/host-fw-handle-icmpv6 branch June 29, 2020 21:56
@pchaigno pchaigno added the area/host-firewall Impacts the host firewall or the host endpoint. label Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/host-firewall Impacts the host firewall or the host endpoint. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
No open projects
1.8.1
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

6 participants