> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Ensure 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

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Manual Steps" defaultOpen="true">
        1. On every control plane node, confirm the file exists and view current ownership:
           ```sh theme={null}
           ls -l /etc/kubernetes/controller-manager.conf
           ```

        2. On every control plane node, change the file owner and group to root:root:
           ```sh theme={null}
           sudo chown root:root /etc/kubernetes/controller-manager.conf
           ```

        3. (Optional) On every control plane node, lock down permissions if needed (common setting is 600):
           ```sh theme={null}
           sudo chmod 600 /etc/kubernetes/controller-manager.conf
           ```

        4. On every control plane node, verify the ownership is now root:root:
           ```sh theme={null}
           /bin/sh -c 'if test -e /etc/kubernetes/controller-manager.conf; then stat -c %U:%G /etc/kubernetes/controller-manager.conf; fi'
           ```
      </Accordion>

      <Accordion title="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.
      </Accordion>

      <Accordion title="Automation">
        ```bash theme={null}
        #!/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:

        ```bash theme={null}
        sudo bash ./fix-controller-manager-conf-ownership.sh
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

### Additional Reading:

* [https://kubernetes.io/docs/admin/kube-controller-manager/](https://kubernetes.io/docs/admin/kube-controller-manager/)
