forked from PaloAltoNetworks/rbac-police
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbind_roles.rego
26 lines (23 loc) · 841 Bytes
/
bind_roles.rego
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package policy
import data.police_builtins as pb
import future.keywords.in
describe[{"desc": desc, "severity": severity}] {
desc := sprintf("Identities that can bind clusterrolebindings or bind rolebindings in privileged namespaces (%v) can grant admin-equivalent permissions to themselves", [concat(", ", pb.privileged_namespaces)])
severity := "Critical"
}
targets := {"serviceAccounts", "nodes", "users", "groups"}
evaluateRoles(roles, owner) {
some role in roles
pb.affectsPrivNS(role)
some rule in role.rules
rolebindingsOrClusterrolebindings(rule.resources)
pb.valueOrWildcard(rule.verbs, "bind")
pb.valueOrWildcard(rule.apiGroups, "rbac.authorization.k8s.io")
}
rolebindingsOrClusterrolebindings(resources) {
"clusterrolebindings" in resources
} {
"rolebindings" in resources
} {
pb.hasWildcard(resources)
}