Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controls/cis_sle12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,7 @@ controls:
rules:
- sshd_approved_macs=cis_sle12
- sshd_use_approved_macs
- sshd_strong_macs=cis_sle12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule sshd_use_strong_macs is used also in multiple other profiles in other products. You should explicitly assign the value of the new sshd_strong_macs variable in all the controls and profile files where the rule sshd_use_strong_macs is selected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did relevant changes in 40cf036 but I guess that will need extra review from @ComplianceAsCode/oracle-maintainers, @ComplianceAsCode/red-hatters and @ComplianceAsCode/ubuntu-maintainers if I made the right assumptions

- sshd_use_strong_macs

- id: 5.2.15
Expand Down
1 change: 1 addition & 0 deletions controls/cis_sle15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ controls:
rules:
- sshd_approved_macs=cis_sle15
- sshd_use_approved_macs
- sshd_strong_macs=cis_sle15
- sshd_use_strong_macs

- id: 5.2.15
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
{{{ ansible_instantiate_variables("sshd_strong_macs") }}}

{{{ ansible_sshd_set(parameter="MACs", value="{{ sshd_strong_macs }}") }}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# platform = multi_platform_all

{{{ bash_sshd_config_set(parameter="MACs", value="[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160") }}}
{{{ bash_instantiate_variables("sshd_strong_macs") }}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you start using a variable, you should also change the corresponding rule.yml file, otherwise, depending on the variable setting, the remediations will be misaligned with the rule description and rationale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be covered in 40cf036


{{{ bash_replace_or_append('/etc/ssh/sshd_config', '^MACs', "$sshd_strong_macs", '%s %s') }}}

Original file line number Diff line number Diff line change
@@ -1 +1,70 @@
{{{ oval_sshd_config(parameter="MACs", value="((hmac-sha2-512-etm@openssh\.com|hmac-sha2-256-etm@openssh\.com|umac-128-etm@openssh\.com|hmac-sha2-512|hmac-sha2-256|hmac-ripemd160),?)+") }}}
<def-group>
<definition class="compliance" id="sshd_use_strong_macs" version="1">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Bash and Ansible you use the macros but in OVAL you change away from macros. What is the reason for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a nice way to transform the comma separated lilst with pipe separated list so can directly use the macro, and didn't felt right to transform the macro that is used in other places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with jinja you can just call replace(",", "|")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with jinja you can just call replace(",", "|")

nvm, I think it won't work: https://jinja.palletsprojects.com/en/3.1.x/templates/#jinja-filters.replace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you take a look at the above ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did but just getting a bar separated list doesn't get me much further since there is need to do much more changes, which I am afraid cause much more noise in the macros, so decided it doesn't worth at this stage

{{{ oval_metadata("Ensure only strong MAC algorithms are used") }}}
<criteria operator="AND">
<criteria comment="SSH is configured correctly or is not installed"
operator="OR">
<criteria comment="sshd is not installed" operator="AND">
<extend_definition comment="sshd is not required or requirement is unset"
definition_ref="sshd_not_required_or_unset" />
{{% if product in ['opensuse', 'sle12', 'sle15'] %}}
<extend_definition comment="package openssh removed"
definition_ref="package_openssh_removed" />
{{% else %}}
<extend_definition comment="package openssh-server removed"
definition_ref="package_openssh-server_removed" />
{{% endif %}}
</criteria>
<criteria comment="sshd is installed and configured" operator="AND">
<extend_definition comment="sshd is required or requirement is unset"
definition_ref="sshd_required_or_unset" />
{{% if product in ['opensuse', 'sle12', 'sle15'] %}}
<extend_definition comment="package openssh installed"
definition_ref="package_openssh_installed" />
{{% else %}}
<extend_definition comment="package openssh-server installed"
definition_ref="package_openssh-server_installed" />
{{% endif %}}
<criterion comment="Check MACs in /etc/ssh/sshd_config"
test_ref="test_sshd_use_strong_macs" />
</criteria>
</criteria>
</criteria>
</definition>

<ind:variable_test check="at least one"
comment="tests the value of MACs setting in the /etc/ssh/sshd_config file"
id="test_sshd_use_strong_macs" version="1">
<ind:object object_ref="obj_sshd_use_strong_macs" />
<ind:state state_ref="ste_sshd_use_strong_macs" />
</ind:variable_test>

<ind:variable_object id="obj_sshd_use_strong_macs" version="1">
<ind:var_ref>var_sshd_config_strong_macs</ind:var_ref>
</ind:variable_object>

<ind:variable_state comment="strong macs" id="ste_sshd_use_strong_macs" version="1">
<ind:value operation="equals" datatype="string" var_ref="var_sshd_strong_macs" var_check="at least one" />
</ind:variable_state>

<ind:textfilecontent54_object id="obj_sshd_config_strong_macs" version="1">
<ind:filepath>/etc/ssh/sshd_config</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*(?i)MACs(?-i)[\s]+([\w,-@]+)+[\s]*(?:#.*)?$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>

<local_variable id="var_sshd_config_strong_macs" datatype="string" version="1" comment="MACs values splitted on comma">
<split delimiter=",">
<object_component item_field="subexpression" object_ref="obj_sshd_config_strong_macs" />
</split>
</local_variable>

<local_variable id="var_sshd_strong_macs" datatype="string" version="1" comment="strong MACs values splitted on comma">
<split delimiter=",">
<variable_component var_ref="sshd_strong_macs" />
</split>
</local_variable>
<external_variable comment="SSH MAC algorithms considered strong" datatype="string" id="sshd_strong_macs" version="1" />
</def-group>


Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: |-
Limit the MACs to strong hash algorithms.
The following line in <tt>/etc/ssh/sshd_config</tt> demonstrates use
of those MACs:
<pre>MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160</pre>
<pre>MACs {{{ xccdf_value("sshd_strong_macs") }}}</pre>

rationale: |-
MD5 and 96-bit MAC algorithms are considered weak and have been shown to increase
Expand Down Expand Up @@ -36,4 +36,4 @@ ocil: |-
MACs are in use, run the following command:
<pre>$ sudo grep -i macs /etc/ssh/sshd_config</pre>
The output should contain only those MACs which are strong, namely,
[email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160 hash functions.
{{{ xccdf_value("sshd_strong_macs") }}} hash functions.
17 changes: 17 additions & 0 deletions linux_os/guide/services/ssh/sshd_strong_macs.var
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
documentation_complete: true

title: 'SSH Strong KEX by FIPS'

description: "Specify the FIPS approved MACs (Message Authentication Code) algorithms\n\tthat are used for data integrity protection by the SSH server."

type: string

operator: equals

interactive: false

options:
default: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
cis_sle12: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
cis_sle15: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256
cis_ubuntu2204: [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256
1 change: 1 addition & 0 deletions products/ol7/profiles/e8.profile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ selections:
- sshd_disable_empty_passwords
- sshd_disable_user_known_hosts
- sshd_enable_strictmodes
- sshd_strong_macs=default
- sshd_use_strong_macs

### Backup
Expand Down
1 change: 1 addition & 0 deletions products/rhel7/profiles/e8.profile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ selections:
- sshd_disable_empty_passwords
- sshd_disable_user_known_hosts
- sshd_enable_strictmodes
- sshd_strong_macs=default
- sshd_use_strong_macs

### Backup
Expand Down
1 change: 1 addition & 0 deletions products/ubuntu2204/profiles/cis_level1_server.profile
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ selections:
- sshd_use_strong_ciphers

### 5.2.14 Ensure only strong MAC algorithms are used (Automated)
- sshd_strong_macs=cis_ubuntu2204
- sshd_use_strong_macs

### 5.2.15 Ensure only strong Key Exchange algorithms are used (Automated)
Expand Down
1 change: 1 addition & 0 deletions tests/data/profile_stability/rhel7/e8.profile
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ selections:
- var_selinux_state=enforcing
- var_selinux_policy_name=targeted
- var_auditd_flush=incremental_async
- sshd_strong_macs=default
title: Australian Cyber Security Centre (ACSC) Essential Eight