-
Notifications
You must be signed in to change notification settings - Fork 795
Add rule crypto_policy_not_overridden for RHEL-09-672020 #14709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ggbecker
wants to merge
1
commit into
ComplianceAsCode:master
Choose a base branch
from
ggbecker:add-RHEL-09-672020
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...os/guide/system/software/integrity/crypto/crypto_policy_not_overridden/ansible/shared.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # platform = multi_platform_rhel,multi_platform_fedora,Oracle Linux 8,Oracle Linux 9 | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
| {{{ ansible_instantiate_variables("var_system_crypto_policy") }}} | ||
|
|
||
| - name: "{{{ rule_title }}} - Check if crypto policy is overridden" | ||
| ansible.builtin.command: /usr/bin/update-crypto-policies --check | ||
| register: crypto_policy_check | ||
| changed_when: false | ||
| failed_when: false | ||
| check_mode: false | ||
|
|
||
| - name: "{{{ rule_title }}} - Reinstall crypto-policies to restore back-end files" | ||
| ansible.builtin.command: dnf -y reinstall crypto-policies | ||
| become: true | ||
| when: crypto_policy_check.rc != 0 | ||
|
|
||
| - name: "{{{ rule_title }}} - Re-apply crypto policy" | ||
| ansible.builtin.command: /usr/bin/update-crypto-policies --set {{ var_system_crypto_policy }} | ||
| become: true | ||
| when: crypto_policy_check.rc != 0 | ||
23 changes: 23 additions & 0 deletions
23
linux_os/guide/system/software/integrity/crypto/crypto_policy_not_overridden/bash/shared.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # platform = multi_platform_all | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| {{{ bash_instantiate_variables("var_system_crypto_policy") }}} | ||
|
|
||
| dnf -y reinstall crypto-policies | ||
|
|
||
| stderr_of_call=$(update-crypto-policies --set "${var_system_crypto_policy}" 2>&1 > /dev/null) | ||
| rc=$? | ||
|
|
||
| if test "$rc" = 127; then | ||
| echo "$stderr_of_call" >&2 | ||
| echo "Make sure that the script is installed on the remediated system." >&2 | ||
| echo "See output of the 'dnf provides update-crypto-policies' command" >&2 | ||
| echo "to see what package to (re)install" >&2 | ||
| false | ||
| elif test "$rc" != 0; then | ||
| echo "Error invoking the update-crypto-policies script: $stderr_of_call" >&2 | ||
| false | ||
| fi |
35 changes: 35 additions & 0 deletions
35
linux_os/guide/system/software/integrity/crypto/crypto_policy_not_overridden/rule.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'Ensure System Cryptographic Policy Is Not Overridden' | ||
|
|
||
| description: |- | ||
| The system-wide cryptographic policy must not be overridden by individual | ||
| applications. All files in <tt>/etc/crypto-policies/back-ends/</tt> except for | ||
| <tt>nss.config</tt> should be symbolic links generated by the | ||
| <tt>update-crypto-policies</tt> tool. | ||
| Verify that the configured cryptographic policy has not been overridden by running: | ||
| <pre>$ sudo update-crypto-policies --check</pre> | ||
| The output should confirm the configured policy matches the generated policy. | ||
|
|
||
| rationale: |- | ||
| Centralized cryptographic policies simplify applying secure ciphers across an | ||
| operating system and the applications that run on that operating system. If | ||
| cryptographic policy back-end configurations are overridden, the system may use | ||
| weak or unapproved cipher suites, undermining the intended security posture. | ||
|
|
||
| severity: medium | ||
|
|
||
| identifiers: | ||
| cce@rhel9: CCE-86483-5 | ||
|
|
||
| references: | ||
| srg: SRG-OS-000396-GPOS-00176,SRG-OS-000393-GPOS-00173,SRG-OS-000394-GPOS-00174 | ||
|
|
||
| ocil_clause: 'the configured policy does not match the generated policy' | ||
|
|
||
| ocil: |- | ||
| Verify that the cryptographic policy has not been overridden by running: | ||
| <pre>$ sudo update-crypto-policies --check</pre> | ||
| If compliant, the output confirms the configured policy matches the generated policy. | ||
|
|
||
| platform: system_with_kernel and not osbuild |
12 changes: 12 additions & 0 deletions
12
linux_os/guide/system/software/integrity/crypto/crypto_policy_not_overridden/sce/shared.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # platform = multi_platform_rhel,multi_platform_fedora,Oracle Linux 8,Oracle Linux 9 | ||
| # check-import = stdout | ||
|
|
||
| update-crypto-policies --check | ||
| rc=$? | ||
|
|
||
| if [ $rc -eq 0 ]; then | ||
| exit "${XCCDF_RESULT_PASS}" | ||
| fi | ||
|
|
||
| exit "${XCCDF_RESULT_FAIL}" |
15 changes: 15 additions & 0 deletions
15
...tware/integrity/crypto/crypto_policy_not_overridden/tests/backend_file_overridden.fail.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash | ||
| # platform = multi_platform_rhel,multi_platform_fedora,Oracle Linux 8,Oracle Linux 9 | ||
| # packages = crypto-policies-scripts | ||
|
|
||
| # Start from a clean, fully applied state | ||
| update-crypto-policies --set DEFAULT | ||
|
|
||
| # Replace the gnutls backend symlink with a modified regular file to simulate | ||
| # a manual per-application override of the system crypto policy. | ||
| # update-crypto-policies --check regenerates the policy and byte-compares it | ||
| # against the back-ends directory, so any content change causes a failure. | ||
| BACKEND_FILE="/etc/crypto-policies/back-ends/gnutls.config" | ||
| content=$(cat "${BACKEND_FILE}") | ||
| rm -f "${BACKEND_FILE}" | ||
| printf '%s\n# manual override\n' "${content}" > "${BACKEND_FILE}" |
12 changes: 12 additions & 0 deletions
12
...re/integrity/crypto/crypto_policy_not_overridden/tests/config_changed_not_applied.fail.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| # platform = multi_platform_rhel,multi_platform_fedora,Oracle Linux 8,Oracle Linux 9 | ||
| # packages = crypto-policies-scripts | ||
|
|
||
| # Start from a clean, fully applied DEFAULT state | ||
| update-crypto-policies --set DEFAULT | ||
|
|
||
| # Change the config to a different policy without running update-crypto-policies. | ||
| # --check regenerates the policy from /etc/crypto-policies/config (now LEGACY) | ||
| # and compares it against the back-ends still generated for DEFAULT, so they | ||
| # will not match. | ||
| echo "LEGACY" > /etc/crypto-policies/config |
6 changes: 6 additions & 0 deletions
6
...ftware/integrity/crypto/crypto_policy_not_overridden/tests/correct_policy_applied.pass.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # platform = multi_platform_rhel,multi_platform_fedora,Oracle Linux 8,Oracle Linux 9 | ||
| # packages = crypto-policies-scripts | ||
|
|
||
| # Ensure the crypto policy is set and fully applied so --check passes | ||
| update-crypto-policies --set DEFAULT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| CCE-86483-5 | ||
| CCE-86484-3 | ||
| CCE-86492-6 | ||
| CCE-86494-2 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be either
multi_platform_allbecause that would apply for all products that the rule is part of orRed Hat Enterprise Linuxif we assume that it won't be reused.