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

Add OwnerReferencesPermissionEnforcement #1244

Closed
wants to merge 1 commit into from
Closed

Conversation

oshoval
Copy link
Contributor

@oshoval oshoval commented Aug 11, 2024

What this PR does / why we need it:
It will allow to detect RBAC errors that are enabled by default on OpenShift
but not by default on vanilla k8s clusters.
https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#ownerreferencespermissionenforcement

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note:


@kubevirt-bot kubevirt-bot added the dco-signoff: yes Indicates the PR's author has DCO signed all their commits. label Aug 11, 2024
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign awels for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@oshoval
Copy link
Contributor Author

oshoval commented Aug 11, 2024

/hold
need to do the same for all the other providers

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 11, 2024
@oshoval
Copy link
Contributor Author

oshoval commented Aug 11, 2024

/cc @brianmcarey @EdDev

Hi, are you interesting in this ?
it can find issues on k8s based provider before we test them on OpenShift
if so we need to apply it for all k8s versions on kubevirtci
Example of a bug kubevirt/ipam-extensions#54 (well this is on other provider, but just the example, that also can happen on kubevirtci vm based providers before this PR, had it on CNAO one time)

@EdDev
Copy link
Member

EdDev commented Aug 11, 2024

/cc @brianmcarey @EdDev

Hi, are you interesting in this ? it can find issues on k8s based provider before we test them on OpenShift if so we need to apply it for all k8s versions on kubevirtci Example of a bug kubevirt/ipam-extensions#54 (well this is on other provider, but just the example, that also can happen on kubevirtci vm based providers before this PR, had it on CNAO one time)

Kubevirt is an U/S project and the reasoning to add something like this should be focused on the usefulness it has for it (and not for a D/S project). D/S projects have their own tests and rules.

If this validation improves Kubevirt security and stability, please reason for the exact benefits this validation has and how it helps the project, regardless of any D/S potential usage of it.

@oshoval
Copy link
Contributor Author

oshoval commented Aug 11, 2024

/cc @brianmcarey @EdDev
Hi, are you interesting in this ? it can find issues on k8s based provider before we test them on OpenShift if so we need to apply it for all k8s versions on kubevirtci Example of a bug kubevirt/ipam-extensions#54 (well this is on other provider, but just the example, that also can happen on kubevirtci vm based providers before this PR, had it on CNAO one time)

Kubevirt is an U/S project and the reasoning to add something like this should be focused on the usefulness it has for it (and not for a D/S project). D/S projects have their own tests and rules.

If this validation improves Kubevirt security and stability, please reason for the exact benefits this validation has and how it helps the project, regardless of any D/S potential usage of it.

Well it helps us on upstream to stricly validate RBACs
for example it will enforce that setting BlockOwnerDeletion on an object, requires having update verb on the Owner /finalizers
This kind of requirement is set by default on OpenShift but not on k8s vanilla clusters, so it will be detectable only if one run Openshift (the tests at the end do run on OpenShift), or if someone enable this feature that this PR suggests.

All info in this short paragraph
https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#ownerreferencespermissionenforcement

"This admission controller protects the access to the metadata.ownerReferences of an object so that only users with delete permission to the object can change it. This admission controller also protects the access to metadata.ownerReferences[x].blockOwnerDeletion of an object, so that only users with update permission to the finalizers subresource of the referenced owner can change it."

For me it could save time at the past when i developed CNAO rbacs optimization, and today a chance like this but oin kind saved me time to simulate an error that was found only on OpenShift, locally on kind.

@oshoval
Copy link
Contributor Author

oshoval commented Aug 11, 2024

/test check-provision-k8s-1.28

@EdDev
Copy link
Member

EdDev commented Aug 11, 2024

Well it helps us on upstream to stricly validate RBACs

For me it could save time at the past when i developed CNAO rbacs optimization, and today a chance like this but oin kind saved me time to simulate an error that was found only on OpenShift, locally on kind.

I tried to explain that you cannot reason such a change by naming a D/S project.

Please add to the PR and a short summary in the commit message why this change is beneficial to Kubevirt, how it helps it and what is gained.
You also need to explain and mention that it does not cause any problem with users that run the cluster without it.

Please add all the needed reasoning and convincing in the PR description and drop the mentioning of the D/S project. After you provide the convincing details, you could mention that some K8S distributions are using it by default (but to be clear, that is not the main reason that should be provided).

@oshoval
Copy link
Contributor Author

oshoval commented Aug 11, 2024

Well it helps us on upstream to stricly validate RBACs
For me it could save time at the past when i developed CNAO rbacs optimization, and today a chance like this but oin kind saved me time to simulate an error that was found only on OpenShift, locally on kind.

I tried to explain that you cannot reason such a change by naming a D/S project.

Please add to the PR and a short summary in the commit message why this change is beneficial to Kubevirt, how it helps it and what is gained. You also need to explain and mention that it does not cause any problem with users that run the cluster without it.

Please add all the needed reasoning and convincing in the PR description and drop the mentioning of the D/S project. After you provide the convincing details, you could mention that some K8S distributions are using it by default (but to be clear, that is not the main reason that should be provided).

Ok thanks, closing now, will get to it in the future (need to finish few things)
(just waiting for check-provision-k8s-1.28 to finish first)

@oshoval
Copy link
Contributor Author

oshoval commented Aug 12, 2024

before more changes, @brianmcarey wdyt about this change ?

@brianmcarey
Copy link
Member

before more changes, @brianmcarey wdyt about this change ?

I would need a reason why this would be needed or useful to kubevirt as @EdDev mentioned.

@oshoval
Copy link
Contributor Author

oshoval commented Aug 12, 2024

before more changes, @brianmcarey wdyt about this change ?

I would need a reason why this would be needed or useful to kubevirt as @EdDev mentioned.

Reasoning, and taking CNAO as example (but can also happen on kubevirt)
is that this way we are stricter on RBACs, which are already stricter on other K8S distributions)
so it makes us more robust

Given this info, would you / Edy want this going forward ?
I can just close it otherwise
Thanks

@oshoval
Copy link
Contributor Author

oshoval commented Aug 12, 2024

Closing this now, i think it is totally fine to have a robust provider which is bit stricter as some k8s distributions are,
Will go back to this once there is more time and will address the comments (just prefer to close PRs instead having them dangling atm)
Thanks for the review

@oshoval oshoval closed this Aug 12, 2024
@oshoval
Copy link
Contributor Author

oshoval commented Aug 18, 2024

Btw a generic solution can be to allow enabling additional admission-plugins via env vars
such as
KUBEVIRT_ADMISSION_PLUGINS=OwnerReferencesPermissionEnforcement (comma separated values list)
and / or even something more generic, allow overriding the kubeadm.conf file itself which can help while developing new providers or new features
anyhow we can start with the current approach of course,
wdyt?

@oshoval oshoval reopened this Aug 18, 2024
@oshoval oshoval marked this pull request as draft August 18, 2024 11:10
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 18, 2024
@oshoval
Copy link
Contributor Author

oshoval commented Aug 18, 2024

/hold cancel

drafing

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 18, 2024
Signed-off-by: Or Shoval <oshoval@redhat.com>
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 28, 2024
@kubevirt-bot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

@oshoval
Copy link
Contributor Author

oshoval commented Sep 3, 2024

Since kubevirtci code bash was changed bigly this PR is not relevant anymore in the current state of it
in case i will have time in the future and see this is important i will be back for it

@oshoval oshoval closed this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants