Controller Manager Configuration File Ownership Is Root
More Info:
Ensure that the controller-manager.conf file ownership is set to root:root.
Risk Level
Low
Address
Security
Compliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
-
On every control plane node, confirm the file exists and view current ownership:
ls -l /etc/kubernetes/controller-manager.conf -
On every control plane node, change the file owner and group to root:root:
sudo chown root:root /etc/kubernetes/controller-manager.conf -
(Optional) On every control plane node, lock down permissions if needed (common setting is 600):
sudo chmod 600 /etc/kubernetes/controller-manager.conf -
On every control plane node, verify the ownership is now root:root:
/bin/sh -c 'if test -e /etc/kubernetes/controller-manager.conf; then stat -c %U:%G /etc/kubernetes/controller-manager.conf; fi'
Using kubectl
kubectl cannot modify file ownership on control plane nodes, so it cannot be used to fix /etc/kubernetes/controller-manager.conf. This must be corrected directly on every control plane node’s host filesystem; see the Manual Steps section for the exact commands to run.
Automation
#!/usr/bin/env bash
#
# Fix ownership of /etc/kubernetes/controller-manager.conf to root:root
# Scope: run on every control plane node (with sudo/root privileges)
# Safe to re-run (idempotent).
set -euo pipefail
TARGET_FILE="/etc/kubernetes/controller-manager.conf"
DESIRED_OWNER="root"
DESIRED_GROUP="root"
echo "=== CIS 1.1.18: Ensure ${TARGET_FILE} ownership is ${DESIRED_OWNER}:${DESIRED_GROUP} ==="
if [ ! -e "${TARGET_FILE}" ]; then
echo "INFO: ${TARGET_FILE} does not exist on this node. Nothing to change."
exit 0
fi
current_owner="$(stat -c '%U' "${TARGET_FILE}")"
current_group="$(stat -c '%G' "${TARGET_FILE}")"
echo "Current ownership: ${current_owner}:${current_group}"
if [ "${current_owner}" = "${DESIRED_OWNER}" ] && [ "${current_group}" = "${DESIRED_GROUP}" ]; then
echo "INFO: Ownership already set to ${DESIRED_OWNER}:${DESIRED_GROUP}. No change needed."
else
echo "Updating ownership to ${DESIRED_OWNER}:${DESIRED_GROUP} ..."
chown "${DESIRED_OWNER}:${DESIRED_GROUP}" "${TARGET_FILE}"
fi
echo "Verifying ownership..."
verified_owner_group="$(stat -c '%U:%G' "${TARGET_FILE}")"
echo "stat -c %U:%G ${TARGET_FILE} => ${verified_owner_group}"
if [ "${verified_owner_group}" != "${DESIRED_OWNER}:${DESIRED_GROUP}" ]; then
echo "ERROR: Failed to set ownership on ${TARGET_FILE} to ${DESIRED_OWNER}:${DESIRED_GROUP}" >&2
exit 1
fi
echo "SUCCESS: ${TARGET_FILE} ownership is correctly set to ${DESIRED_OWNER}:${DESIRED_GROUP}."
Usage:
- Run this script on every control plane node as root, for example:
sudo bash ./fix-controller-manager-conf-ownership.sh