Review service account token verification keys

Review the keys and trust configuration kube-apiserver uses to verify service account tokens.

Description

kube-apiserver uses the PEM keys in --service-account-key-file to verify service account token signatures. With local verification, omitting the flag falls back to the key in --tls-private-key-file.

Potential impact

A mismatched key can reject valid tokens. Trusting an extra key may let tokens signed by an unintended key pass signature verification.

Remediation

If you set --service-account-signing-key-file, supply its corresponding verification key through --service-account-key-file on every API server. Check the path and read permissions. For an external signer, follow its verification procedure and omit incompatible local key flags.

Examples

The arguments shown are from Kubernetes 1.6. On a supported version, mount the actual PEM file at the configured path.

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command: ["kube-apiserver"]
      args: []

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: command-demo
spec:
  containers:
    - name: command-demo-container
      image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
      command: ["kube-apiserver"]
      args: ["--service-account-key-file=/path/to/file.pem"]

References