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

Create restrict-wildcard-apigroups #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions rbac-best-practices/restrict-wildcard-apigroups
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-wildcard-apigroups
annotations:
policies.kyverno.io/title: Restrict Wildcards in apiGroups
policies.kyverno.io/category: Security, EKS Best Practices
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: ClusterRole, Role, RBAC
kyverno.io/kyverno-version: 1.7.0
policies.kyverno.io/minversion: 1.6.0
kyverno.io/kubernetes-version: "1.23"
policies.kyverno.io/description: >-
Wildcards ('*') in apiGroups grants access to all of the apiGroups referenced and does not follow the principal of least privilege. As much as possible,
avoid such open resources unless scoped to perhaps a custom API group.
This policy blocks any Role or ClusterRole that contains a wildcard entry in the apiGroups list found in any rule.
spec:
validationFailureAction: audit
background: true
rules:
- name: wildcard-apigroups
match:
any:
- resources:
kinds:
- Role
- ClusterRole
validate:
message: "Use of a wildcard ('*') in any apiGroups is forbidden."
deny:
conditions:
any:
- key: "{{ contains(request.object.rules[].apiGroups[], '*') }}"
operator: Equals
value: true
Loading