Profile Applicability:
• Level 1
Description:
If the kubelet is running, ensure that the ownership of its kubeconfig file is set to root:root. This ownership protects the file from unauthorized modification and ensures only privileged users can alter its configuration.
Rationale:
The kubelet kubeconfig file controls various parameters for the kubelet service in the worker node. Setting its file ownership to root:root helps maintain the integrity and security of the file, preventing unauthorized changes that could lead to cluster compromise.
Impact:
Pros:
Prevents unauthorized users from modifying sensitive configuration files.
Helps maintain compliance with least privilege access standards.
Strengthens node-level security posture.
Default Value:
The default ownership setting may vary depending on the base AMI or OS image used. Refer to AWS EKS documentation for default image behavior.
Pre-requisites:
SSH or Systems Manager access to worker nodes.
Permissions to inspect and modify file ownership on the node file system.
Privileged pod access if using Kubernetes-native methods.
Remediation
Test Plan:
Using AWS Console:
Navigate to Amazon EC2 > Instances.
Select a worker node and connect using Session Manager or EC2 Connect.
Verify that the kubelet service is running:
sudo systemctl status kubelet
Identify the path of the kubeconfig file:
ps -ef | grep kubelet
Run the following command to check file ownership:
stat -c %U:%G /var/lib/kubelet/kubeconfig
Confirm that the output is root:root.
Using AWS CLI:
Create a privileged pod to inspect the host’s filesystem.
Enter the pod and check file ownership of the kubeconfig file.
kubectl apply -f file-check-pod.yaml kubectl exec -it file-check -- sh ls -l /host/var/lib/kubelet/kubeconfig
Implementation Plan
Using AWS Console:
Open a shell into the worker node using Session Manager or EC2 Connect.
Change the file ownership of the kubeconfig file to root:root using chown.
Using AWS CLI:
SSH into the worker node or use Session Manager.
Run the following command to update ownership:
chown root:root /var/lib/kubelet/kubeconfig
Backout Plan
Using AWS Console:
Connect to the node using Session Manager.
If needed, revert to the previous file owner based on operational requirements using chown.
Using AWS CLI:
Revert ownership to the previous user/group if necessary:
chown <previous_user>:<previous_group> /var/lib/kubelet/kubeconfig