Skip to content

Conversation

@jan-cerny
Copy link
Collaborator

@jan-cerny jan-cerny commented Oct 30, 2025

This PR adds these rules:

  • configure_custom_crypto_policy_cis
  • configure_custom_crypto_policy_cis_mac
  • configure_custom_crypto_policy_cis_ssh_cbc
  • configure_custom_crypto_policy_cis_ssh_ciphers
  • configure_custom_crypto_policy_cis_ssh_macs

The rules configure multiple custom crypto sub policy modules for RHEL CIS. The new rule is very similar to fips_custom_stig_sub_policy. It configures new modules for system wide crypto policies that reduces the set of usable ciphers in sshd, MACs, and others.

The rule is templated by a new template crypto_sub_policies that is also introduced in this commit so that the code can be reused in other similar rules.

This change aligns the RHEL 8 CIS profiles in CaC with the requirements requested in CIS RHEL 8 Benchmark v4.0.0, CIS RHEL 9 Benchmark v2.0.0 and CIS RHEL 10 Benchmark v1.0.1.

All crypto requirements of this profile are now covered by this single rule. The reason for merging all of the sub module configuration is to prevent overriding crypto policy settings. If there would be multiple rules, each of them would call the update-crypto-policies commands with a different sub policy, overriding each other.

This supersedes #14050

Resolves: https://issues.redhat.com/browse/RHEL-111896
Also, it resolves some of the items from https://issues.redhat.com/browse/RHEL-76009.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Oct 30, 2025
@openshift-ci
Copy link

openshift-ci bot commented Oct 30, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@jan-cerny jan-cerny added bugfix Fixes to reported bugs. RHEL8 Red Hat Enterprise Linux 8 product related. CIS CIS Benchmark related. and removed do-not-merge/work-in-progress Used by openshift-ci bot. labels Oct 30, 2025
@jan-cerny jan-cerny added this to the 0.1.79 milestone Oct 30, 2025
Copy link
Member

@ggbecker ggbecker left a comment

Choose a reason for hiding this comment

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

I believe the same should apply for all other CIS RHEL (9/10) major versions.

And would be ideal if the rule would not be RHEL8 centric. We could in theory set the sub_policies variable according to the RHEL version.

Also I believe that it is still valid to check for particular submodules in the crypto policy, for example there would still have a need for the rule that checks if the current crypto policy respects a given security requirement (e.g. no weak mac), this rule would simply check if the submodule contains the right algorithm restriction, and the remediation can simply be reapply the expected sub crypto policy in case of deviation.

This would not imply a change in the CIS benchmarks for example, where they have a requirement for each of the restriction they expect.

I also don't like the name of the rule, instead of crypto_sub_policies_cis_rhel8,
maybe something like configure_custom_crypto_policy_cis

@jan-cerny
Copy link
Collaborator Author

@ggbecker

I believe the same should apply for all other CIS RHEL (9/10) major versions.

Great idea! I have checked the latest versions of RHEL 9 and RHEL 10 CIS Benchmarks and I found they also use the approach to configure cryptography by creating custom crypto policy sub modules. They are very similar to the RHEL 8 bu sometimes with different values. I think I will extend this change to use the new rule also on RHEL 9 and RHEL 10.

And would be ideal if the rule would not be RHEL8 centric. We could in theory set the sub_policies variable according to the RHEL version.

Yes, that makes sense.

Also I believe that it is still valid to check for particular submodules in the crypto policy, for example there would still have a need for the rule that checks if the current crypto policy respects a given security requirement (e.g. no weak mac), this rule would simply check if the submodule contains the right algorithm restriction, and the remediation can simply be reapply the expected sub crypto policy in case of deviation.

I'm not sure if I follow. Can you try to rephrase or explain this a little more? The current code in this PR contains OVAL that checks the contents of the submodule file (.pmod) file, I believe that this way it checks if the current crypto policy respects a given security requirement (e.g. no weak mac).

This would not imply a change in the CIS benchmarks for example, where they have a requirement for each of the restriction they expect.

Is your concern about the fact that after this change we would cover multiple controls with a single rule?

I'm concerned about covering multiple requirements by single rule as well. The previous PR #14050 has the configuration split into 4 different rules. That's better for the granularity, and I'd prefer that. However, it has a problem that when the remediation of a rule runs the update-crypto-policies command it adds the crypto policy sub module configured by the rule but removes the others because it has no information that there are other rules adding other modules. That's a blocker because the test fails and the final state after all 4 rules are applied isn't compliant. I couldn't find a solution for this.

I also don't like the name of the rule, instead of crypto_sub_policies_cis_rhel8,
maybe something like configure_custom_crypto_policy_cis

OK, makes sense once I incorporate the change to RHEL 9 and RHEL 10 CIS profiles.

@jan-cerny jan-cerny added the Highlight This PR/Issue should make it to the featured changelog. label Oct 31, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Used by openshift-ci bot. label Oct 31, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Used by openshift-ci bot. label Oct 31, 2025
@jan-cerny
Copy link
Collaborator Author

I have rebased this PR on the top of the latest upstream master branch. I have renamed the rule and started using it in RHEL 9 and RHEL 10 CIS control files.

@jan-cerny
Copy link
Collaborator Author

I have rebased this PR on the top of the latest upstream master branch.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Used by openshift-ci bot. label Nov 5, 2025
@jan-cerny
Copy link
Collaborator Author

I have rebased this PR on the top of the latest upstream master branch.

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Used by openshift-ci bot. label Nov 5, 2025
@ggbecker
Copy link
Member

ggbecker commented Nov 5, 2025

Also I believe that it is still valid to check for particular submodules in the crypto policy, for example there would still have a need for the rule that checks if the current crypto policy respects a given security requirement (e.g. no weak mac), this rule would simply check if the submodule contains the right algorithm restriction, and the remediation can simply be reapply the expected sub crypto policy in case of deviation.

I'm not sure if I follow. Can you try to rephrase or explain this a little more? The current code in this PR contains OVAL that checks the contents of the submodule file (.pmod) file, I believe that this way it checks if the current crypto policy respects a given security requirement (e.g. no weak mac).

That is correct, I believe my concern is related to what I wrote on the following remark.

This would not imply a change in the CIS benchmarks for example, where they have a requirement for each of the restriction they expect.

Is your concern about the fact that after this change we would cover multiple controls with a single rule?

I'm concerned about covering multiple requirements by single rule as well. The previous PR #14050 has the configuration split into 4 different rules. That's better for the granularity, and I'd prefer that. However, it has a problem that when the remediation of a rule runs the update-crypto-policies command it adds the crypto policy sub module configured by the rule but removes the others because it has no information that there are other rules adding other modules. That's a blocker because the test fails and the final state after all 4 rules are applied isn't compliant. I couldn't find a solution for this.

Yes, my concern was that this change would cover multiple controls with a single rule.

I think one approach is for these fine granular rules to have the same remediation as the rule proposed in this pull request, so it would simply reapply the same custom crypto-policy (with all the requirements from the individual controls) if any of the individual rule is failing. You lose a bit the control of what is remediating and may lose some more customization made by the user, but on the other hand you can't really remediate them individually.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 6, 2025
@jan-cerny jan-cerny added RHEL9 Red Hat Enterprise Linux 9 product related. RHEL10 Red Hat Enterprise Linux 10 product related. Update Rule Issues or pull requests related to Rules updates. Update Profile Issues or pull requests related to Profiles updates. Update Template Issues or pull requests related to Templates updates. and removed do-not-merge/work-in-progress Used by openshift-ci bot. labels Nov 6, 2025
@jan-cerny jan-cerny changed the title Fix crypto policy settings in RHEL 8 CIS Fix crypto policy settings in CIS Nov 6, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 6, 2025
Add a new rule `crypto_sub_policies_cis_rhel8` that configures multiple
custom crypto sub policy modules for RHEL 8 CIS. The new rule is very
similar to `fips_custom_stig_sub_policy`. It configures new modules for
system wide crypto policies that reduces the set of usable ciphers in
sshd, MACs, and others.

The rule is templated by a new template `crypto_sub_policies` that is
also introduced in this commit so that the code can be reused in other
similar rules.

This change aligns the RHEL 8 CIS profiles in CaC with the CIS RHEL 8
Benchmark v4.0.0 requirements. All crypto requirements of this profile
are now covered by this single rule. The reason for merging all of the
sub module configuration is to prevent overriding crypto policy
settings. If there would be multiple rules, each of them would call
the `update-crypto-policies` commands with a different sub policy,
overriding each other.

This supersedes ComplianceAsCode#14050

Resolves: https://issues.redhat.com/browse/RHEL-111896
I have checked the latest versions of RHEL 9 and RHEL 10 CIS Benchmarks
and I found they also use the approach to configure cryptography by
creating custom crypto policy sub modules. They are very similar to the
RHEL 8 bu sometimes with different values.
In this commit, we will start using the rule configure_custom_crypto_policy_cis
in CIS for RHEL 9 and RHEL 10 as well, in a similar way to RHEL 8.
This change will allow users to create individual rules that
check just for a single crypto policy sub module.
They can do this by specifying the `specific_module` parameter
in the template parameters in their `rule.yml` files.
The parameter affects only OVAL. Remediations are identical
for all rules using this template with the same other parameters.
The problem is that rule `configure_custom_crypto_policy_cis` covers
multiple requirements in a single rule. That is insufficient granularity
for our project. We will solve this problem by introducing specialized
rules that check if the current crypto policy respects a given security
requirement (e.g. no weak mac), this rule would simply check if the
individual crypto policy sub module contains the right algorithm
restriction.  These fine granular rules have the same remediation as the
other rules using the `configure_custom_crypto_policy` template, so it
would simply reapply the same custom crypto-policy (with all the
requirements from the individual controls) if any of the individual rule
is failing.
RHEL 10 has removed SHA-1 algortihms from the DEFAULT crypto policy.
This means that there is no subpolicy for disabling SHA-1.
To satisfy the requirement to disable SHA-1 it's sufficient to simply
use the DEFAULT crypto policy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes to reported bugs. CIS CIS Benchmark related. do-not-merge/work-in-progress Used by openshift-ci bot. Highlight This PR/Issue should make it to the featured changelog. RHEL8 Red Hat Enterprise Linux 8 product related. RHEL9 Red Hat Enterprise Linux 9 product related. RHEL10 Red Hat Enterprise Linux 10 product related. Update Profile Issues or pull requests related to Profiles updates. Update Rule Issues or pull requests related to Rules updates. Update Template Issues or pull requests related to Templates updates.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants