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

# Controller Manager Pod Specification File Ownership Should Be root:root

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

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

    <AccordionGroup>
      <Accordion title="Manual Steps" defaultOpen="true">
        1. On every control plane node, check the current ownership of the manifest file:
           ```bash theme={null}
           stat -c %U:%G /etc/kubernetes/manifests/kube-controller-manager.yaml
           ```

        2. If the owner or group is not `root:root`, change the ownership on that control plane node:
           ```bash theme={null}
           sudo chown root:root /etc/kubernetes/manifests/kube-controller-manager.yaml
           ```

        3. (Optional) Confirm file still exists and note that editing a static pod manifest under `/etc/kubernetes/manifests` will trigger an automatic restart of the kube-controller-manager pod by the kubelet; no manual restart is needed.

        4. Verify the fix on that control plane node:
           ```bash theme={null}
           stat -c %U:%G /etc/kubernetes/manifests/kube-controller-manager.yaml
           ```
           The output must be:
           ```bash theme={null}
           root:root
           ```
      </Accordion>

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

      <Accordion title="Automation">
        ```bash theme={null}
        #!/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).
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
