Scheduler Kubeconfig File Ownership Should Be root:root
More Info:
Verifies that the scheduler.conf kubeconfig file is owned by root:root so only privileged users can read the schedulers client credentials.
Risk Level
Medium
Address
Security
Compliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
-
Log in to each control plane node over SSH as a user with sudo privileges.
-
On each control plane node, set the correct ownership on the scheduler kubeconfig file:
sudo chown root:root /etc/kubernetes/scheduler.conf -
(Optional) Confirm the permissions look reasonable (typically 600 or 644, adjust only if required by your hardening policy):
stat -c '%a %n' /etc/kubernetes/scheduler.conf -
Verify the ownership is now set to
root:rootusing the audit command on each control plane node:/bin/sh -c 'if test -e /etc/kubernetes/scheduler.conf; then stat -c %U:%G /etc/kubernetes/scheduler.conf; fi'The output must be:
root:root
Using kubectl
kubectl cannot modify host-level file ownership, including /etc/kubernetes/scheduler.conf on control plane nodes. This must be fixed directly on each control plane node’s filesystem; see the Manual Steps section for the exact commands to run over SSH.
Automation
#!/usr/bin/env bash
#
# Fix ownership of /etc/kubernetes/scheduler.conf to root:root
# Scope: run on every control plane node
# Safe to re-run (idempotent)
set -euo pipefail
SCHED_CONF="/etc/kubernetes/scheduler.conf"
echo "==> Checking for ${SCHED_CONF}"
if [ ! -e "${SCHED_CONF}" ]; then
echo "File ${SCHED_CONF} does not exist on this node. Nothing to do."
exit 0
fi
current_owner_group="$(stat -c '%U:%G' "${SCHED_CONF}")"
echo "Current ownership: ${current_owner_group}"
if [ "${current_owner_group}" != "root:root" ]; then
echo "Updating ownership of ${SCHED_CONF} to root:root"
chown root:root "${SCHED_CONF}"
else
echo "Ownership already set to root:root; no change needed."
fi
echo "==> Verifying ownership"
verify_owner_group="$(stat -c '%U:%G' "${SCHED_CONF}")"
echo "Verified ownership: ${verify_owner_group}"
if [ "${verify_owner_group}" != "root:root" ]; then
echo "ERROR: Failed to set ownership of ${SCHED_CONF} to root:root" >&2
exit 1
fi
echo "Ownership of ${SCHED_CONF} is correctly set to root:root"
Usage (run on every control plane node):
- Copy the script to each control plane node, for example:
scp fix-scheduler-kubeconfig-ownership.sh <control-plane-node>:/root/
- SSH to each control plane node and run:
chmod +x /root/fix-scheduler-kubeconfig-ownership.shsudo /root/fix-scheduler-kubeconfig-ownership.sh
- Optional explicit verification on each control plane node:
/bin/sh -c 'if test -e /etc/kubernetes/scheduler.conf; then stat -c %U:%G /etc/kubernetes/scheduler.conf; fi'