|
|
0c1482 |
From 133d331a04e1ba27324291006c65c2bfa467e49d Mon Sep 17 00:00:00 2001
|
|
|
0c1482 |
From: Gabriel Becker <ggasparb@redhat.com>
|
|
|
0c1482 |
Date: Tue, 1 Feb 2022 16:54:16 +0100
|
|
|
0c1482 |
Subject: [PATCH 1/2] Update RHEL-08-010383 to require only one occurrence of a
|
|
|
0c1482 |
config.
|
|
|
0c1482 |
|
|
|
0c1482 |
The V1R5 release of RHEL8 STIG requires that the configuration should be
|
|
|
0c1482 |
present only in one configuration file to prevent any ordering problem
|
|
|
0c1482 |
when the modules loads the configuration using drop-in files that use
|
|
|
0c1482 |
the lexicographically order of file names.
|
|
|
0c1482 |
---
|
|
|
0c1482 |
.../sudo/sudoers_validate_passwd/ansible/shared.yml | 6 +++---
|
|
|
0c1482 |
.../sudo/sudoers_validate_passwd/oval/shared.xml | 12 ++++++------
|
|
|
0c1482 |
.../software/sudo/sudoers_validate_passwd/rule.yml | 3 ++-
|
|
|
0c1482 |
.../tests/sudoers_validate_passwd_duplicates.fail.sh | 7 +++++++
|
|
|
0c1482 |
4 files changed, 18 insertions(+), 10 deletions(-)
|
|
|
0c1482 |
create mode 100644 linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_validate_passwd_duplicates.fail.sh
|
|
|
0c1482 |
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
index 08ffd76aed6..19673634fb3 100644
|
|
|
0c1482 |
--- a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
@@ -4,6 +4,6 @@
|
|
|
0c1482 |
# complexity = low
|
|
|
0c1482 |
# disruption = low
|
|
|
0c1482 |
|
|
|
0c1482 |
-{{{ ansible_lineinfile(msg='Ensure that Defaults !targetpw is defined in sudoers', path='/etc/sudoers', new_line='Defaults !targetpw', create='yes', state='present') }}}
|
|
|
0c1482 |
-{{{ ansible_lineinfile(msg='Ensure that Defaults !rootpw is defined in sudoers', path='/etc/sudoers', new_line='Defaults !rootpw', create='yes', state='present') }}}
|
|
|
0c1482 |
-{{{ ansible_lineinfile(msg='Ensure that Defaults !runaspw is defined in sudoers', path='/etc/sudoers', new_line='Defaults !runaspw', create='yes', state='present') }}}
|
|
|
0c1482 |
+{{{ ansible_only_lineinfile(msg='Ensure that Defaults !targetpw is defined in sudoers', line_regex='^Defaults !targetpw$', path='/etc/sudoers', new_line='Defaults !targetpw') }}}
|
|
|
0c1482 |
+{{{ ansible_only_lineinfile(msg='Ensure that Defaults !rootpw is defined in sudoers', line_regex='^Defaults !rootpw$', path='/etc/sudoers', new_line='Defaults !rootpw') }}}
|
|
|
0c1482 |
+{{{ ansible_only_lineinfile(msg='Ensure that Defaults !runaspw is defined in sudoers', line_regex='^Defaults !runaspw$', path='/etc/sudoers', new_line='Defaults !runaspw') }}}
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/oval/shared.xml b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/oval/shared.xml
|
|
|
0c1482 |
index 646e6bfb7c0..b3fadd53bee 100644
|
|
|
0c1482 |
--- a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/oval/shared.xml
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/oval/shared.xml
|
|
|
0c1482 |
@@ -8,17 +8,17 @@
|
|
|
0c1482 |
</criteria>
|
|
|
0c1482 |
</definition>
|
|
|
0c1482 |
|
|
|
0c1482 |
-
|
|
|
0c1482 |
+
|
|
|
0c1482 |
id="test_sudoers_targetpw_config" version="1">
|
|
|
0c1482 |
<ind:object object_ref="object_test_sudoers_targetpw_config" />
|
|
|
0c1482 |
</ind:textfilecontent54_test>
|
|
|
0c1482 |
|
|
|
0c1482 |
-
|
|
|
0c1482 |
+
|
|
|
0c1482 |
id="test_sudoers_rootpw_config" version="1">
|
|
|
0c1482 |
<ind:object object_ref="object_test_sudoers_rootpw_config" />
|
|
|
0c1482 |
</ind:textfilecontent54_test>
|
|
|
0c1482 |
|
|
|
0c1482 |
-
|
|
|
0c1482 |
+
|
|
|
0c1482 |
id="test_sudoers_runaspw_config" version="1">
|
|
|
0c1482 |
<ind:object object_ref="object_test_sudoers_runaspw_config" />
|
|
|
0c1482 |
</ind:textfilecontent54_test>
|
|
|
0c1482 |
@@ -26,19 +26,19 @@
|
|
|
0c1482 |
<ind:textfilecontent54_object id="object_test_sudoers_targetpw_config" version="1">
|
|
|
0c1482 |
<ind:filepath operation="pattern match">^/etc/sudoers(\.d/.*)?$</ind:filepath>
|
|
|
0c1482 |
<ind:pattern operation="pattern match">^Defaults !targetpw$\r?\n</ind:pattern>
|
|
|
0c1482 |
- <ind:instance datatype="int">1</ind:instance>
|
|
|
0c1482 |
+ <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
|
|
|
0c1482 |
</ind:textfilecontent54_object>
|
|
|
0c1482 |
|
|
|
0c1482 |
<ind:textfilecontent54_object id="object_test_sudoers_rootpw_config" version="1">
|
|
|
0c1482 |
<ind:filepath operation="pattern match">^/etc/sudoers(\.d/.*)?$</ind:filepath>
|
|
|
0c1482 |
<ind:pattern operation="pattern match">^Defaults !rootpw$\r?\n</ind:pattern>
|
|
|
0c1482 |
- <ind:instance datatype="int">1</ind:instance>
|
|
|
0c1482 |
+ <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
|
|
|
0c1482 |
</ind:textfilecontent54_object>
|
|
|
0c1482 |
|
|
|
0c1482 |
<ind:textfilecontent54_object id="object_test_sudoers_runaspw_config" version="1">
|
|
|
0c1482 |
<ind:filepath operation="pattern match">^/etc/sudoers(\.d/.*)?$</ind:filepath>
|
|
|
0c1482 |
<ind:pattern operation="pattern match">^Defaults !runaspw$\r?\n</ind:pattern>
|
|
|
0c1482 |
- <ind:instance datatype="int">1</ind:instance>
|
|
|
0c1482 |
+ <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
|
|
|
0c1482 |
</ind:textfilecontent54_object>
|
|
|
0c1482 |
|
|
|
0c1482 |
</def-group>
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/rule.yml b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/rule.yml
|
|
|
0c1482 |
index ccc29b77d15..698021d8fd0 100644
|
|
|
0c1482 |
--- a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/rule.yml
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/rule.yml
|
|
|
0c1482 |
@@ -42,7 +42,8 @@ ocil_clause: 'invoke user passwd when using sudo'
|
|
|
0c1482 |
ocil: |-
|
|
|
0c1482 |
Run the following command to Verify that the sudoers security policy is configured to use the invoking user's password for privilege escalation:
|
|
|
0c1482 |
sudo egrep -i '(!rootpw|!targetpw|!runaspw)' /etc/sudoers /etc/sudoers.d/* | grep -v '#'
|
|
|
0c1482 |
- If no results are returned, this is a finding
|
|
|
0c1482 |
+ If no results are returned, this is a finding.
|
|
|
0c1482 |
+ If results are returned from more than one file location, this is a finding.
|
|
|
0c1482 |
If "Defaults !targetpw" is not defined, this is a finding.
|
|
|
0c1482 |
If "Defaults !rootpw" is not defined, this is a finding.
|
|
|
0c1482 |
If "Defaults !runaspw" is not defined, this is a finding.
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_validate_passwd_duplicates.fail.sh b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_validate_passwd_duplicates.fail.sh
|
|
|
0c1482 |
new file mode 100644
|
|
|
0c1482 |
index 00000000000..6247b5230e4
|
|
|
0c1482 |
--- /dev/null
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_validate_passwd_duplicates.fail.sh
|
|
|
0c1482 |
@@ -0,0 +1,7 @@
|
|
|
0c1482 |
+# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15
|
|
|
0c1482 |
+# packages = sudo
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+echo 'Defaults !targetpw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !rootpw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !runaspw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !runaspw' >> /etc/sudoers
|
|
|
0c1482 |
|
|
|
0c1482 |
From 315b248c77252fc3145cdf34fede98b1a32a7c04 Mon Sep 17 00:00:00 2001
|
|
|
0c1482 |
From: Gabriel Becker <ggasparb@redhat.com>
|
|
|
0c1482 |
Date: Wed, 9 Feb 2022 15:24:23 +0100
|
|
|
0c1482 |
Subject: [PATCH 2/2] Update remediations of sudoers_validate_passwd to remove
|
|
|
0c1482 |
duplicates.
|
|
|
0c1482 |
|
|
|
0c1482 |
---
|
|
|
0c1482 |
.../ansible/shared.yml | 20 +++++++++++++++++++
|
|
|
0c1482 |
.../sudoers_validate_passwd/bash/shared.sh | 12 +++++++++++
|
|
|
0c1482 |
.../tests/sudoers_d_duplicate.fail.sh | 9 +++++++++
|
|
|
0c1482 |
3 files changed, 41 insertions(+)
|
|
|
0c1482 |
create mode 100644 linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_d_duplicate.fail.sh
|
|
|
0c1482 |
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
index 19673634fb3..399ca1ea3ce 100644
|
|
|
0c1482 |
--- a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/ansible/shared.yml
|
|
|
0c1482 |
@@ -4,6 +4,26 @@
|
|
|
0c1482 |
# complexity = low
|
|
|
0c1482 |
# disruption = low
|
|
|
0c1482 |
|
|
|
0c1482 |
+{{%- macro delete_line_in_sudoers_d(line) %}}
|
|
|
0c1482 |
+- name: "Find out if /etc/sudoers.d/* files contain {{{ line }}} to be deduplicated"
|
|
|
0c1482 |
+ find:
|
|
|
0c1482 |
+ path: "/etc/sudoers.d"
|
|
|
0c1482 |
+ patterns: "*"
|
|
|
0c1482 |
+ contains: '^{{{ line }}}$'
|
|
|
0c1482 |
+ register: sudoers_d_defaults
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+- name: "Remove found occurrences of {{{ line }}} from /etc/sudoers.d/* files"
|
|
|
0c1482 |
+ lineinfile:
|
|
|
0c1482 |
+ path: "{{ item.path }}"
|
|
|
0c1482 |
+ regexp: "^{{{ line }}}$"
|
|
|
0c1482 |
+ state: absent
|
|
|
0c1482 |
+ with_items: "{{ sudoers_d_defaults.files }}"
|
|
|
0c1482 |
+{{%- endmacro %}}
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !targetpw") }}}
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !rootpw") }}}
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !runaspw") }}}
|
|
|
0c1482 |
+
|
|
|
0c1482 |
{{{ ansible_only_lineinfile(msg='Ensure that Defaults !targetpw is defined in sudoers', line_regex='^Defaults !targetpw$', path='/etc/sudoers', new_line='Defaults !targetpw') }}}
|
|
|
0c1482 |
{{{ ansible_only_lineinfile(msg='Ensure that Defaults !rootpw is defined in sudoers', line_regex='^Defaults !rootpw$', path='/etc/sudoers', new_line='Defaults !rootpw') }}}
|
|
|
0c1482 |
{{{ ansible_only_lineinfile(msg='Ensure that Defaults !runaspw is defined in sudoers', line_regex='^Defaults !runaspw$', path='/etc/sudoers', new_line='Defaults !runaspw') }}}
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/bash/shared.sh b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/bash/shared.sh
|
|
|
0c1482 |
index ea0ac67fa1c..3b327f3fc88 100644
|
|
|
0c1482 |
--- a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/bash/shared.sh
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/bash/shared.sh
|
|
|
0c1482 |
@@ -1,5 +1,17 @@
|
|
|
0c1482 |
# platform = multi_platform_all
|
|
|
0c1482 |
|
|
|
0c1482 |
+{{%- macro delete_line_in_sudoers_d(line) %}}
|
|
|
0c1482 |
+if grep -x '^{{{line}}}$' /etc/sudoers.d/*; then
|
|
|
0c1482 |
+ find /etc/sudoers.d/ -type f -exec sed -i "/{{{line}}}/d" {} \;
|
|
|
0c1482 |
+fi
|
|
|
0c1482 |
+{{%- endmacro %}}
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !targetpw") }}}
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !rootpw") }}}
|
|
|
0c1482 |
+{{{- delete_line_in_sudoers_d("Defaults !runaspw") }}}
|
|
|
0c1482 |
+
|
|
|
0c1482 |
{{{ set_config_file(path="/etc/sudoers", parameter="Defaults !targetpw", value="", create=true, insensitive=false, separator="", separator_regex="", prefix_regex="") }}}
|
|
|
0c1482 |
{{{ set_config_file(path="/etc/sudoers", parameter="Defaults !rootpw", value="", create=true, insensitive=false, separator="", separator_regex="", prefix_regex="") }}}
|
|
|
0c1482 |
{{{ set_config_file(path="/etc/sudoers", parameter="Defaults !runaspw", value="", create=true, insensitive=false, separator="", separator_regex="", prefix_regex="") }}}
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+
|
|
|
0c1482 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_d_duplicate.fail.sh b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_d_duplicate.fail.sh
|
|
|
0c1482 |
new file mode 100644
|
|
|
0c1482 |
index 00000000000..a258d108a00
|
|
|
0c1482 |
--- /dev/null
|
|
|
0c1482 |
+++ b/linux_os/guide/system/software/sudo/sudoers_validate_passwd/tests/sudoers_d_duplicate.fail.sh
|
|
|
0c1482 |
@@ -0,0 +1,9 @@
|
|
|
0c1482 |
+# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15
|
|
|
0c1482 |
+# packages = sudo
|
|
|
0c1482 |
+
|
|
|
0c1482 |
+echo 'Defaults !targetpw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !rootpw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !runaspw' >> /etc/sudoers
|
|
|
0c1482 |
+echo 'Defaults !targetpw' >> /etc/sudoers.d/00-complianceascode.conf
|
|
|
0c1482 |
+echo 'Defaults !rootpw' >> /etc/sudoers.d/00-complianceascode.conf
|
|
|
0c1482 |
+echo 'Defaults !runaspw' >> /etc/sudoers.d/00-complianceascode.conf
|