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

✨ Allow TLS minimum version to be configured #1548

Merged

Conversation

willthames
Copy link
Contributor

@willthames willthames commented Jun 7, 2021

Some environments have automated security scans that trigger
on TLS versions or insecure cipher suites. Setting TLS to 1.3
would solve both problems (setting to 1.2 only solves the former
as the default 1.2 cipher suites are insecure).

Default TLS minimum version of 1.0 remains.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 7, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @willthames!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @willthames. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 7, 2021
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 7, 2021
@willthames
Copy link
Contributor Author

One could argue that only 1.3 makes any real sense but I've gone with the same TLS version options as go's crypto package

@willthames willthames changed the title :bug Allow TLS minimum version to be configured 🐛 Allow TLS minimum version to be configured Jun 7, 2021
@willthames willthames changed the title 🐛 Allow TLS minimum version to be configured 🐛 Allow TLS minimum version to be configured Jun 7, 2021
@coderanger
Copy link
Contributor

/ok-to-test

@willthames You'll need to rebase/amend to remove the Fixes from the commit message. Because of how Kubernetes vendoring works, it can get noisy to leave those in the commits themselves.

As for default version, I would be fine setting it to 1.3 if all recent kube-apiservers support that. That's the only thing which actually matters as a client.

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 7, 2021
Some environments have automated security scans that trigger
on TLS versions or insecure cipher suites. Setting TLS to 1.3
would solve both problems (setting to 1.2 only solves the former
as the default 1.2 cipher suites are insecure).

Default TLS minimum version of 1.0 remains.
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 7, 2021
@willthames
Copy link
Contributor Author

See #1431 for related issue

@willthames
Copy link
Contributor Author

@coderanger TLS 1.3 support was enabled by default with go 1.13 (https://golang.org/doc/go1.13#tls_1_3) but was available in go 1.12 through a GODEBUG setting.

Looks like kubernetes builds started to use go 1.13 from kubernetes 1.17 (from kubernetes/kubernetes@e3ff39f)

AWS still supports 1.16 but kubernetes itself doesn't.

If you're happy for me to make 1.3 the default I can make that change (it'll make this PR a lot simpler!)

@coderanger
Copy link
Contributor

I would want to make sure that's okay with OperatorSDK crew because they have to support older stuff than the rest of us (usually) but I think 1.2 as the default would definitely make sense no matter what, and maybe 1.3 if we can swing it. I think the overall structure of your change is good though, just playing with which is the default value.

@alvaroaleman
Copy link
Member

AWS still supports 1.16 but kubernetes itself doesn't.

It is afaik also still supported on GKE. Many ppl use one of the two so I don't think it is a good idea to default to tls 1.3 just yet.

s.tlsMinVersion = tls.VersionTLS12
case "1.3":
s.tlsMinVersion = tls.VersionTLS13
default:
Copy link
Member

Choose a reason for hiding this comment

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

IMHO we should error if TLSMinVersion is set but not in the list, silently picking an old version is not a good idea IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mind suggesting a mechanism for this (setDefaults doesn't currently have any error handling so I'm not sure what pattern to follow)

Copy link
Member

Choose a reason for hiding this comment

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

I would just move this into Start. The only thing that really qualifies as defaulting is to set it to tls.VersionTLS10 if s.TLSMinVersion is an empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for that suggestion - hopefully this iteration does what you're after.

@alvaroaleman
Copy link
Member

alvaroaleman commented Jun 7, 2021

Also nit, but I don't think this qualifies as a bugfix, a bug is IMHO something that was already built and supposed to work but didn't, since we never had support for configuring the TLS version this is IMHO a feature.

@willthames
Copy link
Contributor Author

@alvaroaleman the description for bug also says patch (although I guess any change is a patch), and there is an issue raised for this - that was my reasoning but I'm not against changing it to feature

@willthames willthames changed the title 🐛 Allow TLS minimum version to be configured ✨ Allow TLS minimum version to be configured Jun 8, 2021
@willthames
Copy link
Contributor Author

@alvaroaleman changed title to use ✨

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 9, 2021
@willthames
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 9, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, willthames

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 9, 2021
@alvaroaleman alvaroaleman added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jun 9, 2021
@k8s-ci-robot k8s-ci-robot merged commit fbf50b0 into kubernetes-sigs:master Jun 9, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.9.x milestone Jun 9, 2021
@alvaroaleman
Copy link
Member

thanks!

@coderanger
Copy link
Contributor

@alvaroaleman Is there a reason we didn't make 1.2 the default?

@alvaroaleman
Copy link
Member

@alvaroaleman Is there a reason we didn't make 1.2 the default?

Yeah, to not change what is currently happening, golang defaults to 1.0:

 // If zero, TLS 1.0 is currently taken as the minimum.

@coderanger
Copy link
Contributor

Sure but that seems like a bad default because kube-apiserver should support 1.2 in all cases? 1.3 was questionable but I don't think there's a reason to not pin up to 1.2 to block some funky MITM attacks?

@alvaroaleman
Copy link
Member

Sure but that seems like a bad default because kube-apiserver should support 1.2 in all cases? 1.3 was questionable but I don't think there's a reason to not pin up to 1.2 to block some funky MITM attacks?

So I am not opposed to changing the default, golang defaulting to 1.0 is quite terrible actually. It just happens to be a change that might cause issues (I don't know if it does) and this change right here seemed to me just about adding a knob.

@coderanger
Copy link
Contributor

Legit, I'll open a new PR to debate changing the default :)

alvaroaleman added a commit to alvaroaleman/controller-runtime that referenced this pull request Nov 9, 2022
This field has been added in kubernetes-sigs#1548
It then turned out that people want to configure more parts of the
TLSConfig and the generic TLSOpts was added in kubernetes-sigs#1897

Deprecate TLSMinVersion in favor of the more generic TLSOpts.
alvaroaleman added a commit to alvaroaleman/controller-runtime that referenced this pull request Nov 9, 2022
This field has been added in kubernetes-sigs#1548
It then turned out that people want to configure more parts of the
TLSConfig and the generic TLSOpts was added in kubernetes-sigs#1897

Deprecate TLSMinVersion in favor of the more generic TLSOpts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants