Controller Manager Pod Specification File Ownership Should
More Info:
Verifies that the kube-controller-manager pod manifest file is owned by root:root so only privileged users can modify it.
Risk Level
Medium
Address
Security
Compliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
-
On every control plane node, check the current ownership of the manifest file:
stat -c %U:%G /etc/kubernetes/manifests/kube-controller-manager.yaml -
If the owner or group is not
root:root, change the ownership on that control plane node:sudo chown root:root /etc/kubernetes/manifests/kube-controller-manager.yaml -
(Optional) Confirm file still exists and note that editing a static pod manifest under
/etc/kubernetes/manifestswill trigger an automatic restart of the kube-controller-manager pod by the kubelet; no manual restart is needed. -
Verify the fix on that control plane node:
stat -c %U:%G /etc/kubernetes/manifests/kube-controller-manager.yamlThe output must be:
root:root
Using kubectl
kubectl cannot modify file ownership on control plane nodes, so it cannot be used to fix this finding on /etc/kubernetes/manifests/kube-controller-manager.yaml. To remediate, you must change ownership directly on every control plane node’s filesystem; see the Manual Steps section for exact commands.
Automation
#!/usr/bin/env bash
#
# Fix ownership of kube-controller-manager pod manifest to root:root
# Scope: run on every control plane node
# Idempotent: safe to run multiple times
set -euo pipefail
MANIFEST_PATH="/etc/kubernetes/manifests/kube-controller-manager.yaml"
echo "==> Checking for kube-controller-manager manifest at ${MANIFEST_PATH}"
if [ ! -e "${MANIFEST_PATH}" ]; then
echo "Manifest file not found at ${MANIFEST_PATH}. Nothing to do on this node."
exit 0
fi
current_owner_group="$(stat -c '%U:%G' "${MANIFEST_PATH}")"
echo "Current ownership: ${current_owner_group}"
if [ "${current_owner_group}" = "root:root" ]; then
echo "Ownership already set to root:root. No change needed."
else
echo "Setting ownership to root:root ..."
chown root:root "${MANIFEST_PATH}"
fi
# Verification
echo "==> Verifying ownership after changes"
verified_owner_group="$(stat -c '%U:%G' "${MANIFEST_PATH}")"
echo "Verified ownership: ${verified_owner_group}"
if [ "${verified_owner_group}" != "root:root" ]; then
echo "ERROR: Failed to set ownership to root:root on ${MANIFEST_PATH}" >&2
exit 1
fi
echo "Ownership successfully set to root:root on ${MANIFEST_PATH}"
Usage:
- Run this script on every control plane node (e.g., via SSH or your configuration management/automation system).