From 62bf1be5a2f2789196a9b81ca7cd246d148dfb5b Mon Sep 17 00:00:00 2001 From: Watson Sato Date: Wed, 3 Jun 2020 10:54:51 +0200 Subject: [PATCH 1/3] no_shelllogin_for_systemaccounts: add tests --- .../no_shelllogin_for_systemaccounts/tests/default.pass.sh | 4 ++++ .../tests/no_sys_uids.pass.sh | 7 +++++++ .../tests/only_system_users.pass.sh | 6 ++++++ .../tests/system_user_with_shell.fail.sh | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh new file mode 100644 index 0000000000..6d48ad78fd --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh @@ -0,0 +1,4 @@ +# remediation = none + +#!/bin/bash +true diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh new file mode 100644 index 0000000000..bc4f9cee8c --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh @@ -0,0 +1,7 @@ +# remediation = none + +#!/bin/bash + +# Force unset of SYS_UID values +sed -i '/^SYS_UID_MIN/d' /etc/login.defs +sed -i '/^SYS_UID_MAX/d' /etc/login.defs diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh new file mode 100644 index 0000000000..0cdb820bbb --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh @@ -0,0 +1,6 @@ +# remediation = none + +#!/bin/bash + +# remove any non-system user +sed -Ei '/^root|nologin$|halt$|sync$|shutdown$/!d' /etc/passwd diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh new file mode 100644 index 0000000000..7639a8809d --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh @@ -0,0 +1,6 @@ +# remediation = none + +#!/bin/bash + +# change system user "mail" shell to bash +usermod --shell /bin/bash mail From 403cf63228a838bb80e09d8a6750bc5ee8597ce4 Mon Sep 17 00:00:00 2001 From: Watson Sato Date: Wed, 3 Jun 2020 11:27:48 +0200 Subject: [PATCH 2/3] no_shelllogin_for_systemaccounts: simplify check for range of UIDs There is no need to make calculations on top of the UIDs, we can compare the collected UIDs with shell againt the states that define the valid range. Avoiding the calculations has the added benefit of not using/referencing a variable that can be empty (when no user has shell, except root). --- .../oval/shared.xml | 198 +++--------------- 1 file changed, 33 insertions(+), 165 deletions(-) diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/oval/shared.xml b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/oval/shared.xml index 7e68441867..d0e836515b 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/oval/shared.xml +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/oval/shared.xml @@ -79,13 +79,6 @@ 1 - - - - - - - - - - - - - - - - - - - -1 - - - - - -1 - - - - - - - - - variable_default_range_quad_expr - - - - - 0 - - - - - - + + + + + + + 0 + + + + - - - - - - - - - - - - - - - - -1 - - - - - - - - - variable_reserved_range_quad_expr - - - - - 0 - - - - - - - - - - - - - - - - - - - - -1 - - - - - - - - - - -1 - - - - - - - - - variable_dynalloc_range_quad_expr - + + + + - - - 0 - + + + - - - - + + + + + + + + + + From 31654f72ee7cd30f937f84889c870fd330e7c366 Mon Sep 17 00:00:00 2001 From: Watson Sato Date: Thu, 4 Jun 2020 14:04:37 +0200 Subject: [PATCH 3/3] no_shelllogin_for_systemaccounts: Fix text shebangs --- .../no_shelllogin_for_systemaccounts/tests/default.pass.sh | 2 +- .../no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh | 3 +-- .../tests/only_system_users.pass.sh | 3 +-- .../tests/system_user_with_shell.fail.sh | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh index 6d48ad78fd..833831f79d 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/default.pass.sh @@ -1,4 +1,4 @@ +#!/bin/bash # remediation = none -#!/bin/bash true diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh index bc4f9cee8c..6769895eb2 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/no_sys_uids.pass.sh @@ -1,6 +1,5 @@ -# remediation = none - #!/bin/bash +# remediation = none # Force unset of SYS_UID values sed -i '/^SYS_UID_MIN/d' /etc/login.defs diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh index 0cdb820bbb..06edf671ce 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/only_system_users.pass.sh @@ -1,6 +1,5 @@ -# remediation = none - #!/bin/bash +# remediation = none # remove any non-system user sed -Ei '/^root|nologin$|halt$|sync$|shutdown$/!d' /etc/passwd diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh index 7639a8809d..10312593b8 100644 --- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh +++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_shelllogin_for_systemaccounts/tests/system_user_with_shell.fail.sh @@ -1,6 +1,5 @@ -# remediation = none - #!/bin/bash +# remediation = none # change system user "mail" shell to bash usermod --shell /bin/bash mail