Blame SOURCES/scap-security-guide-0.1.55-sshd_approved_ciphers_ordered-PR_6541.patch

618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers/rule.yml b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers/rule.yml
618a7c
index abcebf60c7..50c7d689af 100644
618a7c
--- a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers/rule.yml
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers/rule.yml
618a7c
@@ -61,7 +61,6 @@ references:
618a7c
     nist-csf: PR.AC-1,PR.AC-3,PR.AC-4,PR.AC-6,PR.AC-7,PR.IP-1,PR.PT-1,PR.PT-3,PR.PT-4
618a7c
     srg: SRG-OS-000033-GPOS-00014,SRG-OS-000120-GPOS-00061,SRG-OS-000125-GPOS-00065,SRG-OS-000250-GPOS-00093,SRG-OS-000393-GPOS-00173,SRG-OS-000394-GPOS-00174
618a7c
     vmmsrg: SRG-OS-000033-VMM-000140,SRG-OS-000120-VMM-000600,SRG-OS-000478-VMM-001980,SRG-OS-000396-VMM-001590
618a7c
-    stigid@rhel7: RHEL-07-040110
618a7c
     isa-62443-2013: 'SR 1.1,SR 1.10,SR 1.11,SR 1.12,SR 1.13,SR 1.2,SR 1.3,SR 1.4,SR 1.5,SR 1.6,SR 1.7,SR 1.8,SR 1.9,SR 2.1,SR 2.10,SR 2.11,SR 2.12,SR 2.2,SR 2.3,SR 2.4,SR 2.5,SR 2.6,SR 2.7,SR 2.8,SR 2.9,SR 3.1,SR 3.5,SR 3.8,SR 4.1,SR 4.3,SR 5.1,SR 5.2,SR 5.3,SR 7.1,SR 7.6'
618a7c
     isa-62443-2009: 4.3.3.2.2,4.3.3.3.9,4.3.3.5.1,4.3.3.5.2,4.3.3.5.3,4.3.3.5.4,4.3.3.5.5,4.3.3.5.6,4.3.3.5.7,4.3.3.5.8,4.3.3.6.1,4.3.3.6.2,4.3.3.6.3,4.3.3.6.4,4.3.3.6.5,4.3.3.6.6,4.3.3.6.7,4.3.3.6.8,4.3.3.6.9,4.3.3.7.1,4.3.3.7.2,4.3.3.7.3,4.3.3.7.4,4.3.4.3.2,4.3.4.3.3,4.3.4.4.7,4.4.2.1,4.4.2.2,4.4.2.4
