From faf4ffe23150dc56a0e0294a7a57bc6e4d2deab7 Mon Sep 17 00:00:00 2001 From: Vinayak Goyal Date: Tue, 14 Jan 2025 01:45:44 +0000 Subject: [PATCH] KEP-5040: remove gitRepo volume driver. --- .../5040-remove-gitrepo-driver/README.md | 907 ++++++++++++++++++ .../5040-remove-gitrepo-driver/kep.yaml | 39 + 2 files changed, 946 insertions(+) create mode 100644 keps/sig-storage/5040-remove-gitrepo-driver/README.md create mode 100644 keps/sig-storage/5040-remove-gitrepo-driver/kep.yaml diff --git a/keps/sig-storage/5040-remove-gitrepo-driver/README.md b/keps/sig-storage/5040-remove-gitrepo-driver/README.md new file mode 100644 index 00000000000..cd1c2457aae --- /dev/null +++ b/keps/sig-storage/5040-remove-gitrepo-driver/README.md @@ -0,0 +1,907 @@ + +# KEP-5040: Remove gitRepo volume driver. + + + + + + +- [Release Signoff Checklist](#release-signoff-checklist) +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) +- [Proposal](#proposal) + - [User Stories (Optional)](#user-stories-optional) + - [Story 1](#story-1) + - [Story 2](#story-2) + - [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional) + - [Risks and Mitigations](#risks-and-mitigations) +- [Design Details](#design-details) + - [Test Plan](#test-plan) + - [Prerequisite testing updates](#prerequisite-testing-updates) + - [Unit tests](#unit-tests) + - [Integration tests](#integration-tests) + - [e2e tests](#e2e-tests) + - [Graduation Criteria](#graduation-criteria) + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) + - [Version Skew Strategy](#version-skew-strategy) +- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire) + - [Feature Enablement and Rollback](#feature-enablement-and-rollback) + - [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning) + - [Monitoring Requirements](#monitoring-requirements) + - [Dependencies](#dependencies) + - [Scalability](#scalability) + - [Troubleshooting](#troubleshooting) +- [Implementation History](#implementation-history) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Infrastructure Needed (Optional)](#infrastructure-needed-optional) + + +## Release Signoff Checklist + + + +Items marked with (R) are required *prior to targeting to a milestone / release*. + +- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR) +- [ ] (R) KEP approvers have approved the KEP status as `implementable` +- [ ] (R) Design details are appropriately documented +- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors) + - [ ] e2e Tests for all Beta API Operations (endpoints) + - [ ] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) + - [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free +- [ ] (R) Graduation criteria is in place + - [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md) +- [ ] (R) Production readiness review completed +- [ ] (R) Production readiness review approved +- [ ] "Implementation History" section is up-to-date for milestone +- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io] +- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes + + + +[kubernetes.io]: https://kubernetes.io/ +[kubernetes/enhancements]: https://git.k8s.io/enhancements +[kubernetes/kubernetes]: https://git.k8s.io/kubernetes +[kubernetes/website]: https://git.k8s.io/website + +## Summary + + + +The gitRepo volume driver allows users to make the files of a Git +repository(repo) available to a Pod. When a user specifies a gitRepo volume type +in a Pod; kubelet will clone the Git repo and checkout the revision specified. + +Since kubelet runs as root an attacker can configure a Git repo to execute +attacker control code on the host node as root. In [CVE-2024-10220](https://irsl.medium.com/sneaky-write-hook-git-clone-to-root-on-k8s-node-e38236205d54) +security researchers exploited gitRepo volumes and Git hooks to execute attacker +controlled code on the host node as root. + +gitRepo has been deprecated for almost 5 years and the kubernetes +[documentation](https://kubernetes.io/docs/concepts/storage/volumes/#gitrepo) +warns users against using it and provides a VAP policy to block its use. +Kubernetes also recommends mounting an emptyDir volume into an init container +that clones the repo using Git, then mounting the emptyDir into the Pod's main +container. The git-sync project (https://github.com/kubernetes/git-sync) is +designed for exactly this. + +In light of CVE-2024-10220 and the fact that this volume type has been +deprecated we think we should remove gitRepo volume support. + +## Motivation + + + +Since kubelet runs as root an attacker can configure a Git repo to execute +attacker control code on the host node as root. In [CVE-2024-10220](https://irsl.medium.com/sneaky-write-hook-git-clone-to-root-on-k8s-node-e38236205d54) +security researchers exploited gitRepo volumes and Git hooks to execute attacker +controlled code on the host node as root. + +gitRepo has been deprecated for almost 5 years and the kubernetes +[documentation](https://kubernetes.io/docs/concepts/storage/volumes/#gitrepo) +warns users against using it and provides a VAP policy to block its use. +Kubernetes also recommends mounting an emptyDir volume into an init container +that clones the repo using Git, then mounting the emptyDir into the Pod's main +container. The git-sync project (https://github.com/kubernetes/git-sync) is +designed for exactly this. + + +### Goals + + + +- Remove in-tree gitRepo volume support. + +### Non-Goals + + + +## Proposal + +Kubernetes drops support for gitRepo volume types by removing the in-tree driver +that actually mounts the volume in the pod. In this case we will still keep the +gitRepo volume in the API. This removal is similar to removal of support for +[glusterfs](https://kubernetes.io/docs/concepts/storage/volumes/#glusterfs) +which was deprecated in v1.25 and removed in v1.26. + +Sig-storage was actually very close to doing this and had even added a notice of +removal in the release notes for v1.32. But due to concerns raised by sig-arch +they rolled back the notice. sig-storage provided [this rationale](https://github.com/kubernetes/kubernetes/issues/125983#issuecomment-2522201283) for considering removal. + +### Risks and Mitigations + + + +## Design Details + + +We will add a new feature-gate called `DisableGitRepoVolumeDriver` which will be +defaulted to `false`. When this feature-gate is set to `true` kubelet will not +sync and mount gitRepo volumes and this will disable the [gitRepo driver](https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/git_repo/git_repo.go). + +### Timeline: +v1.33 (04/2025): +- We announce the removal in kubernetes release notes, documentation and via +kubernetes release blog post. +- We will add the `DisableGitRepoVolumeDriver` feature-gate to kubelet and +default it to `false`. + +v1.34 (08/2025): +- We will default `DisableGitRepoVolumeDriver` feature-gate to `true`. +- We will announce removal in kubernetes release notes, documentation and via +kubernetes release blog post. + +v1.35 (11/2025): lock gate +- We will remove the ability for users to modify the default value of the +feature-gate. +- We will announce removal in kubernetes release notes, documentation and via +kubernetes release blog post. + +v1.36 (04/2026): +- no change (for 3 version compat) +- We will announce removal in kubernetes release notes, documentation and via +kubernetes release blog post. + +v1.37 (08/2026): +- no change +- We will announce removal in kubernetes release notes, documentation and via +kubernetes release blog post. + +v1.38 (11/2026): +- We will announce removal in kubernetes release notes, documentation and via +kubernetes release blog post. +- We will remove the feature-gate +- We will remove the gitRepo driver code + + +### Test Plan + + + +[ ] I/we understand the owners of the involved components may require updates to +existing tests to make this code solid enough prior to committing the changes necessary +to implement this enhancement. + +##### Prerequisite testing updates + + + +##### Unit tests + + + + + +- ``: `` - `` + +##### Integration tests + + + + + +- : + +##### e2e tests + + + +- : + +### Graduation Criteria + + + +### Upgrade / Downgrade Strategy + + + +### Version Skew Strategy + + + +## Production Readiness Review Questionnaire + + + +### Feature Enablement and Rollback + + + +###### How can this feature be enabled / disabled in a live cluster? + + + +- [ ] Feature gate (also fill in values in `kep.yaml`) + - Feature gate name: + - Components depending on the feature gate: +- [ ] Other + - Describe the mechanism: + - Will enabling / disabling the feature require downtime of the control + plane? + - Will enabling / disabling the feature require downtime or reprovisioning + of a node? + +###### Does enabling the feature change any default behavior? + + + +###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)? + + + +###### What happens if we reenable the feature if it was previously rolled back? + +###### Are there any tests for feature enablement/disablement? + + + +### Rollout, Upgrade and Rollback Planning + + + +###### How can a rollout or rollback fail? Can it impact already running workloads? + + + +###### What specific metrics should inform a rollback? + + + +###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested? + + + +###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.? + + + +### Monitoring Requirements + + + +###### How can an operator determine if the feature is in use by workloads? + + + +###### How can someone using this feature know that it is working for their instance? + + + +- [ ] Events + - Event Reason: +- [ ] API .status + - Condition name: + - Other field: +- [ ] Other (treat as last resort) + - Details: + +###### What are the reasonable SLOs (Service Level Objectives) for the enhancement? + + + +###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service? + + + +- [ ] Metrics + - Metric name: + - [Optional] Aggregation method: + - Components exposing the metric: +- [ ] Other (treat as last resort) + - Details: + +###### Are there any missing metrics that would be useful to have to improve observability of this feature? + + + +### Dependencies + + + +###### Does this feature depend on any specific services running in the cluster? + + + +### Scalability + + + +###### Will enabling / using this feature result in any new API calls? + + + +###### Will enabling / using this feature result in introducing new API types? + + + +###### Will enabling / using this feature result in any new calls to the cloud provider? + + + +###### Will enabling / using this feature result in increasing size or count of the existing API objects? + + + +###### Will enabling / using this feature result in increasing time taken by any operations covered by existing SLIs/SLOs? + + + +###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components? + + + +###### Can enabling / using this feature result in resource exhaustion of some node resources (PIDs, sockets, inodes, etc.)? + + + +### Troubleshooting + + + +###### How does this feature react if the API server and/or etcd is unavailable? + +###### What are other known failure modes? + + + +###### What steps should be taken if SLOs are not being met to determine the problem? + +## Implementation History + + + +## Drawbacks + + + +## Alternatives + + + +### Alternative 1: Aggressively remove gitRepo driver +If we want to be aggressive, we could default to off in v1.33, citing the CVE. +If we want to be “safe”, we might wait 1 or 2 releases between v1.34 and +locking the gate. + +Pros: +- Secure by default. + +Cons: +- Not backward compatible. + +### Alternative 2: Add admission plugin that blocks gitRepo volumes +We add an in-tree admission plugin that, when enabled, will prevent Pods with +gitRepo volumes from being admitted. + +Pros: +- Backwards compatible. +- Allows cloud providers to make a call if they want to support gitRepo volumes or not. + +Cons: +- Not secure by default, requires cluster-admin action. +- The only escape valve is cluster-scoped. +- We'll be adding an in-tree admission plugin for a volume type that is not + maintained. + +### Alternative 3: Use ValidatingAdmissionPolicy +We publish a VAP which prevents Pods and other workloads from using gitRepo, and +strongly recommend cluster-admins (or cluster-providers) install it. + +Pros: +- Backwards compatible. +- Allows cluster-admins to make a call if they want to support gitRepo volumes or not. +- Can be scoped to namespaces rather than whole clusters. +- Works on older clusters. + +Cons: +- Not secure by default +- Requires cluster-admin action. + +### Alternative 4: Make Git hooks disableable +We add a new field to gitRepo volume called `enableHooks` to +configure if Git hooks should be run as part of gitRepo volume mounting. +When this value is set to true kubelet will execute Git hooks when performing +`git clone` and `git checkout`. If enableHooks is unset or set to false, kubelet +will not run any Git hooks when performing `git clone` and `git checkout`. + + +## Infrastructure Needed (Optional) + + diff --git a/keps/sig-storage/5040-remove-gitrepo-driver/kep.yaml b/keps/sig-storage/5040-remove-gitrepo-driver/kep.yaml new file mode 100644 index 00000000000..52a02b8526b --- /dev/null +++ b/keps/sig-storage/5040-remove-gitrepo-driver/kep.yaml @@ -0,0 +1,39 @@ +title: Disable hooks for gitRepo volumes by default. +kep-number: 5040 +authors: + - "@vinayakankugoyal" +owning-sig: sig-storage +participating-sigs: +status: provisional +creation-date: 2024-12-14 +reviewers: + - TBD +approvers: + - TBD + +see-also: + +replaces: + +# The target maturity stage in the current dev cycle for this KEP. +stage: alpha + +# The most recent milestone for which work toward delivery of this KEP has been +# done. This can be the current (upcoming) milestone, if it is being actively +# worked on. +latest-milestone: "v1.33" + +# The milestone at which this feature was, or is targeted to be, at each stage. +milestone: + alpha: "v1.33" + +# The following PRR answers are required at alpha release +# List the feature gate name and the components for which it must be enabled +feature-gates: + - name: DisableGitRepoVolumeDriver + components: + - kubelet +disable-supported: true + +# The following PRR answers are required at beta release +metrics: