|
|
a297d8 |
diff --git a/controls/anssi.yml b/controls/anssi.yml
|
|
|
a297d8 |
index 851993512..515a4a172 100644
|
|
|
a297d8 |
--- a/controls/anssi.yml
|
|
|
a297d8 |
+++ b/controls/anssi.yml
|
|
|
a297d8 |
@@ -850,7 +850,8 @@ controls:
|
|
|
a297d8 |
- id: R63
|
|
|
a297d8 |
level: intermediary
|
|
|
a297d8 |
title: Explicit arguments in sudo specifications
|
|
|
a297d8 |
- # rules: TBD
|
|
|
a297d8 |
+ rules:
|
|
|
a297d8 |
+ - sudoers_explicit_command_args
|
|
|
a297d8 |
|
|
|
a297d8 |
- id: R64
|
|
|
a297d8 |
level: intermediary
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/oval/shared.xml b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/oval/shared.xml
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..94a0cb421
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/oval/shared.xml
|
|
|
a297d8 |
@@ -0,0 +1,25 @@
|
|
|
a297d8 |
+<def-group>
|
|
|
a297d8 |
+ <definition class="compliance" id="{{{ rule_id }}}" version="1">
|
|
|
a297d8 |
+ {{{ oval_metadata("Check that sudoers doesn't contain commands without arguments specified") }}}
|
|
|
a297d8 |
+ <criteria operator="AND">
|
|
|
a297d8 |
+ <criterion comment="Make sure that no commands are without arguments" test_ref="test_{{{ rule_id }}}" />
|
|
|
a297d8 |
+ </criteria>
|
|
|
a297d8 |
+ </definition>
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ comment="Make sure that no command in user spec is without any argument"
|
|
|
a297d8 |
+ id="test_{{{ rule_id }}}" version="1">
|
|
|
a297d8 |
+ <ind:object object_ref="object_{{{ rule_id }}}" />
|
|
|
a297d8 |
+ </ind:textfilecontent54_test>
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ <ind:textfilecontent54_object id="object_{{{ rule_id }}}" version="1">
|
|
|
a297d8 |
+ <ind:filepath operation="pattern match">^/etc/sudoers(\.d/.*)?$</ind:filepath>
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ where a command is <runas spec>?<anything except ,>+,
|
|
|
a297d8 |
+ - ',' is a command delimiter, while
|
|
|
a297d8 |
+ The last capturing group holds the offending command without args.
|
|
|
a297d8 |
+ -->
|
|
|
a297d8 |
+ <ind:pattern operation="pattern match">^(?:\s*[^#=]+)=(?:\s*(?:\([^\)]+\))?\s*(?!\s*\()[^,\s]+(?:[ \t]+[^,\s]+)+[ \t]*,)*(\s*(?:\([^\)]+\))?\s*(?!\s*\()[^,\s]+[ \t]*(?:,|$))</ind:pattern>
|
|
|
a297d8 |
+ <ind:instance datatype="int">1</ind:instance>
|
|
|
a297d8 |
+ </ind:textfilecontent54_object>
|
|
|
a297d8 |
+</def-group>
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/rule.yml b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/rule.yml
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..a0590c8b0
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/rule.yml
|
|
|
a297d8 |
@@ -0,0 +1,46 @@
|
|
|
a297d8 |
+documentation_complete: true
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+title: "Explicit arguments in sudo specifications"
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+description: |-
|
|
|
a297d8 |
+ All commands in the sudoers file must strictly specify the arguments allowed to be used for a given user.
|
|
|
a297d8 |
+ If the command is supposed to be executed only without arguments, pass "" as an argument in the corresponding user specification.
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+rationale: |-
|
|
|
a297d8 |
+ Any argument can modify quite significantly the behavior of a program, whether regarding the
|
|
|
a297d8 |
+ realized operation (read, write, delete, etc.) or accessed resources (path in a file system tree). To
|
|
|
a297d8 |
+ avoid any possibility of misuse of a command by a user, the ambiguities must be removed at the
|
|
|
a297d8 |
+ level of its specification.
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ For example, on some systems, the kernel messages are only accessible by root.
|
|
|
a297d8 |
+ If a user nevertheless must have the privileges to read them, the argument of the dmesg command has to be restricted
|
|
|
a297d8 |
+ in order to prevent the user from flushing the buffer through the -c option:
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ user ALL = dmesg ""
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+severity: medium
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+identifiers:
|
|
|
a297d8 |
+ cce@rhel7: CCE-83631-2
|
|
|
a297d8 |
+ cce@rhel8: CCE-83632-0
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+references:
|
|
|
a297d8 |
+ anssi: BP28(R63)
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ocil_clause: '/etc/sudoers file contains user specifications that allow execution of commands with any arguments'
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ocil: |-
|
|
|
a297d8 |
+ To determine if arguments that commands can be executed with are restricted, run the following command:
|
|
|
a297d8 |
+ $ sudo grep -PR '^(?:\s*[^#=]+)=(?:\s*(?:\([^\)]+\))?\s*(?!\s*\()[^,\s]+(?:[ \t]+[^,\s]+)+[ \t]*,)*(\s*(?:\([^\)]+\))?\s*(?!\s*\()[^,\s]+[ \t]*(?:,|$))' /etc/sudoers /etc/sudoers.d/
|
|
|
a297d8 |
+ The command should return no output.
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+platform: sudo
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+warnings:
|
|
|
a297d8 |
+ - general:
|
|
|
a297d8 |
+ This rule doesn't come with a remediation, as absence of arguments in the user spec doesn't mean that the command is intended to be executed with no arguments.
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+ - general:
|
|
|
a297d8 |
+ The rule can produce false findings when an argument contains a comma - sudoers syntax allows comma escaping using backslash, but the check doesn't support that.
|
|
|
a297d8 |
+ For example, root ALL=(ALL) echo 1\,2 allows root to execute echo 1,2 , but the check would interpret it as two commands echo 1\ and 2 .
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/commented.pass.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/commented.pass.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..b0d05b2a5
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/commented.pass.sh
|
|
|
a297d8 |
@@ -0,0 +1,5 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo '#jen,!fred ALL, !SERVERS = !/bin/sh' > /etc/sudoers
|
|
|
a297d8 |
+echo '# somebody ALL=/bin/ls, (!bob,alice) !/bin/cat, /bin/dog' > /etc/sudoers.d/foo
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-1.fail.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-1.fail.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..c6f885f9f
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-1.fail.sh
|
|
|
a297d8 |
@@ -0,0 +1,5 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+# remediation = none
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'somebody ALL=/bin/ls, (!bob,alice) /bin/cat arg, /bin/dog' > /etc/sudoers
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-2.fail.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-2.fail.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..fce851f55
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/complex-2.fail.sh
|
|
|
a297d8 |
@@ -0,0 +1,5 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+# remediation = none
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls, (!bob,alice) /bin/dog, /bin/cat arg' > /etc/sudoers
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/false_positive.fail.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/false_positive.fail.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..baf66468d
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/false_positive.fail.sh
|
|
|
a297d8 |
@@ -0,0 +1,9 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# remediation = none
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+# The val1\,val2 is the first argument of the /bin/dog command that contains a comma.
|
|
|
a297d8 |
+# Our check tends to interpret the comma as commad delimiter, so the dog arg is val1\
|
|
|
a297d8 |
+# and val2 is another command in the user spec.
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls "", (!bob,alice) /bin/dog val1\,val2, /bin/cat ""' > /etc/sudoers
|
|
|
a297d8 |
+
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.fail.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.fail.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..9a04a205a
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.fail.sh
|
|
|
a297d8 |
@@ -0,0 +1,5 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+# remediation = none
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'jen,!fred ALL,SERVERS = /bin/sh ' > /etc/sudoers
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.pass.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.pass.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..4a3a7c94b
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/simple.pass.sh
|
|
|
a297d8 |
@@ -0,0 +1,6 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls "", (!bob,alice) /bin/dog arg, /bin/cat ""' > /etc/sudoers
|
|
|
a297d8 |
+echo 'jen,!fred ALL,!SERVERS = /bin/sh arg' >> /etc/sudoers
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls arg arg, (bob,!alice) /bin/dog arg, /bin/cat arg' > /etc/sudoers.d/foo
|
|
|
a297d8 |
diff --git a/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/sudoers_d.fail.sh b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/sudoers_d.fail.sh
|
|
|
a297d8 |
new file mode 100644
|
|
|
a297d8 |
index 000000000..9643a3337
|
|
|
a297d8 |
--- /dev/null
|
|
|
a297d8 |
+++ b/linux_os/guide/system/software/sudo/sudoers_explicit_command_args/tests/sudoers_d.fail.sh
|
|
|
a297d8 |
@@ -0,0 +1,9 @@
|
|
|
a297d8 |
+# platform = multi_platform_all
|
|
|
a297d8 |
+# packages = sudo
|
|
|
a297d8 |
+# remediation = none
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls, (!bob,alice) /bin/dog arg, /bin/cat ""' > /etc/sudoers
|
|
|
a297d8 |
+echo 'jen,!fred ALL,!SERVERS = /bin/sh arg' >> /etc/sudoers
|
|
|
a297d8 |
+echo 'nobody ALL=/bin/ls, (bob,!alice) /bin/dog arg, /bin/cat arg' > /etc/sudoers.d/foo
|
|
|
a297d8 |
+
|
|
|
a297d8 |
+echo 'user ALL = ALL' > /etc/sudoers.d/bar
|
|
|
a297d8 |
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
|
|
|
a297d8 |
index 4dbec8255..94a116b59 100644
|
|
|
a297d8 |
--- a/shared/references/cce-redhat-avail.txt
|
|
|
a297d8 |
+++ b/shared/references/cce-redhat-avail.txt
|
|
|
a297d8 |
@@ -140,8 +140,6 @@ CCE-83626-2
|
|
|
a297d8 |
CCE-83627-0
|
|
|
a297d8 |
CCE-83628-8
|
|
|
a297d8 |
CCE-83629-6
|
|
|
a297d8 |
-CCE-83631-2
|
|
|
a297d8 |
-CCE-83632-0
|
|
|
a297d8 |
CCE-83633-8
|
|
|
a297d8 |
CCE-83634-6
|
|
|
a297d8 |
CCE-83635-3
|