|
|
fe0dde |
From 5ac59fa21c10ba7d87beefaa8c26099ddd73a0c3 Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Fri, 4 Sep 2020 15:51:47 +0200
|
|
|
fe0dde |
Subject: [PATCH 1/6] make oval regex stricter
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../snmpd_not_default_password/oval/shared.xml | 2 +-
|
|
|
fe0dde |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/oval/shared.xml b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/oval/shared.xml
|
|
|
fe0dde |
index b617c7339d..1bc84e1a88 100644
|
|
|
fe0dde |
--- a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/oval/shared.xml
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/oval/shared.xml
|
|
|
fe0dde |
@@ -17,7 +17,7 @@
|
|
|
fe0dde |
</ind:textfilecontent54_test>
|
|
|
fe0dde |
<ind:textfilecontent54_object id="object_snmp_default_communities" version="1">
|
|
|
fe0dde |
<ind:filepath>/etc/snmp/snmpd.conf</ind:filepath>
|
|
|
fe0dde |
- <ind:pattern operation="pattern match">^[\s]*(com2se|rocommunity|rwcommunity|createUser).*(public|private)</ind:pattern>
|
|
|
fe0dde |
+ <ind:pattern operation="pattern match">^((?!#).)*(public|private).*</ind:pattern>
|
|
|
fe0dde |
<ind:instance datatype="int">1</ind:instance>
|
|
|
fe0dde |
</ind:textfilecontent54_object>
|
|
|
fe0dde |
</def-group>
|
|
|
fe0dde |
|
|
|
fe0dde |
From 481cce33f5b148071e36d07a75291f5d39a8c02a Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Fri, 4 Sep 2020 15:52:07 +0200
|
|
|
fe0dde |
Subject: [PATCH 2/6] add tests
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../snmpd_not_default_password/tests/both.fail.sh | 6 ++++++
|
|
|
fe0dde |
.../snmpd_not_default_password/tests/commented.pass.sh | 7 +++++++
|
|
|
fe0dde |
.../snmpd_not_default_password/tests/correct.pass.sh | 6 ++++++
|
|
|
fe0dde |
.../snmpd_not_default_password/tests/private.fail.sh | 5 +++++
|
|
|
fe0dde |
.../snmpd_not_default_password/tests/public.fail.sh | 6 ++++++
|
|
|
fe0dde |
5 files changed, 30 insertions(+)
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/both.fail.sh
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/commented.pass.sh
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/correct.pass.sh
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/private.fail.sh
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/public.fail.sh
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/both.fail.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/both.fail.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..5b8efa3c75
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/both.fail.sh
|
|
|
fe0dde |
@@ -0,0 +1,6 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+yum -y install net-snmp
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+echo "something public" >> /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+echo "something private" >> /etc/snmp/snmpd.conf
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/commented.pass.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/commented.pass.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..410d00f5a1
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/commented.pass.sh
|
|
|
fe0dde |
@@ -0,0 +1,7 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+yum -y install net-snmp
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+sed -i '/.*public.*/d' /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+sed -i '/.*private.*/d' /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+echo '# public' >> /etc/snmp/snmpd.conf
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/correct.pass.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/correct.pass.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..355cc8b71d
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/correct.pass.sh
|
|
|
fe0dde |
@@ -0,0 +1,6 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+yum -y install net-snmp
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+sed -i '/.*public.*/d' /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+sed -i '/.*private.*/d' /etc/snmp/snmpd.conf
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/private.fail.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/private.fail.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..c6bcf9b401
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/private.fail.sh
|
|
|
fe0dde |
@@ -0,0 +1,5 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+yum -y install net-snmp
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+echo "something private" >> /etc/snmp/snmpd.conf
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/public.fail.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/public.fail.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..43022ba28c
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/tests/public.fail.sh
|
|
|
fe0dde |
@@ -0,0 +1,6 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+yum -y install net-snmp
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+echo "something public" >> /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+
|
|
|
fe0dde |
|
|
|
fe0dde |
From 9ad3734aa2c6a40fc8a6881d361e420faaaa1117 Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Wed, 9 Sep 2020 11:19:46 +0200
|
|
|
fe0dde |
Subject: [PATCH 3/6] add variables
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../snmpd_not_default_password/bash/shared.sh | 5 -----
|
|
|
fe0dde |
.../snmpd_not_default_password/rule.yml | 1 +
|
|
|
fe0dde |
.../snmp_configure_server/var_snmpd_ro_string.var | 14 ++++++++++++++
|
|
|
fe0dde |
.../snmp_configure_server/var_snmpd_rw_string.var | 14 ++++++++++++++
|
|
|
fe0dde |
4 files changed, 29 insertions(+), 5 deletions(-)
|
|
|
fe0dde |
delete mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_ro_string.var
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_rw_string.var
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
deleted file mode 100644
|
|
|
fe0dde |
index 4d5bc82282..0000000000
|
|
|
fe0dde |
--- a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
+++ /dev/null
|
|
|
fe0dde |
@@ -1,5 +0,0 @@
|
|
|
fe0dde |
-# platform = multi_platform_wrlinux,Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,multi_platform_ol
|
|
|
fe0dde |
-
|
|
|
fe0dde |
-if grep -s "public\|private" /etc/snmp/snmpd.conf | grep -qv "^#"; then
|
|
|
fe0dde |
- sed -i "/^\s*#/b;/public\|private/ s/^/#/" /etc/snmp/snmpd.conf
|
|
|
fe0dde |
-fi
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/rule.yml b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/rule.yml
|
|
|
fe0dde |
index 648f45caa2..72d2495713 100644
|
|
|
fe0dde |
--- a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/rule.yml
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/rule.yml
|
|
|
fe0dde |
@@ -7,6 +7,7 @@ title: 'Ensure Default SNMP Password Is Not Used'
|
|
|
fe0dde |
description: |-
|
|
|
fe0dde |
Edit <tt>/etc/snmp/snmpd.conf</tt>, remove or change the default community strings of
|
|
|
fe0dde |
<tt>public</tt> and <tt>private</tt>.
|
|
|
fe0dde |
+ This profile configures new read-only community string to <tt>{{{ sub_var_value("var_snmpd_ro_string") }}}</tt> and read-write community string to <tt>{{{ sub_var_value("var_snmpd_rw_string") }}}</tt>.
|
|
|
fe0dde |
Once the default community strings have been changed, restart the SNMP service:
|
|
|
fe0dde |
$ sudo service snmpd restart
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_ro_string.var b/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_ro_string.var
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..ac755d154f
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_ro_string.var
|
|
|
fe0dde |
@@ -0,0 +1,14 @@
|
|
|
fe0dde |
+documentation_complete: true
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+title: 'SNMP read-only community string'
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+description: "Specify the SNMP community string used for read-only access."
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+type: string
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+operator: equals
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+interactive: true
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+options:
|
|
|
fe0dde |
+ default: changemero
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_rw_string.var b/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_rw_string.var
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..7d2016a4dd
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/var_snmpd_rw_string.var
|
|
|
fe0dde |
@@ -0,0 +1,14 @@
|
|
|
fe0dde |
+documentation_complete: true
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+title: 'SNMP read-write community string'
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+description: "Specify the SNMP community string used for read-write access."
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+type: string
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+operator: equals
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+interactive: true
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+options:
|
|
|
fe0dde |
+ default: changemerw
|
|
|
fe0dde |
|
|
|
fe0dde |
From c2f193a43373900d65da6134325a8916a734c659 Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Wed, 9 Sep 2020 18:03:31 +0200
|
|
|
fe0dde |
Subject: [PATCH 4/6] add bash remediation
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../snmpd_not_default_password/bash/shared.sh | 16 ++++++++++++++++
|
|
|
fe0dde |
1 file changed, 16 insertions(+)
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..1b0474c07c
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/bash/shared.sh
|
|
|
fe0dde |
@@ -0,0 +1,16 @@
|
|
|
fe0dde |
+#!/bin/bash
|
|
|
fe0dde |
+# platform = debian 10,debian 9,multi_platform_fedora,Oracle Linux 7,Oracle Linux 8,Red Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,WRLinux 1019
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+. /usr/share/scap-security-guide/remediation_functions
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+{{{ bash_instantiate_variables("var_snmpd_ro_string", "var_snmpd_rw_string") }}}
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+# remediate read-only community string
|
|
|
fe0dde |
+if grep -q 'public' /etc/snmp/snmpd.conf; then
|
|
|
fe0dde |
+ sed -i "s/public/$var_snmpd_ro_string/" /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+fi
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+# remediate read-write community string
|
|
|
fe0dde |
+if grep -q 'private' /etc/snmp/snmpd.conf; then
|
|
|
fe0dde |
+ sed -i "s/private/$var_snmpd_rw_string/" /etc/snmp/snmpd.conf
|
|
|
fe0dde |
+fi
|
|
|
fe0dde |
|
|
|
fe0dde |
From 967f9eedd0dfac92d85c62231c13894964fafb5d Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Fri, 11 Sep 2020 10:23:52 +0200
|
|
|
fe0dde |
Subject: [PATCH 5/6] add ansible remediation
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../ansible/shared.yml | 21 +++++++++++++++++++
|
|
|
fe0dde |
1 file changed, 21 insertions(+)
|
|
|
fe0dde |
create mode 100644 linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
new file mode 100644
|
|
|
fe0dde |
index 0000000000..33062169cd
|
|
|
fe0dde |
--- /dev/null
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
@@ -0,0 +1,21 @@
|
|
|
fe0dde |
+# platform = debian 10,debian 9,multi_platform_fedora,Oracle Linux 7,Oracle Linux 8,Red Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,WRLinux 1019
|
|
|
fe0dde |
+# reboot = false
|
|
|
fe0dde |
+# strategy = configure
|
|
|
fe0dde |
+# complexity = low
|
|
|
fe0dde |
+# disruption = medium
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+{{{ ansible_instantiate_variables("var_snmpd_ro_string", "var_snmpd_rw_string") }}}
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+- name: "Replace all instances of SNMP RO strings"
|
|
|
fe0dde |
+ replace:
|
|
|
fe0dde |
+ path: "/etc/snmp/snmpd.conf"
|
|
|
fe0dde |
+ #regexp: '^[#](.*)public(.*)$'
|
|
|
fe0dde |
+ regexp: 'public'
|
|
|
fe0dde |
+ replace: '{{ var_snmpd_ro_string }}'
|
|
|
fe0dde |
+
|
|
|
fe0dde |
+- name: "Replace all instances of SNMP RW strings"
|
|
|
fe0dde |
+ replace:
|
|
|
fe0dde |
+ path: "/etc/snmp/snmpd.conf"
|
|
|
fe0dde |
+ #regexp: '^[#](.*)private(.*)$'
|
|
|
fe0dde |
+ regexp: 'private'
|
|
|
fe0dde |
+ replace: '{{ var_snmpd_rw_string }}'
|
|
|
fe0dde |
|
|
|
fe0dde |
From 946e540dadaf43eadb43479cc6328ee503e5d981 Mon Sep 17 00:00:00 2001
|
|
|
fe0dde |
From: Vojtech Polasek <vpolasek@redhat.com>
|
|
|
fe0dde |
Date: Mon, 14 Sep 2020 07:30:56 +0200
|
|
|
fe0dde |
Subject: [PATCH 6/6] remove forgotten commented lines
|
|
|
fe0dde |
|
|
|
fe0dde |
---
|
|
|
fe0dde |
.../snmpd_not_default_password/ansible/shared.yml | 2 --
|
|
|
fe0dde |
1 file changed, 2 deletions(-)
|
|
|
fe0dde |
|
|
|
fe0dde |
diff --git a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
index 33062169cd..d92c0a17da 100644
|
|
|
fe0dde |
--- a/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
+++ b/linux_os/guide/services/snmp/snmp_configure_server/snmpd_not_default_password/ansible/shared.yml
|
|
|
fe0dde |
@@ -9,13 +9,11 @@
|
|
|
fe0dde |
- name: "Replace all instances of SNMP RO strings"
|
|
|
fe0dde |
replace:
|
|
|
fe0dde |
path: "/etc/snmp/snmpd.conf"
|
|
|
fe0dde |
- #regexp: '^[#](.*)public(.*)$'
|
|
|
fe0dde |
regexp: 'public'
|
|
|
fe0dde |
replace: '{{ var_snmpd_ro_string }}'
|
|
|
fe0dde |
|
|
|
fe0dde |
- name: "Replace all instances of SNMP RW strings"
|
|
|
fe0dde |
replace:
|
|
|
fe0dde |
path: "/etc/snmp/snmpd.conf"
|
|
|
fe0dde |
- #regexp: '^[#](.*)private(.*)$'
|
|
|
fe0dde |
regexp: 'private'
|
|
|
fe0dde |
replace: '{{ var_snmpd_rw_string }}'
|