documentation_complete: true

title: 'Configure System Cryptography Policy'

description: |-
    To configure the system cryptography policy to use ciphers only from the <tt>{{{ xccdf_value("var_system_crypto_policy") }}}</tt>
    {{% if product != "rhcos4" -%}}
    policy, run the following command:
    <pre>$ sudo update-crypto-policies --set {{{ xccdf_value("var_system_crypto_policy") }}}</pre>
    {{% else -%}}
    policy, create a <tt>MachineConfig</tt> as follows:
    <pre>
    ---
    apiVersion: machineconfiguration.openshift.io/v1
    kind: MachineConfig
    metadata:
      labels:
        machineconfiguration.openshift.io/role: master
      name: 50-master-configure-crypto-policy
    spec:
      config:
        ignition:
          version: 3.1.0
        systemd:
          units:
            - name: configure-crypto-policy.service
              enabled: true
              contents: |
                [Unit]
                Before=kubelet.service
                [Service]
                Type=oneshot
                ExecStart=update-crypto-policies --set {{{ xccdf_value("var_system_crypto_policy") }}}
                RemainAfterExit=yes
                [Install]
                WantedBy=multi-user.target
    </pre>
    <p>
    This will configure the crypto policy appropriately in all the
    nodes labeled with the "master" role.
    </p>
    {{{ machineconfig_description_footer() | indent(4) }}}
    {{% endif -%}}
    The rule checks if settings for selected crypto policy are configured as expected. Configuration files in the <tt>/etc/crypto-policies/back-ends</tt> are either symlinks to correct files provided by Crypto-policies package or they are regular files in case crypto policy customizations are applied.
    Crypto policies may be customized by crypto policy modules, in which case it is delimited from the base policy using a colon.

rationale: |-
    Centralized cryptographic policies simplify applying secure ciphers across an operating system and
    the applications that run on that operating system. Use of weak or untested encryption algorithms
    undermines the purposes of utilizing encryption to protect data.

severity: high

references:
    cis@rhel8: 1.6.1
    cis@rhel9: 1.10
    hipaa: 164.308(a)(4)(i),164.308(b)(1),164.308(b)(3),164.312(e)(1),164.312(e)(2)(ii)
    ism: "1446"
    nerc-cip: CIP-003-3 R4.2,CIP-007-3 R5.1,CIP-007-3 R7.1
    nist: AC-17(a),AC-17(2),CM-6(a),MA-4(6),SC-13,SC-12(2),SC-12(3)
    ospp: FCS_COP.1(1),FCS_COP.1(2),FCS_COP.1(3),FCS_COP.1(4),FCS_CKM.1,FCS_CKM.2,FCS_TLSC_EXT.1
    pcidss4: '2.2.7'
    stigid@ol8: OL08-00-010020
    stigid@rhel8: RHEL-08-010020
    srg: SRG-OS-000396-GPOS-00176,SRG-OS-000393-GPOS-00173,SRG-OS-000394-GPOS-00174

ocil_clause: 'cryptographic policy is not configured or is configured incorrectly'

ocil: |-
    To verify that cryptography policy has been configured correctly, run the
    following command:
    <pre>$ update-crypto-policies --show</pre>
    The output should return <pre>{{{ xccdf_value("var_system_crypto_policy") }}}</pre>.
    Run the command to check if the policy is correctly applied:
    <pre>$ update-crypto-policies --is-applied</pre>
    The output should be <pre>The configured policy is applied</pre>.
    Moreover, check if settings for selected crypto policy are as expected.
    List all libraries for which it holds that their crypto policies do not have symbolic link in <pre>/etc/crypto-policies/back-ends</pre>.
    <pre>$ ls -l /etc/crypto-policies/back-ends/ | grep '^[^l]' | tail -n +2 | awk -F' ' '{print $NF}' | awk -F'.' '{print $1}' | sort</pre>
    Subsequently, check if matching libraries have drop in files in the <pre>/etc/crypto-policies/local.d</pre> directory.
    <pre>$ ls /etc/crypto-policies/local.d/ | awk -F'-' '{print $1}' | uniq | sort</pre>
    Outputs of two previous commands should match.

fixtext: |-
    Configure {{{ full_name }}} to implement approved encryption.
    
    update-crypto-policies --set {{{ xccdf_value("var_system_crypto_policy") }}}

srg_requirement: '{{{ full_name }}} must use the {{{ xccdf_value("var_system_crypto_policy") }}} crypto policy.'

warnings:
    - general: |-
        The system needs to be rebooted for these changes to take effect.
    - regulatory: |-
        System Crypto Modules must be provided by a vendor that undergoes
        FIPS-140 certifications.
        FIPS-140 is applicable to all Federal agencies that use
        cryptographic-based security systems to protect sensitive information
        in computer and telecommunication systems (including voice systems) as
        defined in Section 5131 of the Information Technology Management Reform
        Act of 1996, Public Law 104-106. This standard shall be used in
        designing and implementing cryptographic modules that Federal
        departments and agencies operate or are operated for them under
        contract. See <b>{{{ weblink(link="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf") }}}</b>
        To meet this, the system has to have cryptographic software provided by
        a vendor that has undergone this certification. This means providing
        documentation, test results, design information, and independent third
        party review by an accredited lab. While open source software is
        capable of meeting this, it does not meet FIPS-140 unless the vendor
        submits to this process.
