documentation_complete: true


title: 'kubelet - Disable the Read-Only Port'

{{% set default_jqfilter = '.data."config.yaml" | fromjson' %}}
{{% set default_api_path = '/api/v1/namespaces/openshift-kube-apiserver/configmaps/config' %}}
{{% set hypershift_path = '/api/v1/namespaces/{{.hypershift_namespace_prefix}}-{{.hypershift_cluster}}/configmaps/kas-config' %}}
{{% set hypershift_jqfilter = '.data."config.json" | fromjson' %}}
{{% set custom_api_path = '{{if ne .hypershift_cluster "None"}}' ~ hypershift_path ~ '{{else}}' ~  default_api_path ~ '{{end}}' %}}
{{% set custom_jqfilter = '{{if ne .hypershift_cluster "None"}}' ~ hypershift_jqfilter ~ '{{else}}' ~  default_jqfilter ~ '{{end}}' %}}
{{% set dump_path = default_api_path ~ ',' ~ default_jqfilter ~ ',' ~ custom_jqfilter %}}

description: |-
    To disable the read-only port, edit the kubelet configuration
    Edit the <tt>openshift-kube-apiserver</tt> configmap
    and set the <tt>kubelet-read-only-port</tt> parameter to 0:
    <pre>
    "apiServerArguments":{
      ...
      "kubelet-read-only-port":[
        "0"
      ],
      ...
    </pre>

rationale: |-
    OpenShift disables the read-only port (<tt>10255</tt>) on all nodes by setting the
    read-only port kubelet flag to <tt>0</tt>. This ensures only
    authenticated connections are able to receive information about the OpenShift
    system.

severity: medium

ocil_clause: 'the read-only port is not disabled'

ocil: |-
    Run the following command:
    <pre>$ oc get configmap config -n openshift-kube-apiserver -ojson | jq -r '.data["config.yaml"]' | jq -r '.apiServerArguments["kubelet-read-only-port"]'</pre>
    The output should be <tt>0</tt>.

identifiers:
    cce@ocp4: CCE-83427-5

references:
    cis@ocp4: 4.2.5
    nerc-cip: CIP-003-8 R6,CIP-004-6 R3,CIP-007-3 R6.1
    nist: CM-6,CM-6(1)
    pcidss: Req-2.2
    srg: SRG-APP-000516-CTR-001325

warnings:
    - general: |-
        {{{ openshift_filtered_cluster_setting({custom_api_path: dump_path}) | indent(8) }}}

template:
    name: yamlfile_value
    vars:
        ocp_data: "true"
        filepath: {{{ openshift_filtered_path(default_api_path, default_jqfilter) }}}
        yamlpath: '.apiServerArguments["kubelet-read-only-port"][:]'
        values:
          - value: '0'
            type: "string"
            operation: "pattern match"
