Blame SOURCES/scap-security-guide-0.1.58-rhel8_stig_08_010290-PR_7151.patch

889f2b
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_macs_ordered_stig/rule.yml b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_macs_ordered_stig/rule.yml
889f2b
index 194d7dfe2dc..b6c5e7f4b0d 100644
889f2b
--- a/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_macs_ordered_stig/rule.yml
889f2b
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_use_approved_macs_ordered_stig/rule.yml
889f2b
@@ -37,7 +37,7 @@ ocil: |-
889f2b
     MACs are in use, run the following command:
889f2b
     
$ sudo grep -i macs /etc/ssh/sshd_config
889f2b
     The output should contain only following MACs (or a subset) in the exact order:
889f2b
-    
hmac-sha2-512,hmac-sha2-256
889f2b
+    
MACs {{{ xccdf_value("sshd_approved_macs") }}}
889f2b
 
889f2b
 warnings:
889f2b
     - general: |-
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/ansible/shared.yml
889f2b
new file mode 100644
889f2b
index 00000000000..1c9dde77ee2
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/ansible/shared.yml
889f2b
@@ -0,0 +1,16 @@
889f2b
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora
889f2b
+# reboot = true
889f2b
+# strategy = restrict
889f2b
+# complexity = low
889f2b
+# disruption = low
889f2b
+{{{ ansible_instantiate_variables("sshd_approved_macs") }}}
889f2b
+
889f2b
+{{{ ansible_set_config_file(
889f2b
+        msg='Configure SSH Daemon to Use FIPS 140-2 Validated MACs: openssh.config',
889f2b
+        file='/etc/crypto-policies/back-ends/openssh.config',
889f2b
+        parameter='MACs',
889f2b
+        value="{{ sshd_approved_macs }}",
889f2b
+        create='yes',
889f2b
+        prefix_regex='^.*'
889f2b
+    )
889f2b
+}}}
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/bash/shared.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/bash/shared.sh
889f2b
new file mode 100644
889f2b
index 00000000000..b26992ce183
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/bash/shared.sh
889f2b
@@ -0,0 +1,13 @@
889f2b
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora
889f2b
+. /usr/share/scap-security-guide/remediation_functions
889f2b
+{{{ bash_instantiate_variables("sshd_approved_macs") }}}
889f2b
+
889f2b
+{{{ set_config_file(
889f2b
+        path="/etc/crypto-policies/back-ends/openssh.config",
889f2b
+        parameter="MACs",
889f2b
+        value="${sshd_approved_macs}",
889f2b
+        create=true,
889f2b
+        insensitive=false,
889f2b
+        prefix_regex="^.*"
889f2b
+	)
889f2b
+}}}
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/oval/shared.xml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/oval/shared.xml
889f2b
new file mode 100644
889f2b
index 00000000000..5239af10612
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/oval/shared.xml
889f2b
@@ -0,0 +1,35 @@
889f2b
+{{%- set PATH = "/etc/crypto-policies/back-ends/openssh.config" -%}}
889f2b
+<def-group>
889f2b
+  <definition class="compliance" id="{{{ rule_id }}}" version="1">
889f2b
+    {{{ oval_metadata("Limit the Message Authentication Codes (MACs) to those which are FIPS-approved.") }}}
889f2b
+    <criteria operator="AND" comment="Test conditions - presence of the file plus.">
889f2b
+      <criterion comment="Check that {{{ PATH }}} contains FIPS-approved SSHD MACs" test_ref="test_{{{ rule_id }}}" />
889f2b
+    </criteria>
889f2b
+  </definition>
889f2b
+
889f2b
+  
889f2b
+  comment="test the value of MACs setting in the {{{ PATH }}} file"
889f2b
+  id="test_{{{ rule_id }}}" version="1">
889f2b
+    <ind:object object_ref="obj_{{{ rule_id }}}" />
889f2b
+    <ind:state state_ref="ste_{{{ rule_id }}}" />
889f2b
+  </ind:textfilecontent54_test>
889f2b
+
889f2b
+  <ind:textfilecontent54_object id="obj_{{{ rule_id }}}" version="1">
889f2b
+    <ind:filepath>{{{ PATH }}}</ind:filepath>
889f2b
+    <ind:pattern operation="pattern match">^MACs.*$</ind:pattern>
889f2b
+    <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
889f2b
+  </ind:textfilecontent54_object>
889f2b
+
889f2b
+  <ind:textfilecontent54_state id="ste_{{{ rule_id }}}" version="1">
889f2b
+    <ind:text var_ref="sshd_macs_crypto" operation="equals"></ind:text>
889f2b
+  </ind:textfilecontent54_state>
889f2b
+
889f2b
+  <local_variable id="sshd_macs_crypto" datatype="string" comment="The regex of the directive" version="1">
889f2b
+    <concat>
889f2b
+      <literal_component>MACs </literal_component>
889f2b
+      <variable_component var_ref="sshd_approved_macs"/>
889f2b
+    </concat>
889f2b
+  </local_variable>
889f2b
+
889f2b
+  <external_variable comment="SSH Approved MACs by FIPS" datatype="string" id="sshd_approved_macs" version="1" />
889f2b
+</def-group>
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/rule.yml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/rule.yml
889f2b
new file mode 100644
889f2b
index 00000000000..1aeb987db2d
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/rule.yml
889f2b
@@ -0,0 +1,60 @@
889f2b
+documentation_complete: true
889f2b
+
889f2b
+prodtype: fedora,rhel8
889f2b
+
889f2b
+title: 'Configure SSH Client to Use FIPS 140-2 Validated MACs: openssh.config'
889f2b
+
889f2b
+description: |-
889f2b
+    Crypto Policies provide a centralized control over crypto algorithms usage of many packages.
889f2b
+    OpenSSH is supported by system crypto policy, but the OpenSSH configuration may be
889f2b
+    set up incorrectly.
889f2b
+
889f2b
+    To check that Crypto Policies settings are configured correctly, ensure that
889f2b
+    <tt>/etc/crypto-policies/back-ends/openssh.config</tt> contains the following
889f2b
+    line and is not commented out:
889f2b
+    <tt>MACs hmac-sha2-512,hmac-sha2-256</tt>
889f2b
+
889f2b
+rationale: |-
889f2b
+    Overriding the system crypto policy makes the behavior of the OpenSSH
889f2b
+    client violate expectations, and makes system configuration more
889f2b
+    fragmented.
889f2b
+
889f2b
+severity: medium
889f2b
+
889f2b
+identifiers:
889f2b
+    cce@rhel8: CCE-85870-4
889f2b
+
889f2b
+references:
889f2b
+    disa: CCI-001453
889f2b
+    nist: AC-17(2)
889f2b
+    srg: SRG-OS-000250-GPOS-00093
889f2b
+    stigid@rhel8: RHEL-08-010290
889f2b
+
889f2b
+ocil_clause: 'Crypto Policy for OpenSSH client is not configured correctly'
889f2b
+
889f2b
+ocil: |-
889f2b
+    To verify if the OpenSSH client uses defined MACs in the Crypto Policy, run:
889f2b
+    
$ grep -i macs /etc/crypto-policies/back-ends/openssh.config
889f2b
+    and verify that the line matches:
889f2b
+    
MACs hmac-sha2-512,hmac-sha2-256
889f2b
+
889f2b
+warnings:
889f2b
+    - general: |-
889f2b
+        The system needs to be rebooted for these changes to take effect.
889f2b
+    - regulatory: |-
889f2b
+        System Crypto Modules must be provided by a vendor that undergoes
889f2b
+        FIPS-140 certifications.
889f2b
+        FIPS-140 is applicable to all Federal agencies that use
889f2b
+        cryptographic-based security systems to protect sensitive information
889f2b
+        in computer and telecommunication systems (including voice systems) as
889f2b
+        defined in Section 5131 of the Information Technology Management Reform
889f2b
+        Act of 1996, Public Law 104-106. This standard shall be used in
889f2b
+        designing and implementing cryptographic modules that Federal
889f2b
+        departments and agencies operate or are operated for them under
889f2b
+        contract. See {{{ weblink(link="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf") }}}
889f2b
+        To meet this, the system has to have cryptographic software provided by
889f2b
+        a vendor that has undergone this certification. This means providing
889f2b
+        documentation, test results, design information, and independent third
889f2b
+        party review by an accredited lab. While open source software is
889f2b
+        capable of meeting this, it does not meet FIPS-140 unless the vendor
889f2b
+        submits to this process.
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct.pass.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct.pass.sh
889f2b
new file mode 100644
889f2b
index 00000000000..5a4b6887cba
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct.pass.sh
889f2b
@@ -0,0 +1,15 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+sshd_approved_macs=hmac-sha2-512,hmac-sha2-256
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/MACs ${sshd_approved_macs}/" $configfile
889f2b
+else
889f2b
+    echo "MACs ${sshd_approved_macs}" > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_commented.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_commented.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..e713d254f9c
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_commented.fail.sh
889f2b
@@ -0,0 +1,15 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+sshd_approved_macs=hmac-sha2-512,hmac-sha2-256
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/#MACs ${sshd_approved_macs}/" $configfile
889f2b
+else
889f2b
+    echo "#MACs ${sshd_approved_macs}" > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_followed_by_incorrect_commented.pass.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_followed_by_incorrect_commented.pass.sh
889f2b
new file mode 100644
889f2b
index 00000000000..b8a63bec194
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_correct_followed_by_incorrect_commented.pass.sh
889f2b
@@ -0,0 +1,18 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+sshd_approved_macs=hmac-sha2-512,hmac-sha2-256
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/MACs ${sshd_approved_macs}/" $configfile
889f2b
+else
889f2b
+    echo "MACs ${sshd_approved_macs}" > "$configfile"
889f2b
+fi
889f2b
+
889f2b
+# follow up with incorrect
889f2b
+echo "#MACs hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512" >> $configfile
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_file.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_file.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..55ef3f58422
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_file.fail.sh
889f2b
@@ -0,0 +1,10 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+echo "" > $configfile
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_policy.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_policy.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..9980a45681c
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_empty_policy.fail.sh
889f2b
@@ -0,0 +1,14 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/MACs /" $configfile
889f2b
+else
889f2b
+    echo "MACs " > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_followed_by_correct_commented.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_followed_by_correct_commented.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..d1303d60746
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_followed_by_correct_commented.fail.sh
889f2b
@@ -0,0 +1,19 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+sshd_approved_macs=hmac-sha2-512,hmac-sha2-256
889f2b
+incorrect_sshd_approved_macs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/MACs ${incorrect_sshd_approved_macs}/" $configfile
889f2b
+else
889f2b
+    echo "MACs ${incorrect_sshd_approved_macs}" > "$configfile"
889f2b
+fi
889f2b
+
889f2b
+# follow up with correct value
889f2b
+echo "MACs ${sshd_approved_macs}" >> $configfile
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_policy.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_policy.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..8b21af46896
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_incorrect_policy.fail.sh
889f2b
@@ -0,0 +1,14 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i "s/^.*MACs.*$/MACs hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512/" $configfile
889f2b
+else
889f2b
+    echo "MACs hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512" > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_missing_file.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_missing_file.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..2138caad319
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_openssh_conf_crypto_policy/tests/stig_missing_file.fail.sh
889f2b
@@ -0,0 +1,11 @@
889f2b
+#!/bin/bash
889f2b
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/openssh.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+# If file exists, remove it
889f2b
+test -f $configfile && rm -f $configfile
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/ansible/shared.yml
889f2b
new file mode 100644
889f2b
index 00000000000..5ed618586ae
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/ansible/shared.yml
889f2b
@@ -0,0 +1,45 @@
889f2b
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora
889f2b
+# reboot = true
889f2b
+# strategy = restrict
889f2b
+# complexity = low
889f2b
+# disruption = low
889f2b
+{{{ ansible_instantiate_variables("sshd_approved_macs") }}}
889f2b
+
889f2b
+- name: "{{{ rule_title }}}: Set facts"
889f2b
+  set_fact:
889f2b
+    path: /etc/crypto-policies/back-ends/opensshserver.config
889f2b
+    correct_value: "-oMACs={{ sshd_approved_macs }}"
889f2b
+
889f2b
+- name: "{{{ rule_title }}}: Stat"
889f2b
+  stat:
889f2b
+    path: "{{ path }}"
889f2b
+    follow: yes
889f2b
+  register: opensshserver_file
889f2b
+
889f2b
+- name: "{{{ rule_title }}}: Create"
889f2b
+  lineinfile:
889f2b
+    path: "{{ path }}"
889f2b
+    line: "CRYPTO_POLICY='{{ correct_value }}'"
889f2b
+    create: yes
889f2b
+  when: not opensshserver_file.stat.exists or opensshserver_file.stat.size <= correct_value|length
889f2b
+
889f2b
+- name: "{{{ rule_title }}}"
889f2b
+  block:
889f2b
+    - name: "Existing value check"
889f2b
+      lineinfile:
889f2b
+        path: "{{ path }}"
889f2b
+        create: false
889f2b
+        regexp: "{{ correct_value }}"
889f2b
+        state: absent
889f2b
+      check_mode: true
889f2b
+      changed_when: false
889f2b
+      register: opensshserver
889f2b
+
889f2b
+    - name: "Update/Correct value"
889f2b
+      replace:
889f2b
+        path: "{{ path }}"
889f2b
+        regexp: (-oMACs=\S+)
889f2b
+        replace: "{{ correct_value }}"
889f2b
+      when: opensshserver.found is defined and opensshserver.found != 1
889f2b
+
889f2b
+  when: opensshserver_file.stat.exists and opensshserver_file.stat.size > correct_value|length
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/bash/shared.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/bash/shared.sh
889f2b
new file mode 100644
889f2b
index 00000000000..790a2951bab
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/bash/shared.sh
889f2b
@@ -0,0 +1,31 @@
889f2b
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora
889f2b
+. /usr/share/scap-security-guide/remediation_functions
889f2b
+{{{ bash_instantiate_variables("sshd_approved_macs") }}}
889f2b
+
889f2b
+CONF_FILE=/etc/crypto-policies/back-ends/opensshserver.config
889f2b
+correct_value="-oMACs=${sshd_approved_macs}"
889f2b
+
889f2b
+# Test if file exists
889f2b
+test -f ${CONF_FILE} || touch ${CONF_FILE}
889f2b
+
889f2b
+# Ensure CRYPTO_POLICY is not commented out
889f2b
+sed -i 's/#CRYPTO_POLICY=/CRYPTO_POLICY=/' ${CONF_FILE}
889f2b
+
889f2b
+grep -q "'${correct_value}'" ${CONF_FILE}
889f2b
+
889f2b
+if [[ $? -ne 0 ]]; then
889f2b
+    # We need to get the existing value, using PCRE to maintain same regex
889f2b
+    existing_value=$(grep -Po '(-oMACs=\S+)' ${CONF_FILE})
889f2b
+
889f2b
+    if [[ ! -z ${existing_value} ]]; then
889f2b
+        # replace existing_value with correct_value
889f2b
+        sed -i "s/${existing_value}/${correct_value}/g" ${CONF_FILE}
889f2b
+    else
889f2b
+        # ***NOTE*** #
889f2b
+        # This probably means this file is not here or it's been modified
889f2b
+        # unintentionally.
889f2b
+        # ********** #
889f2b
+        # echo correct_value to end
889f2b
+        echo "CRYPTO_POLICY='${correct_value}'" >> ${CONF_FILE}
889f2b
+    fi
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/oval/shared.xml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/oval/shared.xml
889f2b
new file mode 100644
889f2b
index 00000000000..18028157032
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/oval/shared.xml
889f2b
@@ -0,0 +1,35 @@
889f2b
+{{%- set PATH = "/etc/crypto-policies/back-ends/opensshserver.config" -%}}
889f2b
+<def-group>
889f2b
+  <definition class="compliance" id="{{{ rule_id }}}" version="1">
889f2b
+    {{{ oval_metadata("Limit the Message Authentication Codes (MACs) to those which are FIPS-approved.") }}}
889f2b
+    <criteria operator="AND" comment="Test conditions - presence of the file plus.">
889f2b
+      <criterion comment="Check that {{{ PATH }}} contains FIPS-approved SSHD MACs" test_ref="test_{{{ rule_id }}}" />
889f2b
+    </criteria>
889f2b
+  </definition>
889f2b
+
889f2b
+  
889f2b
+  comment="test the value of MACs setting in the {{{ PATH }}} file"
889f2b
+  id="test_{{{ rule_id }}}" version="1">
889f2b
+    <ind:object object_ref="obj_{{{ rule_id }}}" />
889f2b
+    <ind:state state_ref="ste_{{{ rule_id }}}" />
889f2b
+  </ind:textfilecontent54_test>
889f2b
+
889f2b
+  <ind:textfilecontent54_object id="obj_{{{ rule_id }}}" version="1">
889f2b
+    <ind:filepath>{{{ PATH }}}</ind:filepath>
889f2b
+    <ind:pattern operation="pattern match">^(?!#).*(-oMACs=\S+).+$</ind:pattern>
889f2b
+    <ind:instance operation="equals" datatype="int">1</ind:instance>
889f2b
+  </ind:textfilecontent54_object>
889f2b
+
889f2b
+  <ind:textfilecontent54_state id="ste_{{{ rule_id }}}" version="1">
889f2b
+    <ind:subexpression var_ref="sshd_macs_crypto_opensshserver" operation="equals" />
889f2b
+  </ind:textfilecontent54_state>
889f2b
+
889f2b
+  <local_variable id="sshd_macs_crypto_opensshserver" datatype="string" comment="The regex of the directive" version="1">
889f2b
+    <concat>
889f2b
+      <literal_component>-oMACs=</literal_component>
889f2b
+      <variable_component var_ref="sshd_approved_macs"/>
889f2b
+    </concat>
889f2b
+  </local_variable>
889f2b
+
889f2b
+  <external_variable comment="SSH Approved MACs by FIPS" datatype="string" id="sshd_approved_macs" version="1" />
889f2b
+</def-group>
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/rule.yml b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/rule.yml
889f2b
new file mode 100644
889f2b
index 00000000000..0fd107a1bbe
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/rule.yml
889f2b
@@ -0,0 +1,60 @@
889f2b
+documentation_complete: true
889f2b
+
889f2b
+prodtype: rhel8
889f2b
+
889f2b
+title: 'Configure SSH Server to Use FIPS 140-2 Validated MACs: opensshserver.config'
889f2b
+
889f2b
+description: |-
889f2b
+    Crypto Policies provide a centralized control over crypto algorithms usage of many packages.
889f2b
+    OpenSSH is supported by system crypto policy, but the OpenSSH configuration may be
889f2b
+    set up incorrectly.
889f2b
+
889f2b
+    To check that Crypto Policies settings are configured correctly, ensure that
889f2b
+    <tt>/etc/crypto-policies/back-ends/opensshserver.config</tt> contains the following
889f2b
+    text and is not commented out:
889f2b
+    <tt>-oMACS=hmac-sha2-512,hmac-sha2-256</tt>
889f2b
+
889f2b
+rationale: |-
889f2b
+    Overriding the system crypto policy makes the behavior of the OpenSSH
889f2b
+    server violate expectations, and makes system configuration more
889f2b
+    fragmented.
889f2b
+
889f2b
+severity: medium
889f2b
+
889f2b
+identifiers:
889f2b
+    cce@rhel8: CCE-85899-3
889f2b
+
889f2b
+references:
889f2b
+    disa: CCI-001453
889f2b
+    nist: AC-17(2)
889f2b
+    srg: SRG-OS-000250-GPOS-00093
889f2b
+    stigid@rhel8: RHEL-08-010290
889f2b
+
889f2b
+ocil_clause: 'Crypto Policy for OpenSSH Server is not configured correctly'
889f2b
+
889f2b
+ocil: |-
889f2b
+    To verify if the OpenSSH server uses defined MACs in the Crypto Policy, run:
889f2b
+    
$ grep -Po '(-oMACs=\S+)' /etc/crypto-policies/back-ends/opensshserver.config
889f2b
+    and verify that the line matches:
889f2b
+    
-oMACS=hmac-sha2-512,hmac-sha2-256
889f2b
+
889f2b
+warnings:
889f2b
+    - general: |-
889f2b
+        The system needs to be rebooted for these changes to take effect.
889f2b
+    - regulatory: |-
889f2b
+        System Crypto Modules must be provided by a vendor that undergoes
889f2b
+        FIPS-140 certifications.
889f2b
+        FIPS-140 is applicable to all Federal agencies that use
889f2b
+        cryptographic-based security systems to protect sensitive information
889f2b
+        in computer and telecommunication systems (including voice systems) as
889f2b
+        defined in Section 5131 of the Information Technology Management Reform
889f2b
+        Act of 1996, Public Law 104-106. This standard shall be used in
889f2b
+        designing and implementing cryptographic modules that Federal
889f2b
+        departments and agencies operate or are operated for them under
889f2b
+        contract. See {{{ weblink(link="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf") }}}
889f2b
+        To meet this, the system has to have cryptographic software provided by
889f2b
+        a vendor that has undergone this certification. This means providing
889f2b
+        documentation, test results, design information, and independent third
889f2b
+        party review by an accredited lab. While open source software is
889f2b
+        capable of meeting this, it does not meet FIPS-140 unless the vendor
889f2b
+        submits to this process.
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_correct.pass.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_correct.pass.sh
889f2b
new file mode 100644
889f2b
index 00000000000..14da92218dc
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_correct.pass.sh
889f2b
@@ -0,0 +1,17 @@
889f2b
+#!/bin/bash
889f2b
+# platform = Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+sshd_approved_macs=hmac-sha2-512,hmac-sha2-256
889f2b
+configfile=/etc/crypto-policies/back-ends/opensshserver.config
889f2b
+correct_value="-oMACs=${sshd_approved_macs}"
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+# Proceed when file exists
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i -r "s/-oMACs=\S+/${correct_value}/" $configfile
889f2b
+else
889f2b
+    echo "${correct_value}" > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_empty_policy.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_empty_policy.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..3dde1479296
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_empty_policy.fail.sh
889f2b
@@ -0,0 +1,7 @@
889f2b
+#!/bin/bash
889f2b
+# platform = Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/opensshserver.config
889f2b
+
889f2b
+echo "" > "$configfile"
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_incorrect_policy.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_incorrect_policy.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..a50a0fc02bf
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_incorrect_policy.fail.sh
889f2b
@@ -0,0 +1,14 @@
889f2b
+#!/bin/bash
889f2b
+# platform = Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/opensshserver.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+if [[ -f $configfile ]]; then
889f2b
+    sed -i -r "s/-oMACs=\S+/-oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com/" $configfile
889f2b
+else
889f2b
+    echo "-oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com" > "$configfile"
889f2b
+fi
889f2b
diff --git a/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_missing_file.fail.sh b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_missing_file.fail.sh
889f2b
new file mode 100644
889f2b
index 00000000000..11e596ced87
889f2b
--- /dev/null
889f2b
+++ b/linux_os/guide/system/software/integrity/crypto/harden_sshd_macs_opensshserver_conf_crypto_policy/tests/rhel8_stig_missing_file.fail.sh
889f2b
@@ -0,0 +1,11 @@
889f2b
+#!/bin/bash
889f2b
+# platform = Red Hat Enterprise Linux 8
889f2b
+# profiles = xccdf_org.ssgproject.content_profile_stig
889f2b
+
889f2b
+configfile=/etc/crypto-policies/back-ends/opensshserver.config
889f2b
+
889f2b
+# Ensure directory + file is there
889f2b
+test -d /etc/crypto-policies/back-ends || mkdir -p /etc/crypto-policies/back-ends
889f2b
+
889f2b
+# If file exists, remove it
889f2b
+test -f $configfile && rm -f $configfile
889f2b
diff --git a/products/rhel8/profiles/stig.profile b/products/rhel8/profiles/stig.profile
889f2b
index 6372d13cfc9..28b47cca487 100644
889f2b
--- a/products/rhel8/profiles/stig.profile
889f2b
+++ b/products/rhel8/profiles/stig.profile
889f2b
@@ -50,6 +50,7 @@ selections:
889f2b
     - var_password_pam_retry=3
889f2b
     - var_password_pam_minlen=15
889f2b
     - var_sshd_set_keepalive=0
889f2b
+    - sshd_approved_macs=stig
889f2b
     - sshd_idle_timeout_value=10_minutes
889f2b
     - var_accounts_passwords_pam_faillock_deny=3
889f2b
     - var_accounts_passwords_pam_faillock_fail_interval=900
889f2b
@@ -174,11 +175,17 @@ selections:
889f2b
     # RHEL-08-010260
889f2b
     - file_groupowner_var_log
889f2b
 
889f2b
+    # *** SHARED *** #
889f2b
     # RHEL-08-010290 && RHEL-08-010291
889f2b
-    ### NOTE: This will get split out in future STIG releases, as well as we will break
889f2b
-    ### these rules up to be more flexible in meeting the requirements.
889f2b
+    # *** SHARED *** #
889f2b
     - configure_ssh_crypto_policy
889f2b
 
889f2b
+    # RHEL-08-010290
889f2b
+    - harden_sshd_macs_openssh_conf_crypto_policy
889f2b
+    - harden_sshd_macs_opensshserver_conf_crypto_policy
889f2b
+
889f2b
+    # RHEL-08-010291
889f2b
+
889f2b
     # RHEL-08-010292
889f2b
     - sshd_use_strong_rng
889f2b
 
889f2b
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
889f2b
index 24e81491683..036d34cea1d 100644
889f2b
--- a/shared/references/cce-redhat-avail.txt
889f2b
+++ b/shared/references/cce-redhat-avail.txt
889f2b
@@ -10,7 +10,6 @@ CCE-85866-2
889f2b
 CCE-85867-0
889f2b
 CCE-85868-8
889f2b
 CCE-85869-6
889f2b
-CCE-85870-4
889f2b
 CCE-85872-0
889f2b
 CCE-85873-8
889f2b
 CCE-85874-6
889f2b
@@ -36,7 +35,6 @@ CCE-85895-1
889f2b
 CCE-85896-9
889f2b
 CCE-85897-7
889f2b
 CCE-85898-5
889f2b
-CCE-85899-3
889f2b
 CCE-85900-9
889f2b
 CCE-85901-7
889f2b
 CCE-85902-5
889f2b
diff --git a/tests/data/profile_stability/rhel8/stig.profile b/tests/data/profile_stability/rhel8/stig.profile
889f2b
index 32f1a24a7a4..393051a34ea 100644
889f2b
--- a/tests/data/profile_stability/rhel8/stig.profile
889f2b
+++ b/tests/data/profile_stability/rhel8/stig.profile
889f2b
@@ -145,6 +145,8 @@ selections:
889f2b
 - grub2_uefi_admin_username
889f2b
 - grub2_uefi_password
889f2b
 - grub2_vsyscall_argument
889f2b
+- harden_sshd_macs_openssh_conf_crypto_policy
889f2b
+- harden_sshd_macs_opensshserver_conf_crypto_policy
889f2b
 - install_smartcard_packages
889f2b
 - installed_OS_is_vendor_supported
889f2b
 - kerberos_disable_no_keytab
889f2b
@@ -325,6 +327,7 @@ selections:
889f2b
 - var_password_pam_lcredit=1
889f2b
 - var_password_pam_retry=3
889f2b
 - var_sshd_set_keepalive=0
889f2b
+- sshd_approved_macs=stig
889f2b
 - sshd_idle_timeout_value=10_minutes
889f2b
 - var_accounts_passwords_pam_faillock_deny=3
889f2b
 - var_accounts_passwords_pam_faillock_fail_interval=900
889f2b
diff --git a/tests/data/profile_stability/rhel8/stig_gui.profile b/tests/data/profile_stability/rhel8/stig_gui.profile
889f2b
index d6a27c67dc0..de82fb34518 100644
889f2b
--- a/tests/data/profile_stability/rhel8/stig_gui.profile
889f2b
+++ b/tests/data/profile_stability/rhel8/stig_gui.profile
889f2b
@@ -156,6 +156,8 @@ selections:
889f2b
 - grub2_uefi_admin_username
889f2b
 - grub2_uefi_password
889f2b
 - grub2_vsyscall_argument
889f2b
+- harden_sshd_macs_openssh_conf_crypto_policy
889f2b
+- harden_sshd_macs_opensshserver_conf_crypto_policy
889f2b
 - install_smartcard_packages
889f2b
 - installed_OS_is_vendor_supported
889f2b
 - kerberos_disable_no_keytab
889f2b
@@ -335,6 +337,7 @@ selections:
889f2b
 - var_password_pam_lcredit=1
889f2b
 - var_password_pam_retry=3
889f2b
 - var_sshd_set_keepalive=0
889f2b
+- sshd_approved_macs=stig
889f2b
 - sshd_idle_timeout_value=10_minutes
889f2b
 - var_accounts_passwords_pam_faillock_deny=3
889f2b
 - var_accounts_passwords_pam_faillock_fail_interval=900