Blame SOURCES/scap-security-guide-0.1.49-openssl-strong-entropy-wrap.patch

54c0d5
From e0f1e2096d0f33fa94e3f78a5038e929b0039c32 Mon Sep 17 00:00:00 2001
54c0d5
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
54c0d5
Date: Mon, 27 Jan 2020 11:51:53 +0100
54c0d5
Subject: [PATCH 1/6] Add a rule for the openssl strong entropy wrapper.
54c0d5
54c0d5
---
54c0d5
 .../openssl_use_strong_entropy/rule.yml       | 65 +++++++++++++++++++
54c0d5
 rhel8/profiles/ospp.profile                   |  1 +
54c0d5
 shared/references/cce-redhat-avail.txt        |  1 -
54c0d5
 3 files changed, 66 insertions(+), 1 deletion(-)
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
new file mode 100644
54c0d5
index 0000000000..e9ea8ed338
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
@@ -0,0 +1,65 @@
54c0d5
+documentation_complete: true
54c0d5
+
54c0d5
+# TODO: The plan is not to need this for RHEL>=8.4
54c0d5
+prodtype: rhel8
54c0d5
+
54c0d5
+title: 'OpenSSL uses strong entropy source'
54c0d5
+
54c0d5
+description: |-
54c0d5
+    To set up an <tt>openssl</tt> wrapper that adds a <tt>-rand /dev/random</tt> option to the <tt>openssl</tt> invocation,
54c0d5
+    save the following shell snippet to the <tt>/etc/profile.d/cc-config.sh</tt>:
54c0d5
+    
54c0d5
+    # provide a default -rand /dev/random option to openssl commands that
54c0d5
+    # support it
54c0d5
+
54c0d5
+    # written inefficiently for maximum shell compatibility
54c0d5
+    openssl()
54c0d5
+    (
54c0d5
+      openssl_bin=/usr/bin/openssl
54c0d5
+
54c0d5
+      case "$*" in
54c0d5
+        # if user specified -rand, honor it
54c0d5
+        *\ -rand\ *|*\ -help*) exec $openssl_bin "$@" ;;
54c0d5
+      esac
54c0d5
+
54c0d5
+      cmds=`$openssl_bin list -digest-commands -cipher-commands | tr '\n' ' '`
54c0d5
+      for i in `$openssl_bin list -commands`; do
54c0d5
+        if $openssl_bin list -options "$i" | grep -q '^rand '; then
54c0d5
+          cmds=" $i $cmds"
54c0d5
+        fi
54c0d5
+      done
54c0d5
+
54c0d5
+      case "$cmds" in
54c0d5
+        *\ "$1"\ *)
54c0d5
+          cmd="$1"; shift
54c0d5
+          exec $openssl_bin "$cmd" -rand /dev/random "$@" ;;
54c0d5
+      esac
54c0d5
+
54c0d5
+      exec $openssl_bin "$@"
54c0d5
+    )
54c0d5
+    
54c0d5
+
54c0d5
+rationale: |-
54c0d5
+    The <tt>openssl</tt> default configuration uses less robust entropy sources for seeding.
54c0d5
+    The referenced script is sourced to every login shell, and it transparently adds an option
54c0d5
+    that enforces strong entropy to every <tt>openssl</tt> invocation,
54c0d5
+    which makes <tt>openssl</tt> more secure by default.
54c0d5
+
54c0d5
+severity: medium
54c0d5
+
54c0d5
+identifiers:
54c0d5
+    cce@rhel8: 82721-2
54c0d5
+
54c0d5
+references:
54c0d5
+    ospp: FIA_AFL.1
54c0d5
+
54c0d5
+ocil: |-
54c0d5
+    To determine whether the <tt>openssl</tt> wrapper is configured correcrlty,
54c0d5
+    make sure that the <tt>/etc/profile.d/cc-config.sh</tt> file contains contents
54c0d5
+    that are included in the rule's description.
54c0d5
+
54c0d5
+ocil_clause: |-
54c0d5
+    there is no <tt>/etc/profile.d/cc-config.sh</tt> file, or its contents don't match those in the description
54c0d5
+
54c0d5
+warnings:
54c0d5
+    - general: "This setting can cause problems on computers without the hardware random generator, because insufficient entropy blocks the program until enough entropy is available."
54c0d5
diff --git a/rhel8/profiles/ospp.profile b/rhel8/profiles/ospp.profile
54c0d5
index 63aea526b7..ef3ced5010 100644
54c0d5
--- a/rhel8/profiles/ospp.profile
54c0d5
+++ b/rhel8/profiles/ospp.profile
54c0d5
@@ -59,6 +59,7 @@ selections:
54c0d5
     - sshd_enable_warning_banner
54c0d5
     - sshd_rekey_limit
54c0d5
     - sshd_use_strong_rng
54c0d5
+    - openssl_use_strong_entropy
54c0d5
 
54c0d5
     # Time Server
54c0d5
     - chronyd_client_only
54c0d5
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
54c0d5
index 4cb08794f4..1733872dfa 100644
54c0d5
--- a/shared/references/cce-redhat-avail.txt
54c0d5
+++ b/shared/references/cce-redhat-avail.txt
54c0d5
@@ -248,6 +248,5 @@
54c0d5
 CCE-82719-6
54c0d5
 CCE-82720-4
54c0d5
-CCE-82721-2
54c0d5
 CCE-82722-0
54c0d5
 CCE-82723-8
54c0d5
 CCE-82724-6
54c0d5
54c0d5
From bbd0f8b1234858a4abeece07d7d188bb07d3d077 Mon Sep 17 00:00:00 2001
54c0d5
From: Vojtech Polasek <vpolasek@redhat.com>
54c0d5
Date: Mon, 27 Jan 2020 19:35:06 +0100
54c0d5
Subject: [PATCH 2/6] create checks, remediations,
54c0d5
54c0d5
---
54c0d5
 .../ansible/shared.yml                        | 12 +++++++
54c0d5
 .../openssl_use_strong_entropy/bash/shared.sh |  5 +++
54c0d5
 .../oval/shared.xml                           | 34 +++++++++++++++++++
54c0d5
 .../openssl_use_strong_entropy/rule.yml       | 29 +---------------
54c0d5
 shared/macros.jinja                           | 34 ++++++++++++++++++-
54c0d5
 5 files changed, 85 insertions(+), 29 deletions(-)
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
new file mode 100644
54c0d5
index 0000000000..3ce26d6525
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
@@ -0,0 +1,12 @@
54c0d5
+# platform = multi_platform_all
54c0d5
+# reboot = false
54c0d5
+# strategy = restrict
54c0d5
+# complexity = low
54c0d5
+# disruption = low
54c0d5
+
54c0d5
+- name: "copy a file with shell snippet to configure openssl strong entropy"
54c0d5
+  copy:
54c0d5
+    dest: /etc/profile.d/cc-config.sh
54c0d5
+    content: |+
54c0d5
+        {{{ openssl_strong_entropy_config_file()|indent(8,blank=True) }}}
54c0d5
+        
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
new file mode 100644
54c0d5
index 0000000000..db5c331ce7
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
@@ -0,0 +1,5 @@
54c0d5
+# platform = Red Hat Enterprise Linux 8
54c0d5
+
54c0d5
+cat > /etc/profile.d/cc-config.sh <<- 'EOM'
54c0d5
+{{{ openssl_strong_entropy_config_file() }}}
54c0d5
+EOM
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
new file mode 100644
54c0d5
index 0000000000..b441b7ae6e
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
@@ -0,0 +1,34 @@
54c0d5
+<def-group>
54c0d5
+  <definition class="compliance" id="openssl_use_strong_entropy" version="1">
54c0d5
+    <metadata>
54c0d5
+      <title>Configure Openssl to use strong entropy</title>
54c0d5
+      <affected family="unix">
54c0d5
+        <platform>Red Hat Enterprise Linux 8</platform>
54c0d5
+        <platform>multi_platform_fedora</platform>
54c0d5
+      </affected>
54c0d5
+      <description>OpenSSL should be configured to generate random data with strong entropy.</description>
54c0d5
+    </metadata>
54c0d5
+    <criteria>
54c0d5
+      
54c0d5
+      comment="Check that the OpenSSL is configured to generate random data with strong entropy." />
54c0d5
+    </criteria>
54c0d5
+  </definition>
54c0d5
+
54c0d5
+  
54c0d5
+  comment="Test if openssl is configured to generate random data with strong entropy" version="1"
54c0d5
+  check="all" check_existence="all_exist">
54c0d5
+    <ind:object object_ref="object_openssl_strong_entropy"/>
54c0d5
+    <ind:state state_ref="state_openssl_strong_entropy"/>
54c0d5
+  </ind:filehash58_test>
54c0d5
+
54c0d5
+  <ind:filehash58_object id="object_openssl_strong_entropy" version="1">
54c0d5
+    <ind:filepath>/etc/profile.d/cc-config.sh</ind:filepath>
54c0d5
+    <ind:hash_type>SHA-256</ind:hash_type>
54c0d5
+  </ind:filehash58_object>
54c0d5
+
54c0d5
+  <ind:filehash58_state id="state_openssl_strong_entropy" version="1">
54c0d5
+    <ind:filepath>/etc/profile.d/cc-config.sh</ind:filepath>
54c0d5
+    <ind:hash_type>SHA-256</ind:hash_type>
54c0d5
+    <ind:hash>6488c757642cd493da09dd78ee27f039711a1ad79039900970553772fd2106af</ind:hash>
54c0d5
+  </ind:filehash58_state>
54c0d5
+</def-group>
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
index e9ea8ed338..3b01da01af 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
@@ -9,34 +9,7 @@ description: |-
54c0d5
     To set up an <tt>openssl</tt> wrapper that adds a <tt>-rand /dev/random</tt> option to the <tt>openssl</tt> invocation,
54c0d5
     save the following shell snippet to the <tt>/etc/profile.d/cc-config.sh</tt>:
54c0d5
     
54c0d5
-    # provide a default -rand /dev/random option to openssl commands that
54c0d5
-    # support it
54c0d5
-
54c0d5
-    # written inefficiently for maximum shell compatibility
54c0d5
-    openssl()
54c0d5
-    (
54c0d5
-      openssl_bin=/usr/bin/openssl
54c0d5
-
54c0d5
-      case "$*" in
54c0d5
-        # if user specified -rand, honor it
54c0d5
-        *\ -rand\ *|*\ -help*) exec $openssl_bin "$@" ;;
54c0d5
-      esac
54c0d5
-
54c0d5
-      cmds=`$openssl_bin list -digest-commands -cipher-commands | tr '\n' ' '`
54c0d5
-      for i in `$openssl_bin list -commands`; do
54c0d5
-        if $openssl_bin list -options "$i" | grep -q '^rand '; then
54c0d5
-          cmds=" $i $cmds"
54c0d5
-        fi
54c0d5
-      done
54c0d5
-
54c0d5
-      case "$cmds" in
54c0d5
-        *\ "$1"\ *)
54c0d5
-          cmd="$1"; shift
54c0d5
-          exec $openssl_bin "$cmd" -rand /dev/random "$@" ;;
54c0d5
-      esac
54c0d5
-
54c0d5
-      exec $openssl_bin "$@"
54c0d5
-    )
54c0d5
+    {{{ openssl_strong_entropy_config_file() | indent(4) }}}
54c0d5
     
54c0d5
 
54c0d5
 rationale: |-
54c0d5
diff --git a/shared/macros.jinja b/shared/macros.jinja
54c0d5
index 77f8eb31c7..8a25acc937 100644
54c0d5
--- a/shared/macros.jinja
54c0d5
+++ b/shared/macros.jinja
54c0d5
@@ -618,10 +618,42 @@ ocil_clause: "the correct value is not returned"
54c0d5
 
54c0d5
 
54c0d5
 {{% macro body_of_warning_about_dependent_rule(rule_id, why) -%}}
54c0d5
-        When selecting this rule in a profile, 
54c0d5
+        When selecting this rule in a profile,
54c0d5
         {{%- if why %}}
54c0d5
             make sure that rule with ID {{{ rule_id }}} is selected as well: {{{ why }}}
54c0d5
         {{%- else %}}
54c0d5
             rule {{{ rule_id }}} has to be selected as well.
54c0d5
         {{%- endif %}}
54c0d5
 {{% endmacro %}}
54c0d5
+
54c0d5
+{{% macro openssl_strong_entropy_config_file() -%}}
54c0d5
+# provide a default -rand /dev/random option to openssl commands that
54c0d5
+# support it
54c0d5
+
54c0d5
+# written inefficiently for maximum shell compatibility
54c0d5
+openssl()
54c0d5
+(
54c0d5
+  openssl_bin=/usr/bin/openssl
54c0d5
+
54c0d5
+  case "$*" in
54c0d5
+    # if user specified -rand, honor it
54c0d5
+    *\ -rand\ *|*\ -help*) exec $openssl_bin "$@" ;;
54c0d5
+  esac
54c0d5
+
54c0d5
+  cmds=`$openssl_bin list -digest-commands -cipher-commands | tr '\n' ' '`
54c0d5
+  for i in `$openssl_bin list -commands`; do
54c0d5
+    if $openssl_bin list -options "$i" | grep -q '^rand '; then
54c0d5
+      cmds=" $i $cmds"
54c0d5
+    fi
54c0d5
+  done
54c0d5
+
54c0d5
+  case "$cmds" in
54c0d5
+    *\ "$1"\ *)
54c0d5
+      cmd="$1"; shift
54c0d5
+      exec $openssl_bin "$cmd" -rand /dev/random "$@" ;;
54c0d5
+  esac
54c0d5
+
54c0d5
+  exec $openssl_bin "$@"
54c0d5
+)
54c0d5
+
54c0d5
+{{%- endmacro %}}
54c0d5
54c0d5
From efaa2c9cbbe09af6b319f487ec05f646290a05a1 Mon Sep 17 00:00:00 2001
54c0d5
From: Vojtech Polasek <vpolasek@redhat.com>
54c0d5
Date: Tue, 28 Jan 2020 13:42:40 +0100
54c0d5
Subject: [PATCH 3/6] add tests
54c0d5
54c0d5
---
54c0d5
 .../tests/correct.pass.sh                     | 34 +++++++++++++++++++
54c0d5
 .../tests/file_missing.fail.sh                |  5 +++
54c0d5
 .../tests/file_modified.fail.sh               |  5 +++
54c0d5
 3 files changed, 44 insertions(+)
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
 create mode 100644 linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
new file mode 100644
54c0d5
index 0000000000..0bffab3c81
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
@@ -0,0 +1,34 @@
54c0d5
+#!/bin/bash
54c0d5
+# platform = Red Hat Enterprise Linux 8
54c0d5
+# profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
+
54c0d5
+cat > /etc/profile.d/cc-config.sh <<- 'EOM'
54c0d5
+# provide a default -rand /dev/random option to openssl commands that
54c0d5
+# support it
54c0d5
+
54c0d5
+# written inefficiently for maximum shell compatibility
54c0d5
+openssl()
54c0d5
+(
54c0d5
+  openssl_bin=/usr/bin/openssl
54c0d5
+
54c0d5
+  case "$*" in
54c0d5
+    # if user specified -rand, honor it
54c0d5
+    *\ -rand\ *|*\ -help*) exec $openssl_bin "$@" ;;
54c0d5
+  esac
54c0d5
+
54c0d5
+  cmds=`$openssl_bin list -digest-commands -cipher-commands | tr '\n' ' '`
54c0d5
+  for i in `$openssl_bin list -commands`; do
54c0d5
+    if $openssl_bin list -options "$i" | grep -q '^rand '; then
54c0d5
+      cmds=" $i $cmds"
54c0d5
+    fi
54c0d5
+  done
54c0d5
+
54c0d5
+  case "$cmds" in
54c0d5
+    *\ "$1"\ *)
54c0d5
+      cmd="$1"; shift
54c0d5
+      exec $openssl_bin "$cmd" -rand /dev/random "$@" ;;
54c0d5
+  esac
54c0d5
+
54c0d5
+  exec $openssl_bin "$@"
54c0d5
+)
54c0d5
+EOM
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
new file mode 100644
54c0d5
index 0000000000..c1d526902c
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
@@ -0,0 +1,5 @@
54c0d5
+#!/bin/bash
54c0d5
+# platform = Red Hat Enterprise Linux 8
54c0d5
+# profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
+
54c0d5
+rm -f /etc/profile.d/cc-config.sh
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
new file mode 100644
54c0d5
index 0000000000..313d14a37f
54c0d5
--- /dev/null
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
@@ -0,0 +1,5 @@
54c0d5
+#!/bin/bash
54c0d5
+# platform = Red Hat Enterprise Linux 8
54c0d5
+# profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
+
54c0d5
+echo "wrong data" > /etc/profile.d/cc-config.sh
54c0d5
54c0d5
From 223194744d54d0400ab1d2981761166580a4f017 Mon Sep 17 00:00:00 2001
54c0d5
From: Vojtech Polasek <vpolasek@redhat.com>
54c0d5
Date: Wed, 29 Jan 2020 11:12:46 +0100
54c0d5
Subject: [PATCH 4/6] remove blank=true from  jinja macro as rhel6 and rhel7 do
54c0d5
 not support it
54c0d5
54c0d5
---
54c0d5
 .../crypto/openssl_use_strong_entropy/ansible/shared.yml        | 2 +-
54c0d5
 1 file changed, 1 insertion(+), 1 deletion(-)
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
index 3ce26d6525..bdc530f9f5 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
@@ -8,5 +8,5 @@
54c0d5
   copy:
54c0d5
     dest: /etc/profile.d/cc-config.sh
54c0d5
     content: |+
54c0d5
-        {{{ openssl_strong_entropy_config_file()|indent(8,blank=True) }}}
54c0d5
+        {{{ openssl_strong_entropy_config_file()|indent(8) }}}
54c0d5
         
54c0d5
54c0d5
From bd41dcc77b326ed4bc352fe15d083ca6b144855f Mon Sep 17 00:00:00 2001
54c0d5
From: Vojtech Polasek <vpolasek@redhat.com>
54c0d5
Date: Thu, 30 Jan 2020 14:25:31 +0100
54c0d5
Subject: [PATCH 5/6] reword rationale, change file name
54c0d5
54c0d5
from cc-config.sh to openssl-rand.sh
54c0d5
change title of oval
54c0d5
---
54c0d5
 .../openssl_use_strong_entropy/ansible/shared.yml  |  2 +-
54c0d5
 .../openssl_use_strong_entropy/bash/shared.sh      |  2 +-
54c0d5
 .../openssl_use_strong_entropy/oval/shared.xml     | 11 ++++-------
54c0d5
 .../crypto/openssl_use_strong_entropy/rule.yml     | 14 +++++---------
54c0d5
 .../tests/correct.pass.sh                          |  2 +-
54c0d5
 .../tests/file_missing.fail.sh                     |  2 +-
54c0d5
 .../tests/file_modified.fail.sh                    |  2 +-
54c0d5
 7 files changed, 14 insertions(+), 21 deletions(-)
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
index bdc530f9f5..6ee232892d 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
@@ -6,7 +6,7 @@
54c0d5
 
54c0d5
 - name: "copy a file with shell snippet to configure openssl strong entropy"
54c0d5
   copy:
54c0d5
-    dest: /etc/profile.d/cc-config.sh
54c0d5
+    dest: /etc/profile.d/openssl-rand.sh
54c0d5
     content: |+
54c0d5
         {{{ openssl_strong_entropy_config_file()|indent(8) }}}
54c0d5
         
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
index db5c331ce7..d8c9935005 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/bash/shared.sh
54c0d5
@@ -1,5 +1,5 @@
54c0d5
 # platform = Red Hat Enterprise Linux 8
54c0d5
 
54c0d5
-cat > /etc/profile.d/cc-config.sh <<- 'EOM'
54c0d5
+cat > /etc/profile.d/openssl-rand.sh <<- 'EOM'
54c0d5
 {{{ openssl_strong_entropy_config_file() }}}
54c0d5
 EOM
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
index b441b7ae6e..847754f36d 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/oval/shared.xml
54c0d5
@@ -1,11 +1,8 @@
54c0d5
 <def-group>
54c0d5
   <definition class="compliance" id="openssl_use_strong_entropy" version="1">
54c0d5
     <metadata>
54c0d5
-      <title>Configure Openssl to use strong entropy</title>
54c0d5
-      <affected family="unix">
54c0d5
-        <platform>Red Hat Enterprise Linux 8</platform>
54c0d5
-        <platform>multi_platform_fedora</platform>
54c0d5
-      </affected>
54c0d5
+      <title>Configure OpenSSL to use strong entropy</title>
54c0d5
+      {{{- oval_affected(products) }}}
54c0d5
       <description>OpenSSL should be configured to generate random data with strong entropy.</description>
54c0d5
     </metadata>
54c0d5
     <criteria>
54c0d5
@@ -22,12 +19,12 @@
54c0d5
   </ind:filehash58_test>
54c0d5
 
54c0d5
   <ind:filehash58_object id="object_openssl_strong_entropy" version="1">
54c0d5
-    <ind:filepath>/etc/profile.d/cc-config.sh</ind:filepath>
54c0d5
+    <ind:filepath>/etc/profile.d/openssl-rand.sh</ind:filepath>
54c0d5
     <ind:hash_type>SHA-256</ind:hash_type>
54c0d5
   </ind:filehash58_object>
54c0d5
 
54c0d5
   <ind:filehash58_state id="state_openssl_strong_entropy" version="1">
54c0d5
-    <ind:filepath>/etc/profile.d/cc-config.sh</ind:filepath>
54c0d5
+    <ind:filepath>/etc/profile.d/openssl-rand.sh</ind:filepath>
54c0d5
     <ind:hash_type>SHA-256</ind:hash_type>
54c0d5
     <ind:hash>6488c757642cd493da09dd78ee27f039711a1ad79039900970553772fd2106af</ind:hash>
54c0d5
   </ind:filehash58_state>
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
index 3b01da01af..dd82336532 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
@@ -7,19 +7,15 @@ title: 'OpenSSL uses strong entropy source'
54c0d5
 
54c0d5
 description: |-
54c0d5
     To set up an <tt>openssl</tt> wrapper that adds a <tt>-rand /dev/random</tt> option to the <tt>openssl</tt> invocation,
54c0d5
-    save the following shell snippet to the <tt>/etc/profile.d/cc-config.sh</tt>:
54c0d5
+    save the following shell snippet to the <tt>/etc/profile.d/openssl-rand.sh</tt>:
54c0d5
     
54c0d5
     {{{ openssl_strong_entropy_config_file() | indent(4) }}}
54c0d5
     
54c0d5
 
54c0d5
 rationale: |-
54c0d5
-    The <tt>openssl</tt> default configuration uses less robust entropy sources for seeding.
54c0d5
-    The referenced script is sourced to every login shell, and it transparently adds an option
54c0d5
-    that enforces strong entropy to every <tt>openssl</tt> invocation,
54c0d5
-    which makes <tt>openssl</tt> more secure by default.
54c0d5
+    This rule ensures that <tt>openssl</tt> always uses SP800-90A compliant random number generator.
54c0d5
 
54c0d5
 severity: medium
54c0d5
-
54c0d5
 identifiers:
54c0d5
     cce@rhel8: 82721-2
54c0d5
 
54c0d5
@@ -27,12 +23,12 @@ references:
54c0d5
     ospp: FIA_AFL.1
54c0d5
 
54c0d5
 ocil: |-
54c0d5
-    To determine whether the <tt>openssl</tt> wrapper is configured correcrlty,
54c0d5
-    make sure that the <tt>/etc/profile.d/cc-config.sh</tt> file contains contents
54c0d5
+    To determine whether the <tt>openssl</tt> wrapper is configured correctly,
54c0d5
+    make sure that the <tt>/etc/profile.d/openssl-rand.sh</tt> file contains contents
54c0d5
     that are included in the rule's description.
54c0d5
 
54c0d5
 ocil_clause: |-
54c0d5
-    there is no <tt>/etc/profile.d/cc-config.sh</tt> file, or its contents don't match those in the description
54c0d5
+    there is no <tt>/etc/profile.d/openssl-rand.sh</tt> file, or its contents don't match those in the description
54c0d5
 
54c0d5
 warnings:
54c0d5
     - general: "This setting can cause problems on computers without the hardware random generator, because insufficient entropy blocks the program until enough entropy is available."
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
index 0bffab3c81..d7f3ce8c87 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/correct.pass.sh
54c0d5
@@ -2,7 +2,7 @@
54c0d5
 # platform = Red Hat Enterprise Linux 8
54c0d5
 # profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
 
54c0d5
-cat > /etc/profile.d/cc-config.sh <<- 'EOM'
54c0d5
+cat > /etc/profile.d/openssl-rand.sh <<- 'EOM'
54c0d5
 # provide a default -rand /dev/random option to openssl commands that
54c0d5
 # support it
54c0d5
 
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
index c1d526902c..64a580da91 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_missing.fail.sh
54c0d5
@@ -2,4 +2,4 @@
54c0d5
 # platform = Red Hat Enterprise Linux 8
54c0d5
 # profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
 
54c0d5
-rm -f /etc/profile.d/cc-config.sh
54c0d5
+rm -f /etc/profile.d/openssl-rand.sh
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
index 313d14a37f..2c812e874b 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/tests/file_modified.fail.sh
54c0d5
@@ -2,4 +2,4 @@
54c0d5
 # platform = Red Hat Enterprise Linux 8
54c0d5
 # profiles = xccdf_org.ssgproject.content_profile_ospp
54c0d5
 
54c0d5
-echo "wrong data" > /etc/profile.d/cc-config.sh
54c0d5
+echo "wrong data" > /etc/profile.d/openssl-rand.sh
54c0d5
54c0d5
From 679bd9cd08f962b3a88197817c199bd90a47f8d7 Mon Sep 17 00:00:00 2001
54c0d5
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
54c0d5
Date: Fri, 31 Jan 2020 16:34:48 +0100
54c0d5
Subject: [PATCH 6/6] Rule and remediation wording improvements.
54c0d5
54c0d5
---
54c0d5
 .../openssl_use_strong_entropy/ansible/shared.yml |  3 +--
54c0d5
 .../crypto/openssl_use_strong_entropy/rule.yml    | 15 ++++++++++-----
54c0d5
 2 files changed, 11 insertions(+), 7 deletions(-)
54c0d5
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
index 6ee232892d..25afb8e27f 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/ansible/shared.yml
54c0d5
@@ -4,9 +4,8 @@
54c0d5
 # complexity = low
54c0d5
 # disruption = low
54c0d5
 
54c0d5
-- name: "copy a file with shell snippet to configure openssl strong entropy"
54c0d5
+- name: "Put a file with shell wrapper to configure OpenSSL to always use strong entropy"
54c0d5
   copy:
54c0d5
     dest: /etc/profile.d/openssl-rand.sh
54c0d5
     content: |+
54c0d5
         {{{ openssl_strong_entropy_config_file()|indent(8) }}}
54c0d5
-        
54c0d5
diff --git a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
index dd82336532..8a958e93b0 100644
54c0d5
--- a/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
+++ b/linux_os/guide/system/software/integrity/crypto/openssl_use_strong_entropy/rule.yml
54c0d5
@@ -6,14 +6,18 @@ prodtype: rhel8
54c0d5
 title: 'OpenSSL uses strong entropy source'
54c0d5
 
54c0d5
 description: |-
54c0d5
-    To set up an <tt>openssl</tt> wrapper that adds a <tt>-rand /dev/random</tt> option to the <tt>openssl</tt> invocation,
54c0d5
-    save the following shell snippet to the <tt>/etc/profile.d/openssl-rand.sh</tt>:
54c0d5
+    By default, OpenSSL doesn't always use a SP800-90A compliant random number generator.
54c0d5
+    A way to configure OpenSSL to always use a strong source is to setup a wrapper that
54c0d5
+    defines a shell function that shadows the actual <tt>openssl</tt> binary,
54c0d5
+    and that ensures that the <tt>-rand /dev/random</tt> option is added to every <tt>openssl</tt> invocation.
54c0d5
+
54c0d5
+    To do so, place the following shell snippet exactly as-is to <tt>/etc/profile.d/openssl-rand.sh</tt>:
54c0d5
     
54c0d5
     {{{ openssl_strong_entropy_config_file() | indent(4) }}}
54c0d5
     
54c0d5
 
54c0d5
 rationale: |-
54c0d5
-    This rule ensures that <tt>openssl</tt> always uses SP800-90A compliant random number generator.
54c0d5
+    This rule ensures that <tt>openssl</tt> invocations always uses SP800-90A compliant random number generator as a default behavior.
54c0d5
 
54c0d5
 severity: medium
54c0d5
 identifiers:
54c0d5
@@ -23,8 +27,9 @@ references:
54c0d5
     ospp: FIA_AFL.1
54c0d5
 
54c0d5
 ocil: |-
54c0d5
-    To determine whether the <tt>openssl</tt> wrapper is configured correctly,
54c0d5
-    make sure that the <tt>/etc/profile.d/openssl-rand.sh</tt> file contains contents
54c0d5
+    To determine whether OpenSSL is wrapped by a shell function that ensures that every invocation
54c0d5
+    uses a SP800-90A compliant entropy source,
54c0d5
+    make sure that the <tt>/etc/profile.d/openssl-rand.sh</tt> file contents exactly match those
54c0d5
     that are included in the rule's description.
54c0d5
 
54c0d5
 ocil_clause: |-