Broad Pod creation permissions

Broad Pod creation permissions can let users gain higher privileges indirectly.

Description

Grant create on pods only to accounts that deploy workloads, in the namespaces they need. Within admission-policy limits, Pod creators choose the image, service account, volumes and security settings.

Potential impact

A Pod that uses a powerful service account or sensitive data can give its creator access beyond what the deployment requires.

Remediation

For an account that only inspects Pods, grant the read operations it needs. List the actual resources and verbs instead of using *, and review every binding for the account. Verify that it can read Pods in the intended namespace and cannot create them.

Examples

The examples define two ClusterRoles and omit their bindings.

Before

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: pod-creator
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs:
      - "get"
      - "watch"
      - "create"

After

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: pod-reader
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs:
      - "get"
      - "watch"
      - "list"

pod-creator permits get, watch and create. The separate pod-reader role grants list in place of create. Revoke the account’s old creation grant while preserving access for any other subjects that still need it.

References