Service account lookup not set
ID |
api_server_service_account_lookup |
Severity |
low |
Vendor |
Kubernetes |
Resource |
kube-apiserver |
Tags |
reachable |
Description
The Kubernetes API Server validates and configures data for the api objects which include pods, services, replication controllers, and others.
When --service-account-lookup
is not enabled, the API Server does not verify 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.
Examples
apiVersion: v1
kind: Pod
metadata:
name: bad (1)
spec:
containers:
- command:
- kube-apiserver
image: gcr.io/google_containers/kube-apiserver-amd64:v1.9.0
name: bad-container
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /health
port: 6443
scheme: HTTPS
initialDelaySeconds: 15
timeoutSeconds: 15
resources:
requests:
cpu: 250m
volumeMounts:
- mountPath: /etc/kubernetes/
name: k8s
readOnly: true
- mountPath: /etc/ssl/certs
name: certs
- mountPath: /etc/pki
name: pki
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes
name: k8s
- hostPath:
path: /etc/ssl/certs
name: certs
- hostPath:
path: /etc/pki
name: pki
1 | Missing -service-account-lookup command argument means API Server does not validate that the service account token mentioned in the request is actually present in etcd. |
Mitigation / Fix
apiVersion: v1
kind: Pod
metadata:
name: good
spec:
containers:
- command:
- kube-apiserver
- --service-account-lookup=true (1)
image: gcr.io/google_containers/kube-apiserver-amd64:v1.9.0
name: good-container
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /health
port: 6443
scheme: HTTPS
initialDelaySeconds: 15
timeoutSeconds: 15
resources:
requests:
cpu: 250m
volumeMounts:
- mountPath: /etc/kubernetes/
name: k8s
readOnly: true
- mountPath: /etc/ssl/certs
name: certs
- mountPath: /etc/pki
name: pki
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes
name: k8s
- hostPath:
path: /etc/ssl/certs
name: certs
- hostPath:
path: /etc/pki
name: pki
1 | Provided -service-account-lookup command argument means API Server validates that the service account token mentioned in the request is actually present in etcd. |