618a7c
     cobit5: APO11.04,APO13.01,BAI03.05,BAI10.01,BAI10.02,BAI10.03,BAI10.05,DSS01.04,DSS05.02,DSS05.03,DSS05.04,DSS05.05,DSS05.07,DSS05.10,DSS06.03,DSS06.06,DSS06.10,MEA02.01
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/ansible/shared.yml b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/ansible/shared.yml
618a7c
new file mode 100644
618a7c
index 0000000000..4796a2eab1
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/ansible/shared.yml
618a7c
@@ -0,0 +1,13 @@
618a7c
+# platform = Red Hat Enterprise Linux 7,Oracle Linux 7
618a7c
+# reboot = false
618a7c
+# strategy = restrict
618a7c
+# complexity = low
618a7c
+# disruption = low
618a7c
+
618a7c
+- name: "Configure sshd to use approved ciphers"
618a7c
+  lineinfile:
618a7c
+    path: /etc/ssh/sshd_config
618a7c
+    line: 'Ciphers aes256-ctr,aes192-ctr,aes128-ctr'
618a7c
+    state: present
618a7c
+    regexp: '^[\s]*[Cc]iphers[\s]+(aes256-ctr(?=[\w,-@]+|$),?)?(aes192-ctr(?=[\w,-@]+|$),?)?(aes128-ctr(?=[\w,-@]+|$),?)?[\s]*(?:#.*)?$'
618a7c
+    create: True
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/bash/shared.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/bash/shared.sh
618a7c
new file mode 100644
618a7c
index 0000000000..8f751ed516
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/bash/shared.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+# platform = multi_platform_wrlinux,Red Hat Enterprise Linux 7,Oracle Linux 7
618a7c
+
618a7c
+if grep -q -P '^\s*[Cc]iphers\s+' /etc/ssh/sshd_config; then
618a7c
+  sed -i 's/^\s*[Cc]iphers.*/Ciphers aes256-ctr,aes192-ctr,aes128-ctr/' /etc/ssh/sshd_config
618a7c
+else
618a7c
+  echo "Ciphers aes256-ctr,aes192-ctr,aes128-ctr" >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/oval/shared.xml b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/oval/shared.xml
618a7c
new file mode 100644
618a7c
index 0000000000..53ff0a2a9e
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/oval/shared.xml
618a7c
@@ -0,0 +1,38 @@
618a7c
+<def-group>
618a7c
+  <definition class="compliance" id="sshd_use_approved_ciphers_ordered_stig" version="1">
618a7c
+    {{{ oval_metadata("Limit the ciphers to those which are FIPS-approved.") }}}
618a7c
+    <criteria operator="AND">
618a7c
+      <extend_definition comment="Installed OS is FIPS certified" definition_ref="installed_OS_is_FIPS_certified" />
618a7c
+      
618a7c
+      operator="OR">
618a7c
+        <criteria comment="sshd is not installed" operator="AND">
618a7c
+          
618a7c
+          definition_ref="sshd_not_required_or_unset" />
618a7c
+          
618a7c
+          definition_ref="package_openssh-server_removed" />
618a7c
+        </criteria>
618a7c
+        <criteria comment="sshd is installed and configured" operator="AND">
618a7c
+          
618a7c
+          definition_ref="sshd_required_or_unset" />
618a7c
+          
618a7c
+          definition_ref="package_openssh-server_installed" />
618a7c
+          
618a7c
+          test_ref="test_sshd_use_approved_ciphers_ordered_stig" />
618a7c
+        </criteria>
618a7c
+      </criteria>
618a7c
+    </criteria>
618a7c
+  </definition>
618a7c
+
618a7c
+  
618a7c
+  comment="tests the value of Ciphers setting in the /etc/ssh/sshd_config file"
618a7c
+  id="test_sshd_use_approved_ciphers_ordered_stig" version="1">
618a7c
+    <ind:object object_ref="obj_sshd_use_approved_ciphers_ordered_stig" />
618a7c
+  </ind:textfilecontent54_test>
618a7c
+
618a7c
+  <ind:textfilecontent54_object id="obj_sshd_use_approved_ciphers_ordered_stig" version="1">
618a7c
+    <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
618a7c
+    <ind:pattern operation="pattern match">^[\s]*(?i)Ciphers(?-i)[\s]+(?=[\w]+)(aes256-ctr(?=[\w,]+|$),?)?(aes192-ctr(?=[\w,]+|$),?)?(aes128-ctr)?[\s]*(?:#.*)?$</ind:pattern>
618a7c
+    <ind:instance datatype="int">1</ind:instance>
618a7c
+  </ind:textfilecontent54_object>
618a7c
+
618a7c
+</def-group>
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/rule.yml b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/rule.yml
618a7c
new file mode 100644
618a7c
index 0000000000..0751064179
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/rule.yml
618a7c
@@ -0,0 +1,64 @@
618a7c
+documentation_complete: true
618a7c
+
618a7c
+prodtype: rhel7
618a7c
+
618a7c
+title: 'Use Only FIPS 140-2 Validated Ciphers'
618a7c
+
618a7c
+description: |-
618a7c
+    Limit the ciphers to those algorithms which are FIPS-approved.
618a7c
+    The following line in <tt>/etc/ssh/sshd_config</tt>
618a7c
+    demonstrates use of FIPS-approved ciphers:
618a7c
+    
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
618a7c
+    This rule ensures that there are configured ciphers mentioned
618a7c
+    above (or their subset), keeping the given order of algorithms.
618a7c
+
618a7c
+rationale: |-
618a7c
+    Unapproved mechanisms that are used for authentication to the cryptographic module are not verified and therefore
618a7c
+    cannot be relied upon to provide confidentiality or integrity, and system data may be compromised.
618a7c
+    
618a7c
+    Operating systems utilizing encryption are required to use FIPS-compliant mechanisms for authenticating to
618a7c
+    cryptographic modules.
618a7c
+    
618a7c
+    FIPS 140-2 is the current standard for validating that mechanisms used to access cryptographic modules
618a7c
+    utilize authentication that meets industry and government requirements. For government systems, this allows
618a7c
+    Security Levels 1, 2, 3, or 4 for use on {{{ full_name }}}.
618a7c
+
618a7c
+severity: medium
618a7c
+
618a7c
+identifiers:
618a7c
+    cce@rhel7: CCE-83398-8
618a7c
+
618a7c
+references:
618a7c
+    disa: CCI-000068,CCI-000366,CCI-000803,CCI-000877,CCI-002890,CCI-003123
618a7c
+    srg: SRG-OS-000033-GPOS-00014,SRG-OS-000120-GPOS-00061,SRG-OS-000125-GPOS-00065,SRG-OS-000250-GPOS-00093,SRG-OS-000393-GPOS-00173,SRG-OS-000394-GPOS-00174
618a7c
+    stigid@rhel7: RHEL-07-040110
618a7c
+
618a7c
+ocil_clause: 'FIPS ciphers are not configured or the enabled ciphers are not FIPS-approved'
618a7c
+
618a7c
+ocil: |-
618a7c
+    Only FIPS ciphers should be used. To verify that only FIPS-approved
618a7c
+    ciphers are in use, run the following command:
618a7c
+    
$ sudo grep Ciphers /etc/ssh/sshd_config
618a7c
+    The output should contain only following ciphers (or a subset) in the exact order:
618a7c
+    
aes256-ctr,aes192-ctr,aes128-ctr
618a7c
+
618a7c
+warnings:
618a7c
+    - general: |-
618a7c
+        The system needs to be rebooted for these changes to take effect.
618a7c
+    - regulatory: |-
618a7c
+        System Crypto Modules must be provided by a vendor that undergoes
618a7c
+        FIPS-140 certifications.
618a7c
+        FIPS-140 is applicable to all Federal agencies that use
618a7c
+        cryptographic-based security systems to protect sensitive information
618a7c
+        in computer and telecommunication systems (including voice systems) as
618a7c
+        defined in Section 5131 of the Information Technology Management Reform
618a7c
+        Act of 1996, Public Law 104-106. This standard shall be used in
618a7c
+        designing and implementing cryptographic modules that Federal
618a7c
+        departments and agencies operate or are operated for them under
618a7c
+        contract. See {{{ weblink(link="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf") }}}
618a7c
+        To meet this, the system has to have cryptographic software provided by
618a7c
+        a vendor that has undergone this certification. This means providing
618a7c
+        documentation, test results, design information, and independent third
618a7c
+        party review by an accredited lab. While open source software is
618a7c
+        capable of meeting this, it does not meet FIPS-140 unless the vendor
618a7c
+        submits to this process.
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/comment.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/comment.fail.sh
618a7c
new file mode 100644
618a7c
index 0000000000..daff7d7c53
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/comment.fail.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/# ciphers aes256-ctr,aes192-ctr,aes128-ctr/" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo "# ciphers aes256-ctr,aes192-ctr,aes128-ctr" >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_reduced_list.pass.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_reduced_list.pass.sh
618a7c
new file mode 100644
618a7c
index 0000000000..b9d22262af
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_reduced_list.pass.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/Ciphers aes192-ctr,aes128-ctr/" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo "Ciphers aes192-ctr,aes128-ctr" >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_scrambled.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_scrambled.fail.sh
618a7c
new file mode 100644
618a7c
index 0000000000..b99d3832cd
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_scrambled.fail.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/Ciphers aes128-ctr,aes192-ctr,aes256-ctr/" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr" >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_value.pass.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_value.pass.sh
618a7c
new file mode 100644
618a7c
index 0000000000..6dfd54631c
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_value.pass.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/ciphers aes256-ctr,aes192-ctr,aes128-ctr/" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo 'ciphers aes256-ctr,aes192-ctr,aes128-ctr' >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/line_not_there.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/line_not_there.fail.sh
618a7c
new file mode 100644
618a7c
index 0000000000..7b38914a1a
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/line_not_there.fail.sh
618a7c
@@ -0,0 +1,3 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+sed -i "/^Ciphers.*/d" /etc/ssh/sshd_config
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/no_parameters.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/no_parameters.fail.sh
618a7c
new file mode 100644
618a7c
index 0000000000..6fdb47093d
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/no_parameters.fail.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/Ciphers /" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo 'Ciphers ' >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/wrong_value.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/wrong_value.fail.sh
618a7c
new file mode 100644
618a7c
index 0000000000..24fdf0f30d
618a7c
--- /dev/null
618a7c
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/wrong_value.fail.sh
618a7c
@@ -0,0 +1,7 @@
618a7c
+#!/bin/bash
618a7c
+
618a7c
+if grep -q "^Ciphers" /etc/ssh/sshd_config; then
618a7c
+	sed -i "s/^Ciphers.*/ Ciphers aes128-ctr,aes192-ctr,weak-cipher,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,rijndael-cbc@lysator\.liu\.se/" /etc/ssh/sshd_config
618a7c
+else
618a7c
+	echo " Ciphers aes128-ctr,aes192-ctr,weak-cipher,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,rijndael-cbc@lysator\.liu\.se" >> /etc/ssh/sshd_config
618a7c
+fi
618a7c
diff --git a/rhel7/profiles/stig.profile b/rhel7/profiles/stig.profile
618a7c
index 6c06a8ede6..adf86894e1 100644
618a7c
--- a/rhel7/profiles/stig.profile
618a7c
+++ b/rhel7/profiles/stig.profile
618a7c
@@ -239,8 +239,7 @@ selections:
618a7c
     - install_antivirus
618a7c
     - accounts_max_concurrent_login_sessions
618a7c
     - configure_firewalld_ports
618a7c
-    - sshd_approved_ciphers=stig
618a7c
-    - sshd_use_approved_ciphers
618a7c
+    - sshd_use_approved_ciphers_ordered_stig
618a7c
     - accounts_tmout
618a7c
     - sshd_enable_warning_banner
618a7c
     - sssd_ldap_start_tls