Profile Applicability:
• Level 1
Description:
Ensure that the Kubelet is configured to authenticate using certificates by setting the client certificate authority (CA) file.
Rationale:
When Kubelet is authenticated using certificates, the apiserver uses the client certificate to verify the authenticity of the Kubelet before any interaction occurs. This ensures the connection is secure, preventing man-in-the-middle attacks. Without client certificate authentication, connections from the apiserver to Kubelet could be intercepted, compromising the cluster.
Impact:
Pros:
Secures Kubelet connections by enforcing certificate-based authentication.
Prevents man-in-the-middle attacks and ensures the integrity of the connection.
Improves overall security by ensuring mutual authentication between the apiserver and Kubelet.
Cons:
Requires TLS to be configured both on the apiserver and the Kubelets.
Adds complexity in configuration and maintenance.
Default Value:
The default setting might vary based on the Kubernetes distribution. Check AWS EKS documentation for default values.
Pre-requisites:
Access to worker nodes via SSH or Session Manager.
Ability to modify Kubelet configurations and restart services.
Kubernetes access to test via /configz or deploy privileged pods.
Remediation
Test Plan:
Using AWS Console:
SSH into the worker node and run the following command to find the Kubelet process:
ps -ef | grep kubelet
Identify the path of the configuration file from the --config argument.
Open the Kubelet configuration file to check if a client CA file is configured:
sudo less /path/to/kubelet-config.json
Look for the following entry:
"authentication": { "x509": { "clientCAFile": <path/to/client-ca-file> } }
Using AWS CLI:
Get the list of nodes in your cluster:
kubectl get nodes
Start a proxy to the Kubernetes API:
kubectl proxy --port=8080
In a separate terminal, for each node, run:
export NODE_NAME=my-node-name curl http://localhost:8080/api/v1/nodes/${NODE_NAME}/proxy/configz
Verify that the client CA file is configured by checking the returned JSON for:
"authentication": { "x509": { "clientCAFile": <path/to/client-ca-file> } }
Implementation Plan
Using AWS Console:
SSH into the worker node and find the Kubelet configuration file via ps -ef | grep kubelet.
Open the file:
sudo less /path/to/kubelet-config.json
Add or modify the following entry to configure the client CA file:
"authentication": { "x509": { "clientCAFile": <path/to/client-ca-file> } }
Save the file and exit.
Using AWS CLI:
Locate and edit the Kubelet systemd service file (e.g., /etc/systemd/system/kubelet.service.d/10-kubelet-args.conf for Amazon Linux or Bottlerocket AMIs).
Add the following argument to the KUBELET_ARGS variable:
--client-ca-file=<path/to/client-ca-file>
Reload systemd and restart the Kubelet service:
systemctl daemon-reload systemctl restart kubelet.service systemctl status kubelet -l
Backout Plan
Using AWS Console:
If using a configuration file, revert the file to its previous version without the clientCAFile entry.
If using systemd arguments, remove the --client-ca-file argument and restart the Kubelet service.
Using AWS CLI:
Remove the --client-ca-file flag from the systemd unit or revert to the previous configuration file version if backed up.
Restart the Kubelet service:
systemctl daemon-reload systemctl restart kubelet.service
References:
Kubelet Authentication and Authorization