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

NDEV-20544: add remediate policies for RBAC best practices #169

Merged

Conversation

Chandan-DK
Copy link
Contributor

@Chandan-DK Chandan-DK commented Sep 26, 2024

Description:

This PR adds remediation policies for the following RBAC best practices policies:

  • restrict-automount-sa-token
  • restrict-clusterrole-nodesproxy
  • restrict-wildcard-resources

In remediate-restrict-clusterrole-nodesproxy policy, we are replacing nodes/proxy with "" instead of removing it.
Consider we have a ClusterRole like this where the resources array contains a single element nodes/proxy

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: badcr03
rules:
- apiGroups: [""]
  resources: ["nodes/proxy"]
  verbs: ["get", "watch", "list"]

When we apply the remediate policy on this, it gets mutated to:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: badcr03
rules:
- apiGroups: [""]
  resources: [""]
  verbs: ["get", "watch", "list"]

If we had performed a remove operation on nodes/proxy, then creation of the ClusterRole would have been blocked by Kubernetes with the following error:

The ClusterRole "badcr03" is invalid: rules[0].resources: Required value: resource rules must supply at least one resource

An empty string "" does not match any resources and can be considered a dummy value.

The above approach of replacing instead of removing has been followed in remediate-restrict-wildcard-resources policy too

Related Issues:

Checklist:

  • This PR requires a bump in kyverno-policies chart version .
  • I have created a PR to bump the enterprise-kyverno-operator chart version.

@anusha94 anusha94 merged commit 9a85362 into nirmata:main Sep 29, 2024
19 checks passed
@Chandan-DK Chandan-DK deleted the remediate-policies-for-rbac-best-practices branch September 29, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants