Description
In Kubernetes RBAC, list and watch on secrets can return Secret values just as get can. A Role or ClusterRole grants these permissions to users, groups or ServiceAccounts through a binding.
Potential impact
An exposed password, token, certificate or key can affect other systems that trust that credential.
Remediation
Remove unnecessary Secret-read verbs and wildcards. For required access, limit the identities and namespaces, then review RoleBindings and ClusterRoleBindings to verify effective permissions.
Examples
Both excerpts define rules for the terraform-example Role. A separate binding determines who receives them.
Before
hcl
resource "kubernetes_role" "role" {
metadata {
name = "terraform-example"
}
rule {
api_groups = [""]
resources = ["secrets"]
verbs = ["get", "list", "watch"]
}
}
After
hcl
resource "kubernetes_role" "role" {
metadata {
name = "terraform-example"
}
rule {
api_groups = [""]
resources = ["pods"]
verbs = ["get", "list", "watch"]
}
}
Explanation:
- Before: All three verbs apply to
secrets. - After: The same verbs now apply to
pods. Keep this rule only if Pod access is needed.