Skip to main content

More Info:

Broad get, list and watch access to secret objects allows credentials to be exfiltrated. Restrict these permissions to only the workloads and users that require them.

Risk Level

High

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. List all ClusterRoles with secret access
    • Run on: any machine with kubectl access
    • Command:
    • This identifies ClusterRoles that can get, list, or watch secrets.
  2. Inspect each flagged ClusterRole’s secret permissions in detail
    • Run on: any machine with kubectl access
    • For each ClusterRole name from step 1:
    • Review which secrets resources and verbs are granted, and whether any * verbs or * resources are present.
  3. Map ClusterRoles to subjects via ClusterRoleBindings
    • Run on: any machine with kubectl access
    • For each ClusterRole from step 1:
    • Use this to determine which users, groups, or service accounts receive secret access and in which namespaces they operate.
  4. Decide least-privilege requirements per subject
    • For each subject from step 3, answer:
      • Does it truly need get/list/watch on secrets?
      • If yes, is cluster-wide access required, or only specific namespaces?
      • Can access be narrowed to specific secret names (via resourceNames) or limited to get only instead of list/watch?
    • Document which permissions are justified and which should be removed or scope-reduced.
  5. Adjust ClusterRoles and bindings to enforce least privilege
    • Run on: any machine with kubectl access
    • To remove or narrow secret access from a ClusterRole:
      • In the editor, either:
        • Remove the entire rule that includes secrets, or
        • Remove secrets from .rules[].resources, or
        • Remove unnecessary verbs (list, watch, or *) from .rules[].verbs, or
        • Add .resourceNames to restrict to specific secret names if appropriate.
    • If cluster-scoped access is not needed, create namespace-scoped Roles and RoleBindings instead and then remove the corresponding ClusterRoleBinding(s).
  6. Re-verify effective secret access after changes
    • Run on: any machine with kubectl access
    • Re-run the detection query:
    • Confirm that only the ClusterRoles you explicitly decided to keep with secret access remain, and that their definitions match your least-privilege decisions from step 4.
Output meaning:
  • Any ClusterRole name printed here has at least one rule granting get, list, or watch on the secrets resource.
  • Each such role must be manually reviewed to decide if that level of access is truly required.

What to look for:
  • Problematic examples:
    • resources: ["*"] combined with verbs: ["*"] or including get, list, watch.
    • resources: ["secrets"] with verbs including any of get, list, watch where the role is used by broad subjects (e.g., all service accounts in a namespace).
  • Safer patterns:
    • Roles scoped to specific non-secret resources only.
    • Roles that only use non-read verbs for secrets (e.g., rare cases of create or update for a tightly scoped automation, though these also warrant review).

Output meaning:
  • Prints: <clusterrolebinding-name> <subject-kind:namespace:name,...>
  • Problematic indicators:
    • Bindings to system:authenticated, system:serviceaccounts, or system:serviceaccounts:<namespace> when the role has secret read access.
    • Bindings to many generic service accounts that don’t clearly need secret read access.

Then inspect each Role:
What to look for:
  • Roles with secret read verbs in namespaces where many workloads run, especially paired with broad RoleBindings.

Problem indicators:
  • RoleBindings that attach secret-reading Roles to:
    • Default service accounts (e.g., ServiceAccount:<namespace>:default).
    • Large groups or all service accounts in a namespace.

Output meaning:
  • Shows effective permissions; lines mentioning secrets with get, list, or watch indicate that the associated user/group/service account can read secrets.
  • Use this as a cross-check to focus your manual review.