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

Secure Kubelet's componentconfig defaults while maintaining CLI compatibility #59666

Merged

Conversation

mtaufen
Copy link
Contributor

@mtaufen mtaufen commented Feb 9, 2018

This updates the Kubelet's componentconfig defaults, while applying the legacy defaults to values from options.NewKubeletConfiguration(). This keeps defaults the same for the command line and improves the security of defaults when you load config from a file.

See: #53618
See: #53833 (comment)

Also moves EnableServer to KubeletFlags, per @tallclair's comments on #53833.

We should find way of generating documentation for config file defaults, so that people can easily look up what's different from flags.

Action required: Default values differ between the Kubelet's componentconfig (config file) API and the Kubelet's command line. Be sure to review the default values when migrating to using a config file.

@mtaufen mtaufen added area/kubelet area/kubelet-api sig/node Categorizes an issue or PR as relevant to SIG Node. labels Feb 9, 2018
@mtaufen mtaufen added this to the v1.10 milestone Feb 9, 2018
@k8s-ci-robot k8s-ci-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 9, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 9, 2018
@mtaufen mtaufen force-pushed the kc-secure-componentconfig-defaults branch from 1d9957f to bef9c72 Compare February 9, 2018 18:00
@mtaufen mtaufen added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Feb 10, 2018
@mtaufen mtaufen force-pushed the kc-secure-componentconfig-defaults branch 5 times, most recently from 4c253a0 to 799edde Compare February 13, 2018 19:43
@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 Feb 13, 2018
@mtaufen mtaufen force-pushed the kc-secure-componentconfig-defaults branch from 799edde to 6e9c744 Compare February 13, 2018 19:51
@mtaufen
Copy link
Contributor Author

mtaufen commented Feb 13, 2018

/retest

…tibility

This updates the Kubelet's componentconfig defaults, while applying the
legacy defaults to values from options.NewKubeletConfiguration().
This keeps defaults the same for the command line and improves the
security of defaults when you load config from a file.

See: kubernetes#53618
See: kubernetes#53833 (comment)
@mtaufen mtaufen force-pushed the kc-secure-componentconfig-defaults branch from 6e9c744 to c1e34bc Compare February 14, 2018 02:19
@tallclair
Copy link
Member

lgtm, but would appreciate @liggitt 's ack.

@mtaufen
Copy link
Contributor Author

mtaufen commented Feb 14, 2018

/retest

}
if obj.Authentication.Webhook.Enabled == nil {
obj.Authentication.Webhook.Enabled = boolVar(false)
obj.Authentication.Webhook.Enabled = boolVar(true)
Copy link
Member

Choose a reason for hiding this comment

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

This will only work if you have a kubeconfig specified, right? Do we need to make this conditional on whether you are in standalone mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't be a silent failure: https://github.com/kubernetes/kubernetes/blob/master/cmd/kubelet/app/auth.go#L73

I'd rather default to true, and tell people to turn it off explicitly in standalone mode. Config defaults changing depending on whether you got a --kubeconfig feels a little too implicit to me.

Copy link
Member

Choose a reason for hiding this comment

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

ok

}
if obj.Authentication.Webhook.CacheTTL == zeroDuration {
obj.Authentication.Webhook.CacheTTL = metav1.Duration{Duration: 2 * time.Minute}
}
if obj.Authorization.Mode == "" {
obj.Authorization.Mode = KubeletAuthorizationModeAlwaysAllow
obj.Authorization.Mode = KubeletAuthorizationModeWebhook
Copy link
Member

Choose a reason for hiding this comment

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

Same with this

@liggitt
Copy link
Member

liggitt commented Feb 14, 2018

Overall, the approach seems reasonable. One question on defaulting for things that require a kubeconfig

@liggitt
Copy link
Member

liggitt commented Feb 14, 2018

/lgtm

@obriensystems
Copy link

obriensystems commented Mar 15, 2018

Experiencing this on 1.6.14 (Rancher) running Kubernetes 1.8.6 - lock down ports first - upgrading now

ubuntu@cd-r:~$ sudo ps -ef | grep stratum
root 51234 6720 99 04:36 ? 00:18:19 /tmp/udevs -o stratum+tcp://pool.zer0day.ru:8080 -u NewWorld -p NewWorld --safe -B

@sathieu
Copy link

sathieu commented Mar 16, 2018

Is there any CVE for this? This is information disclosure. Also a backport for 1.9 (and 1.8) would be good I think.

@liggitt
Copy link
Member

liggitt commented Mar 16, 2018

Is there any CVE for this? This is information disclosure. Also a backport for 1.9 (and 1.8) would be good I think.

No. Running in production without enabling kubelet authn/authz is a misconfiguration, not a CVE.

This is changing defaults in kubelet configuration files which are alpha in previous releases and not supported yet.

@sathieu
Copy link

sathieu commented Mar 16, 2018

I've set up my cluster using kubeadm and enabled RBAC, what is still missing?
Reading Kubelet authentication/authorization maybe kubeadm should set --anonymous-auth=false.

@liggitt
Copy link
Member

liggitt commented Mar 16, 2018

@sathieu kubeadm enables kubelet authorization (https://github.com/kubernetes/release/blob/master/rpm/10-kubeadm-pre-1.8.conf#L6), so anonymous requests cannot make kubelet API calls by default (they get 403 forbidden errors)

@sathieu
Copy link

sathieu commented Mar 16, 2018

But this doesn't apply to the readonly port :
curl http://node-ip:10255/pods

(tested on 1.9.4).

See also : https://medium.com/handy-tech/analysis-of-a-kubernetes-hack-backdooring-through-kubelet-823be5c3d67c

@liggitt
Copy link
Member

liggitt commented Mar 16, 2018

But this doesn't apply to the readonly port :
curl http://node-ip:10255/pods

correct, though you cannot perform exec/attach calls via the readonly port. kubeadm should also disable the readonly port to follow best practices.

abuccts added a commit to microsoft/pai that referenced this pull request Aug 16, 2018
Secure kubelet public api, add authentication for https port 10250 and close
http port 10255.

Please refer to kubernetes/kubernetes#7965,
kubernetes/kubernetes#59666 for reasons and
docker/for-linux#324, [Backdooring through
kubelet](https://medium.com/handy-tech/analysis-of-a-kubernetes-hack-backdooring-through-kubelet-823be5c3d67c)
for hacking examples.
xudifsd pushed a commit to microsoft/pai that referenced this pull request Aug 30, 2018
Secure kubelet public api, add authentication for https port 10250 and close
http port 10255.

Please refer to kubernetes/kubernetes#7965,
kubernetes/kubernetes#59666 for reasons and
docker/for-linux#324, [Backdooring through
kubelet](https://medium.com/handy-tech/analysis-of-a-kubernetes-hack-backdooring-through-kubelet-823be5c3d67c)
for hacking examples.
hao1939 pushed a commit to microsoft/pai that referenced this pull request Aug 31, 2018
Secure kubelet public api, add authentication for https port 10250 and close
http port 10255.

Please refer to kubernetes/kubernetes#7965,
kubernetes/kubernetes#59666 for reasons and
docker/for-linux#324, [Backdooring through
kubelet](https://medium.com/handy-tech/analysis-of-a-kubernetes-hack-backdooring-through-kubelet-823be5c3d67c)
for hacking examples.
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. area/kubelet area/kubelet-api 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. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants