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

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