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 rule S6867: Wildcards should not be used to define RBAC permissions #3511

Merged
merged 7 commits into from
Dec 19, 2023
Merged
29 changes: 29 additions & 0 deletions rules/S6867/kubernetes/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"title": "Do not use wildcards when defining RBAC permissions",
"type": "VULNERABILITY",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6867",
"sqKey": "S6864",
"scope": "All",
"securityStandards": {
"CWE": [
284
]
},
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "unknown",
"code": {
"impacts": {
"MAINTAINABILITY": "MEDIUM",
"SECURITY": "MEDIUM"
},
"attribute": "COMPLETE"
}
}
91 changes: 91 additions & 0 deletions rules/S6867/kubernetes/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Do not use wildcards when defining RBAC permissions

// If you want to factorize the description uncomment the following line and create the file.
//include::../description.adoc[]

== Why is this an issue?

Using wildcards when defining Role-Based Access Control (RBAC) permissions in Kubernetes can lead to significant security issues. This is because it grants overly broad permissions, potentially allowing access to sensitive resources.


RBAC is designed to limit the access rights of users within the system by assigning roles to them. These roles define what actions a user can perform and on which resources. When a wildcard is used, it means that the role has access to all resources/verbs, bypassing the principle of least privilege. This principle states that a user should have only the minimal permissions they need to perform their job function.


=== What is the potential impact?

If an attacker gains access to a role with wildcard permissions, they could potentially read, modify, or delete any resource in the Kubernetes cluster, leading to data breaches, service disruptions, or other malicious activities.

== How to fix it
//== How to fix it in FRAMEWORK NAME

=== Code examples

==== Noncompliant code example

[source,text,diff-id=1,diff-type=noncompliant]
----
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: example-role
rules:
- apiGroups: [""]
resources: ["*"] # Noncompliant
verbs: ["get", "list"]
----

==== Compliant solution

[source,text,diff-id=1,diff-type=compliant]
----
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: example-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]
----

//=== How does this work?

//=== Pitfalls

//=== Going the extra mile


== Resources
=== Documentation

* Kubernetes Documentation - https://kubernetes.io/docs/reference/access-authn-authz/rbac/[Using RBAC Authorization]


//=== Articles & blog posts
//=== Conference presentations
=== Standards

* https://owasp.org/Top10/A01_2021-Broken_Access_Control/[OWASP Top 10 2021 Category A1] - Broken Access Control
* https://cwe.mitre.org/data/definitions/284[MITRE, CWE-284] - Improper Access Control
* https://owasp.org/www-project-top-ten/2017/A5_2017-Broken_Access_Control[OWASP Top 10 2017 Category A5] - Broken Access Control

//=== External coding guidelines
//=== Benchmarks

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Do not use wildcards when defining RBAC permissions


=== Highlighting

* Highlight the property that was set using a wildcart.
endif::env-github,rspecator-view[]
2 changes: 2 additions & 0 deletions rules/S6867/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Loading