Ensure that the --service-account-lookup argument is set to true (API Server)

Validate service account before validating token. If --service-account-lookup is not enabled, the apiserver only verifies that the authentication token is valid, and does not validate that the service account token mentioned in the request is actually present in etcd. This allows using a service account token even after the corresponding service account is deleted. This is an example of time of check to time of use security issue.

Risk Level: High
Cloud Entity: Pods
CloudGuard Rule ID: D9.K8S.MON.02
Covered by Spectral: Yes
Category: Compute

GSL LOGIC

KubernetesPod where labels contain [value='kube-apiserver'] and namespace = 'kube-system' should not have spec.containers with [parsedArgs contain [key like 'service-account-lookup' and value = 'true']]

REMEDIATION

Edit the API server pod specification file $apiserverconf
on the master node and set the below parameter.
--service-account-lookup=true

References

  1. https://kubernetes.io/docs/admin/kube-apiserver/
  2. https://github.com/kubernetes/kubernetes/issues/24167
  3. https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use

Pods

Pods are the smallest deployable units of computing that can be created and managed in Kubernetes.A Pod is a group of one or more containers (such as Docker containers), with shared storage/network, and a specification for how to run the containers.

Compliance Frameworks

  • CIS Kubernetes Benchmark v1.20
  • CIS Kubernetes Benchmark v1.23
  • CIS Kubernetes Benchmark v1.24
  • CIS Kubernetes Benchmark v1.4.0
  • CIS Kubernetes Benchmark v1.5.1
  • CIS Kubernetes Benchmark v1.6.1
  • Kubernetes NIST.SP.800-190
  • Kubernetes v.1.13 CloudGuard Best Practices
  • Kubernetes v.1.14 CloudGuard Best Practices