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

Add input filter rule for wireguard #6250

Merged

Conversation

muff1nman
Copy link
Contributor

@muff1nman muff1nman commented Jun 20, 2022

Description

Without this rule, in an environment with a default drop, Wireguard
traffic will not be accepted. This change adds a static input rule in the
same fashion as done for other encapsulation modes (ipip, vxlan) to
ensure these packets are accepted. No drop rule is needed however as
wireguard does its own validation of incoming messages.

Todos

  • Tests
  • Documentation
  • Release note

Release Note

Calico will now add an ACCEPT rule for the Wireguard UDP port when enabled to ensure policy doesn't drop Calico Wireguard traffic.

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

  • docs-pr-required: This change requires a change to the documentation that has not been completed yet.
  • docs-completed: This change has all necessary documentation completed.
  • docs-not-required: This change has no user-facing impact and requires no docs.

Every PR needs one release-note-* label.

  • release-note-required: This PR has user-facing changes. Most PRs should have this label.
  • release-note-not-required: This PR has no user-facing changes.

Other optional labels:

  • cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.
  • needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.

Without this rule, in an environment with a default drop, Wireguard
traffic will not be accepted. This change adds a static input rule in the
same fashion as done for other encapsulation modes (ipip, vxlan) to
ensure these packets are accepted. No drop rule is needed however as
wireguard does its own validation of incoming messages.
@muff1nman muff1nman requested a review from a team as a code owner June 20, 2022 21:44
@marvin-tigera marvin-tigera added this to the Calico v3.24.0 milestone Jun 20, 2022
@marvin-tigera marvin-tigera added docs-pr-required Change is not yet documented release-note-required Change has user-facing impact (no matter how small) labels Jun 20, 2022
@CLAassistant
Copy link

CLAassistant commented Jun 20, 2022

CLA assistant check
All committers have signed the CLA.

@caseydavenport
Copy link
Member

Interesting. I don't believe the equivalent rules for VXLAN / IPIP were added to deal with a default DROP environment, but rather to tighten the security posture by only allowing encap packets from known Calico hosts. That said, I see that they would address that scenario as well.

I think this is probably OK to do for Wireguard as well, as the encap'd packets will still be run through Calico policy afterwards and as you say Wireguard will do verification as well based on its configuration.

/sem-approve

@caseydavenport
Copy link
Member

Oh, and @muff1nman you'll need to sign the contributor agreement to make the CLA bot happy.

@caseydavenport caseydavenport added the docs-not-required Docs not required for this change label Jun 21, 2022
@marvin-tigera marvin-tigera removed the docs-pr-required Change is not yet documented label Jun 21, 2022
@coutinhop
Copy link
Contributor

Hi @muff1nman,

First of all, thanks for your contribution!

The wireguard port is added to the failsafes (when enabled) in

// If wireguard is enabled, update the failsafe ports to include the wireguard port.
, which ultimately should add an allow rule for the wireguard port and be equivalent to what your changes are doing.

I'm just trying to understand, what was the issue you were seeing with default DROP? I'm thinking the fix may be something else (if wireguard is not working properly with default DROP)...

By also adding an output filter rule for wireguard, this allows
wireguard to be consistent with other tunneling rules and removes the
need for failsafes entirely. Accordingly failsafe rules for wireguard
are removed.
@muff1nman
Copy link
Contributor Author

@coutinhop Based on our out-of-band conversation I've removed the failsafes logic entirely for wireguard and added any missing rules to the static rules (namely OUTPUT). Feel free to reiterate/summarize our conversation here especially if you feel the latest change doesn't meet your expectations. I'll plan to squash.

@coutinhop
Copy link
Contributor

@muff1nman thanks for these changes! That was exactly what I had in mind. @caseydavenport @fasaxc could you take a look and see if you can tell anything that could go wrong by switching from the failsafes to these static rules? Thanks!

/sem-approve

@coutinhop
Copy link
Contributor

/sem-approve

@caseydavenport caseydavenport merged commit 3a6eefe into projectcalico:master Jun 28, 2022
@muff1nman muff1nman deleted the ademaria/wireguard-input branch August 30, 2022 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required Docs not required for this change release-note-required Change has user-facing impact (no matter how small)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants