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

TLS server configuration hardening #2850

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Mar 6, 2023

Description

Enforce TLS minimum versions and a fixed list of allowed TLS ciphers for all the TLS secured endpoints managed by k0s. This has already been the case for the API server, the kubelet and the konnectivity server. Unify the approach to also include etcd and the k0s API itself.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@twz123 twz123 requested a review from a team as a code owner March 6, 2023 10:42
@twz123 twz123 requested review from kke and jnummelin March 6, 2023 10:42
Comment on lines +240 to +244
cipherSuites := make([]string, len(constant.AllowedTLS12CipherSuiteIDs))
for i, cipherSuite := range constant.AllowedTLS12CipherSuiteIDs {
cipherSuites[i] = tls.CipherSuiteName(cipherSuite)
}

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could be a helper func in the constant package as it is used in couple different places now

Copy link
Member Author

@twz123 twz123 Mar 6, 2023

Choose a reason for hiding this comment

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

It's used in two places, one being deprecated. That's why I didn't do it. Technically, the changes in this file aren't necessary at all, since it only exists for backwards compatibility when upgrading from k0s 1.25.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just realizing: This is required for the <=1.25 backports.

"--log-level": e.LogLevel,
"--peer-client-cert-auth": "true",
"--enable-pprof": "false",
// "--tls-min-version": "TLS1.2", // https://github.com/etcd-io/etcd/pull/15156
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover

Copy link
Member Author

@twz123 twz123 Mar 6, 2023

Choose a reason for hiding this comment

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

I've put it here as a reminder for the future, when etcd actually supports --tls-min-version. This is not yet available as of etcd v3.5.7, but already merged to main. I can remove it if you prefer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a text comment with clarification for the reason, if you want, but now it looks like leftover and would be accidentally removed on the first edit of this file by somebody who doesn't have a context.

How I read this line now:

  • there was an argument tls-min-version
  • the given value was TLS1.2
  • the reason to have this value is explained in the Add TLSv1.3 support. etcd-io/etcd#15156
  • somebody commented the whole thing out due to some reason

Sorry for nitpicking here, but I always afraid of out-dated or misguiding comments, because they always make reading code harder :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough. Will make the doc string clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Enforce TLS minimum versions and a fixed list of allowed TLS ciphers for
all the TLS secured endpoints managed by k0s. This has already been the
case for the API server, the kubelet and the konnectivity server. Unify
the approach to also include etcd and the k0s API itself.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
@twz123 twz123 added security fix area/controlplane backport/release-1.26 PR that needs to be backported/cherrypicked to release-1.26 branch labels Mar 6, 2023
@twz123 twz123 merged commit bbad20c into k0sproject:main Mar 6, 2023
@twz123 twz123 deleted the enforce-tls branch March 6, 2023 13:40
@k0s-bot
Copy link

k0s-bot commented Mar 6, 2023

Backport failed for release-1.26, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin release-1.26
git worktree add -d .worktree/backport-2850-to-release-1.26 origin/release-1.26
cd .worktree/backport-2850-to-release-1.26
git checkout -b backport-2850-to-release-1.26
ancref=$(git merge-base c08e7b57fbd7b668ed6df1b6eba27ed8d697aa42 55f75fd533a8fc747205c42c226d580b927eb4fc)
git cherry-pick -x $ancref..55f75fd533a8fc747205c42c226d580b927eb4fc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/controlplane backport/release-1.26 PR that needs to be backported/cherrypicked to release-1.26 branch security fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants