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 flag to enforce mTLS on hubble relay clients #25582

Merged
merged 1 commit into from Jul 5, 2023

Conversation

marqc
Copy link
Contributor

@marqc marqc commented May 22, 2023

Fixes: #24265

Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

For some time hubble-relay clients (hubble CLI, hubble UI) support mTLS. This change adds option to enforce mTLS on connections to hubble-relay.
Fixes: 24265

Add tls-server-enforce-mtls flag to hubble-relay to enforce mTLS connection with clients.

@marqc marqc requested a review from a team as a code owner May 22, 2023 12:51
@marqc marqc requested a review from kaworu May 22, 2023 12:51
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 22, 2023
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label May 22, 2023
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @marqc. I think we want a new flag for the CA used to validate Hubble Relay client connections. On the way I think we should rename some flags for consistency:

  • tls-client-cert-file → tls-hubble-client-cert-file
  • tls-client-key-file → tls-hubble-client-key-file

To clarify that this keypair is used to contact Hubble servers.

  • tls-server-cert-file → tls-relay-server-cert-file
  • tls-server-key-file → tls-relay-server-key-file

To clarify that this keypair is used by the Hubble Relay server. Then the new flag could be named tls-relay-client-ca-files for consistency. While technically a breaking change, the flags renaming should be transparently handled by the Helm charts, so unlikely to affect most users. What do you think? cc @rolinh

@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from da34aa9 to a3f2487 Compare May 24, 2023 14:00
@marqc marqc requested review from a team as code owners May 24, 2023 14:00
@marqc marqc requested a review from youngnick May 24, 2023 14:00
@marqc
Copy link
Contributor Author

marqc commented May 24, 2023

Thanks for the PR @marqc. I think we want a new flag for the CA used to validate Hubble Relay client connections. On the way I think we should rename some flags for consistency:

  • tls-client-cert-file → tls-hubble-client-cert-file
  • tls-client-key-file → tls-hubble-client-key-file

To clarify that this keypair is used to contact Hubble servers.

  • tls-server-cert-file → tls-relay-server-cert-file
  • tls-server-key-file → tls-relay-server-key-file

To clarify that this keypair is used by the Hubble Relay server. Then the new flag could be named tls-relay-client-ca-files for consistency. While technically a breaking change, the flags renaming should be transparently handled by the Helm charts, so unlikely to affect most users. What do you think? cc @rolinh

@kaworu For better backwards compatibility I implemented old flag deprecation instead of just renaming.

The complete set of flags after these changes:

./hubble-relay help serve
Run the gRPC proxy server.

Usage:
  hubble-relay serve [flags]

Flags:
      --cluster-name string                  Name of the current cluster (default "default")
      --dial-timeout duration                Dial timeout when connecting to hubble peers (default 5s)
      --disable-client-tls                   Disable (m)TLS and allow the connection to Hubble server instances to be over plaintext.
      --disable-server-tls                   Disable TLS for the server and allow clients to connect over plaintext.
      --gops                                 Run gops agent (default true)
      --gops-port int                        Port for gops server to listen on (default 9893)
  -h, --help                                 help for serve
      --listen-address string                Address on which to listen (default ":4245")
      --metrics-listen-address string        Address on which to listen for metrics
      --peer-service string                  Address of the server that implements the peer gRPC service (default "unix:///var/run/cilium/hubble.sock")
      --pprof                                Enable serving the pprof debugging API
      --pprof-address string                 Address that pprof listens on (default "localhost")
      --pprof-port int                       Port that pprof listens on (default 6062)
      --retry-timeout duration               Time to wait before attempting to reconnect to a hubble peer when the connection is lost (default 30s)
      --sort-buffer-drain-timeout duration   When the per-request flows sort buffer is not full, a flow is drained every time this timeout is reached (only affects requests in follow-mode) (default 1s)
      --sort-buffer-len-max int              Max number of flows that can be buffered for sorting before being sent to the client (per request) (default 100)
      --tls-hubble-client-cert-file string   Path to the public key file for the client certificate to connect to Hubble server instances. The file must contain PEM encoded data.
      --tls-hubble-client-key-file string    Path to the private key file for the client certificate to connect to Hubble server instances. The file must contain PEM encoded data.
      --tls-hubble-server-ca-files strings   Paths to one or more public key files of the CA which sign certificates for Hubble server instances.
      --tls-relay-client-ca-files strings    Paths to one or more public key files of the CA which sign certificates for Hubble relay client instances.
      --tls-relay-server-cert-file string    Path to the public key file for the Hubble Relay server. The file must contain PEM encoded data.
      --tls-relay-server-key-file string     Path to the private key file for the Hubble Relay server. The file must contain PEM encoded data.
      --tls-server-enforce-mtls              Enforces clients to use mTLS. This option requires providing CA files in tls-hubble-server-ca-files

Global Flags:
  -D, --debug   Enable debug messages

Are you sure that the new flag should be tls-relay-client-ca-files and not tls-relay-server-ca-files?

@marqc marqc requested a review from kaworu May 25, 2023 09:07
@marqc marqc changed the title Enforce mTLS on hubble relay clients Add flag to enforce mTLS on hubble relay clients May 25, 2023
@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from a3f2487 to 7a66ab9 Compare May 25, 2023 09:11
@kaworu kaworu added kind/feature This introduces new functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/hubble Impacts hubble server or relay labels May 25, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels May 25, 2023
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks for the update @marqc!

