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 limiting adding/removing finalizers #59591

Open
liggitt opened this issue Feb 8, 2018 · 17 comments
Open

Allow limiting adding/removing finalizers #59591

liggitt opened this issue Feb 8, 2018 · 17 comments
Assignees
Labels
area/apiserver area/security kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth.

Comments

@liggitt
Copy link
Member

liggitt commented Feb 8, 2018

/kind feature
@kubernetes/sig-auth-feature-requests
@kubernetes/sig-api-machinery-feature-requests

What happened:

As a namespace-constrained user, I am able to manually add/remove finalizers added by system components:

  • garbage collection finalizers
  • pv/pvc protection finalizers
  • service catalog deprovisioning finalizers
  • etc...

What you expected to happen:

As a cluster admin, I expected to be able to control what finalizers can be added/removed by end users, so they can be relied on by system components and controllers for gating deletion

@liggitt liggitt added area/security area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. kind/feature Categorizes issue or PR as related to a new feature. sig/auth Categorizes an issue or PR as relevant to SIG Auth. labels Feb 8, 2018
@mikedanese
Copy link
Member

@ihmccreery

@hzxuzhonghu
Copy link
Member

/cc

@ikehz
Copy link
Contributor

ikehz commented Feb 9, 2018

+1

I've noticed this deficiency as well. More specifics:

The finalize command as it exists today takes a complete namespace object and, as far as I can tell, removes any finalizers from the API object that don't appear in the request object.

This makes fine-grained authorization impossible, which is especially important for namespace-constrained users. I want to write an authorization rules like: "only service account Y can modify finalizer X (on all namespaces)" (it might also be nice to specify "user Z can modify all finalizers on their namespace except X or W" but that seems like a nice-to-have for which I'm not sure there are many use cases).

Additionally to the multi-tenancy concerns above, bugs are just easy to write and hard to protect against right now. If I write a namespace controller that accidentally deletes all finalizers, instead of just the one I intend to modify, that's a large blast radius.

My first pass at this would be to define finalizers as first-class subresources on a namespace?

Xref https://github.com/kubernetes/community/blob/master/contributors/design-proposals/architecture/namespaces.md#finalizers.

@ikehz
Copy link
Contributor

ikehz commented Feb 9, 2018

I think we could do this in a backward-compatible way, even, by making the current finalize call an alias for the subresource-based, correctly authorized call, where the apiserver computes what finalizers are being deleted and delegates to the subresource endpoint.

@liggitt liggitt changed the title Add ability to limit ability to add/remove finalizers Allow limiting adding/removing finalizers Feb 9, 2018
@mbohlool
Copy link
Contributor

/cc @jennybuckley

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 16, 2018
@mikedanese mikedanese removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 17, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 15, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 14, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

@liggitt liggitt reopened this Dec 2, 2018
@liggitt liggitt added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Dec 2, 2018
@smarterclayton
Copy link
Contributor

I’d like to escalate this. Abuse of finalizer deletion is widespread, and people are doing terrible things because we aren’t adequately communicating the risks of these.

In particular the PVC finalizer abuse has reached new heights - on that one there are other things to investigate (like whether the controller is giving feedback to users appropriately).

I’d like to (as part of this) make sure finalizer owners are living up to their responsibility to explain to humans why they aren’t allowing a deletion.

@smarterclayton
Copy link
Contributor

I’d be happy with an admission control check.

Also we should note an explicit difference between namespace deletion and other types of finalizers.

@zhouhaibing089
Copy link
Contributor

We've been thinking about this, too. Besides finalizers, we also want to take care of annotations and init containers(where those annotations and init containers are added by third-party systems).

Basically, we are trying to setup new RBAC clusterroles for finalizers, and checking authorization during admission(just like PodSecurityPolicy checks the use permission on podsecuritypolicies).

@zhouhaibing089
Copy link
Contributor

Does this require a KEP? I am interested to work on this.

@lavalamp
Copy link
Member

lavalamp commented Apr 3, 2019

If you want to change core kubernetes for this, then yes, it needs a KEP.

If you want to write a general admission controller that solves the problem, I don't think you need a KEP. I'm not 100% sure off the top of my head that we pass enough information about the user to the webhook admission controllers; so you may end up asking for more features there.

@zhouhaibing089
Copy link
Contributor

zhouhaibing089 commented Apr 4, 2019

I think a general admission + RBAC should suffice:

Briefly, we can define a new verb finalize, cluster administrators can create proper RBAC rules for it, for example, we can give GC controller permissions to remove finalizers orphan:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: orphan-finalizer
rules:
- apiGroups:
  - "*"
  resources:
  - "*"
  resourceNames:
  - "orphan"
  verbs:
  - "finalize"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: orphan-finalizer
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: orphan-finalizer
subjects:
- kind: ServiceAccount
  name: generic-garbage-collector
  namespace: kube-system

During admission time, we get the user info, and figure out:

  1. All the new added finalizers.
  2. Finalizers which are removed.

We send a call to authorizer to check whether that user can do the finalization of the finalizer.

Can I get some feedback here?

@zhouhaibing089
Copy link
Contributor

Proposing this: #76213.

cc @liggitt @lavalamp

@tallclair tallclair added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Jun 12, 2019
@enj enj added this to Backlog in SIG Auth Old Apr 9, 2021
@liggitt liggitt removed their assignment May 20, 2021
@ritazh ritazh moved this from Needs Triage to Needs KEP in SIG Auth Old Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver area/security kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth.
Projects
Status: Needs KEP
SIG Auth Old
Needs KEP
Development

No branches or pull requests