Skip to main content

More Info:

Roles that grant get, list, or watch on secrets expose sensitive credentials. Access to secrets should be limited to the workloads that genuinely need it.

Risk Level

High

Address

Security

Compliance Standards

  • CIS AKS

Triage and Remediation

Remediation

Manual Steps

  1. List all Roles that can access Secrets
    • Run on: any machine with kubectl access
    This shows all Roles that reference the secrets resource in any rule.
  2. Review exactly which secret permissions each Role has
    • Run on: any machine with kubectl access
      For each <namespace> <role-name> pair from step 1, inspect in detail:
    Manually check .rules for:
    • resources: ["secrets"] or including secrets
    • verbs containing any of get, list, watch (or *)
  3. Determine if each Role’s secret access is justified
    • For each Role from step 2, identify which subjects actually use it:
    • For each ServiceAccount / user / group listed:
      • Identify the workloads (Pods/Deployments/Jobs, etc.) using that ServiceAccount.
      • Decide whether those workloads truly need to read Kubernetes Secrets (for example, they use envFrom: secretRef: or secret volumes, or perform runtime secret reads via the API).
  4. Adjust Roles to least privilege where secret access is not required
    • Run on: any machine with kubectl access
      For a Role whose subjects do not need to read Secrets, remove secrets (or *) from its rules, or remove get/list/watch on secrets:
    In the editor, update .rules so either:
    • resources no longer includes secrets, or
    • verbs no longer includes get, list, or watch for secrets.
  5. Create replacement least-privileged Roles where needed
    If a Role is shared and some subjects still require secret access while others do not:
    • Create a new Role without secrets access:
    • Rebind the subjects that should not have secret access to the new Role:
      In .roleRef.name, change the Role to <new-role-name> for the appropriate subjects, or split RoleBindings so that only the intended subjects keep the original Role with secret access.
  6. Verify that Roles with secret access are now minimal and intentional
    • Re-run the discovery query:
    • For the remaining Roles listed, repeat step 2 quickly to confirm that:
      • Only workloads that genuinely need secret read access are bound.
      • verbs for secrets are limited to what is strictly necessary, typically only get (and rarely list/watch).
In /tmp/all-roles.yaml, look for rules entries where:
Indications of a problem (these need human judgment against your workload requirements):
  • resources includes secrets (or ["*"]) in combination with:
    • overly broad verbs, such as ["get", "list", "watch"], ["*"], or many verbs where only get might be needed, or none at all.
    • overly broad resourceNames (omitted or ["*"]), granting access to all secrets in the namespace instead of specific ones.
    • use in generic/system-wide Roles rather than workload-specific Roles tied to a narrow ServiceAccount.
Examples that warrant review:
To focus on one suspicious Role you find in the YAML, use:
Use these outputs to decide, per Role, whether:
  • it truly needs any access to secrets at all, and
  • if so, whether you can scope it down (fewer verbs, specific resourceNames, or moving access into a more targeted Role).
Explanation of output indicating a problem:
  • Any line listed under either:
    • ### Roles with secret access (namespaced) ###, or
    • ### ClusterRoles with secret access (cluster-wide) ### shows a Role/ClusterRole that grants get, list, watch, or * on the secrets resource.
  • These entries must be manually reviewed to determine whether each subject truly requires that level of access; where not required, use kubectl edit role / kubectl edit clusterrole or manifest updates to remove or narrow these permissions.