Are you sure that the new flag should be tls-relay-client-ca-files and not tls-relay-server-ca-files?

Yes, it convey that the CA is used to validate clients, this is consistent with

cilium/pkg/option/config.go

Lines 946 to 949 in 2a966f4

// HubbleTLSClientCAFiles specifies the path to one or more client CA
// certificates to use for TLS with mutual authentication (mTLS). The files
// must contain PEM encoded data.
HubbleTLSClientCAFiles = "hubble-tls-client-ca-files"

@kaworu For better backwards compatibility I implemented old flag deprecation instead of just renaming.

Awesome, could you please add a note in Documentation/operations/upgrade.rst about the flag deprecation and planned removal for v1.15 (in the Deprecated Options section)? Other than that LGTM.

hubble-relay/cmd/serve/serve.go Outdated Show resolved Hide resolved
hubble-relay/cmd/serve/serve.go Outdated Show resolved Hide resolved
@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from 7a66ab9 to abdd143 Compare June 8, 2023 10:18
@marqc marqc requested a review from a team as a code owner June 8, 2023 10:18
@marqc marqc requested a review from zacharysarah June 8, 2023 10:18
@marqc
Copy link
Contributor Author

marqc commented Jun 8, 2023

@kaworu

Awesome, could you please add a note in Documentation/operations/upgrade.rst about the flag deprecation and planned removal for v1.15 (in the Deprecated Options section)? Other than that LGTM.

Documentation updated.

@marqc marqc requested a review from kaworu June 8, 2023 10:23
Copy link
Contributor

@zacharysarah zacharysarah left a comment

Choose a reason for hiding this comment

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

@marqc Some changes required, otherwise LGTM.

Documentation/operations/upgrade.rst Outdated Show resolved Hide resolved
@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from 57a0a68 to 64225e1 Compare June 15, 2023 21:21
@marqc marqc requested a review from zacharysarah June 15, 2023 21:22
@marqc marqc requested a review from kaworu June 19, 2023 08:54
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks @marqc! Patch LGTM, however CI is unhappy:

HINT: to fix this, run 'make -C Documentation update-helm-values'

@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from 5686f3d to fff3d91 Compare June 19, 2023 10:44
@marqc
Copy link
Contributor Author

marqc commented Jun 19, 2023

Thanks @marqc! Patch LGTM, however CI is unhappy:

HINT: to fix this, run 'make -C Documentation update-helm-values'

thanks, fixed

Copy link
Member

@rolinh rolinh left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ti-mo
Copy link
Contributor

ti-mo commented Jun 20, 2023

/test

@ti-mo ti-mo added the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jun 20, 2023
@ti-mo
Copy link
Contributor

ti-mo commented Jun 20, 2023

@marqc Thanks, nice work! I've kicked off tests and put this on the queue to revisit after the 1.14 release branch has been cut.

@ldelossa
Copy link
Contributor

@marqc I think you know the deal by now ;), needs a rebase and a push back up. That will fix the two stuck tests you see in this PR.

@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from fff3d91 to 7a83019 Compare June 27, 2023 19:32
@ldelossa
Copy link
Contributor

/test

@ldelossa ldelossa removed the dont-merge/wait-until-release Freeze window for current release is blocking non-bugfix PRs label Jun 29, 2023
Fixes: cilium#24265
Signed-off-by: Marek Chodor <mchodor@google.com>
Co-authored-by: ZSC <zacharysarah@users.noreply.github.com>
@marqc marqc force-pushed the enforce-mtls-on-hubble-relay-clients branch from 7a83019 to ef9e0eb Compare June 29, 2023 20:29
@kaworu
Copy link
Member

kaworu commented Jun 30, 2023

/test

@ldelossa
Copy link
Contributor

hmm, not sure why travisCI tests are getting blocked.

@ldelossa
Copy link
Contributor

@marqc

Sorry to ask you to do this, but it appears all your PRs are having trouble triggering TravisCI.
I tried to see if I can open a PR myself with your fork, but GH does not recognize your fork when we attempt to 'compare across forks'.

I'm going to leave this message on your other PRs as well, but can you please close this PR and open a new one with the same changes? Hopefully this will fix these issues.

@squeed
Copy link
Contributor

squeed commented Jul 4, 2023

I've manually run the Travis tests (make && make integration-tests) and everything seems fine. I'll try and get this merged.

@squeed squeed added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 4, 2023
@borkmann borkmann added backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch and removed backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. labels Jul 5, 2023
@borkmann borkmann merged commit 15db629 into cilium:main Jul 5, 2023
63 of 64 checks passed
@joamaki joamaki mentioned this pull request Jul 5, 2023
23 tasks
@joamaki joamaki added backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. and removed needs-backport/1.14 This PR / issue needs backporting to the v1.14 branch labels Jul 5, 2023
@jibi jibi added backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. and removed backport-pending/1.14 The backport for Cilium 1.14.x for this PR is in progress. labels Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-done/1.14 The backport for Cilium 1.14.x for this PR is done. kind/community-contribution This was a contribution made by a community member. kind/feature This introduces new functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/hubble Impacts hubble server or relay
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CFP: mTLS security between hubble-cli & hubble-relay