Skip to content

Commit

Permalink
Create restrict-add-other-users-to-rolebinding
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhav888 authored Sep 6, 2024
1 parent b502913 commit c86e288
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions rbac-best-practices/restrict-add-other-users-to-rolebinding
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-add-other-users-to-rolebinding
annotations:
policies.kyverno.io/title: Restrict Users from Adding other User to their Rolebinding
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: >-
Restrict users from adding other users to their rolebindings.
spec:
validationFailureAction: audit
rules:
- name: restrict-add-rolebinding
match:
any:
- resources:
kinds:
- Role
validate:
deny:
conditions:
all:
- key: "{{ request.object.rules[].resources[] }}"
operator: AnyIn
value: rolebindings
- key: "{{ request.object.rules[].verbs[] }}"
operator: AnyIn
value:
- get
- patch
- key: "{{ contains(request.object.rules[].apiGroups[], '*') }}"
operator: Equals
value: true

0 comments on commit c86e288

Please sign in to comment.