Skip to content

Refactors and rules for RHEL7 DISA STIG #7827

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

Closed

Conversation

lenox-joseph
Copy link
Contributor

@lenox-joseph lenox-joseph commented Nov 4, 2021

Description:

  • sshd_disable_x11_forwarding: Set the parameter to fail if not present.
  • display_login_attempts: Refactor into a DISA specific rule for RHEL7.
  • Make numerous ssh_server checks explicit.
  • Add audit rules for create_module under RHEL7.
  • Add audit rule for RHEL to audit kmod.
  • Tighten up regex for sshd cipher/mac

Rationale:

  • sshd_disable_x11_forwarding: On RHEL7, a missing parameter does not necessarily mean that X11 forwarding is disabled. DISA's SCAP checks will fail this step without the parameter set. For safety, we set the parameter explicitly.
  • display_login_attempts: DISA has different requirements than CIS and the current rule fails DISA's SCAP checks.
  • ~~DISA SCAP requires these to be set to pass, and it's generally better to set what you want/need rather than rely on defaults (that may change w/o warning on an upgrade). ~~
  • DISA stig requires auditing create_module.
  • DISA stig requires auditing uses of kmod RHEL-07-030840.

@openshift-ci
Copy link

openshift-ci bot commented Nov 4, 2021

Hi @lenox-joseph. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Nov 4, 2021

references:
disa: CCI-000130,CCI-000169,CCI-000172,CCI-002884
nist: AU-3,AU-3.1,AU-12(a),AU-12.1(ii),AU-12.1(iv)AU-12(c),MA-4(1)(a)
srg: SRG-OS-000037-GPOS-00015,SRG-OS-000042-GPOS-00020,SRG-OS-000062-GPOS-00031,SRG-OS-000392-GPOS-00172,SRG-OS-000462-GPOS-00206,SRG-OS-000471-GPOS-00215,SRG-OS-000471-GPOS-00216,SRG-OS-000477-GPOS-00222
stigid@rhel7: RHEL-07-030840
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only addition to the reference list and its only use.

@openshift-ci openshift-ci bot added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Nov 4, 2021
@Mab879
Copy link
Member

Mab879 commented Nov 4, 2021

/ok-to-test

@ggbecker
Copy link
Member

ggbecker commented Nov 4, 2021

Description:

* `sshd_disable_x11_forwarding`: Set the parameter to fail if not present.

From https://linux.die.net/man/5/sshd_config I see that the X11Forwarding is defaulted to "no". So I assume the default would be enough. Is that a different case in RHEL7?

X11Forwarding Specifies whether X11 forwarding is permitted. The argument must be ''yes'' or ''no''. The default is ''no''.

* Make numerous `ssh_server` checks explicit.

There has been some conversations around what path to take here. We though at first that using accepting the default value for options that are secure by default was a good idea. But then it makes misaligned with DISA content.

* Add audit rule for RHEL to audit kmod.

The rule is slightly different than DISA STIG RHEL8, we may have to adapt something to be strictly equal to DISA STIG RHEL7

Rationale:

* `sshd_disable_x11_forwarding`: On RHEL7, a missing parameter does not necessarily mean that X11 forwarding is disabled. DISA's SCAP checks will fail this step without the parameter set. For safety, we set the parameter explicitly.

* `display_login_attempts`: DISA has different requirements than CIS and the current rule fails DISA's SCAP checks.

@lenox-joseph
Copy link
Contributor Author

lenox-joseph commented Nov 4, 2021 via email

@lenox-joseph
Copy link
Contributor Author

lenox-joseph commented Nov 4, 2021 via email

@lenox-joseph
Copy link
Contributor Author

lenox-joseph commented Nov 4, 2021 via email

@ggbecker
Copy link
Member

ggbecker commented Nov 4, 2021

So if I am splitting a product out from the rule, the CCE gets burned? That doesn't seem to make a lot of sense to me

No, you keep the old CCEs in the rule. And add new CCEs to the new rule. Also, we have already some rules suffixed by _stig.yml instead of _disa.yml, so you may want to rename the rule.

@lenox-joseph
Copy link
Contributor Author

lenox-joseph commented Nov 4, 2021 via email

@ggbecker
Copy link
Member

ggbecker commented Nov 4, 2021

So there will be a CCE attached to a rule that doesn't have the platform attached to it at all? Ooookay

I'm not sure if I understand your platform concept here. But CCE is used to identify uniquely a rule. These CCE numbers are provided by NIST and we can use them to assign to rules and later we notify them which rules received which CCE and they put into their database. So it doesn't make sense to simply move the CCE to a new rule, since the older one is still being used by many other profiles and we would also lose the sense of uniqueness.

@openshift-ci openshift-ci bot added the needs-rebase Used by openshift-ci bot. label Nov 4, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Used by openshift-ci bot. label Nov 4, 2021
@@ -274,7 +276,7 @@ selections:
- sshd_disable_user_known_hosts
- chronyd_or_ntpd_set_maxpoll
- service_firewalld_enabled
- display_login_attempts
- display_login_attempts_stig
Copy link
Member

Choose a reason for hiding this comment

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

I still believe we can extend display_login_attempts to accommodate any change required for STIG. Can you point out the reason why you decided to split the rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commit is older than your last changes that stripped silent. I've removed the split rule.

@@ -31,7 +31,7 @@

<ind:textfilecontent54_object id="obj_sshd_use_approved_ciphers_ordered_stig" version="1">
<ind:filepath>/etc/ssh/sshd_config</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*(?i)Ciphers(?-i)[\s]+(?=[\w]+)(aes256-ctr(?=[\w,]+|$),?)?(aes192-ctr(?=[\w,]+|$),?)?(aes128-ctr)?[\s]*(?:#.*)?$</ind:pattern>
<ind:pattern operation="pattern match">^[\s]*[Cc]iphers[\s]+(?=\w)(aes256-ctr(?=[\w,-@]+|$),?)?(aes192-ctr(?=[\w,-@]+|$),?)?(aes128-ctr(?=[\w,-@]+|$),?)?[\s]*(?:#.*)?$</ind:pattern>
Copy link
Member

Choose a reason for hiding this comment

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

From: https://man7.org/linux/man-pages/man5/sshd_config.5.html

The possible keywords and their meanings are as follows (note that
     keywords are case-insensitive and arguments are case-sensitive):

It means that CIpHeRS should also be accepted for example.

Also your regex doesn't match a line with trailing whitespace. I don't know exactly why but the previous one accepted it

I use this website to test regexes: https://regex101.com/

Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what's the intent behind these changes? Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've got a use case where I need to adhere more closely to DISA (after remediation, I expect DISA's upstream rules to be evaluated on the system by a separate auditor), and I was looking for a path of less resistance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've sent an email up to DISA; what I'll do right now is add a couple tests with CIpHeRs and trailing whitespace and adjust the regex to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trailing whitespace isn't marked as "pass" for the original regex either. I think that it's allowed, but not referenced at all in sshd_config(5).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^[\s]*(?i)Ciphers(?-i)[\s]+(?=\w)(aes256-ctr(?=[\w,-@]+|$),?)?(aes192-ctr(?=[\w,-@]+|$),?)?(aes128-ctr(?=[\s\w,-@]+|$),?)?[\s]*(?:#.*)?[\s]*$

Does catch trailing whitespace. Since DISA wouldn't return pass for 'Ciphers aes256-ctr,aes192-ctr,aes128-ctr ', however, I don't think we should either without a strong reason to do so.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the original (?i)Ciphers(?-i) should be enough to cover the case-insensitivity, although I don't really believe that people will use CIpHeRs in their SSH configuration files.

@Mab879
Copy link
Member

Mab879 commented Nov 15, 2021

/retest

@lenox-joseph
Copy link
Contributor Author

Looking at the text it looks like it's in the cluster infrastructure? Not something I can test locally.

@Mab879
Copy link
Member

Mab879 commented Nov 16, 2021

/retest

@lenox-joseph
Copy link
Contributor Author

/retest

@lenox-joseph lenox-joseph force-pushed the upstream-merge branch 2 times, most recently from 2439eb0 to 1ec6270 Compare November 22, 2021 16:11
@Mab879
Copy link
Member

Mab879 commented Mar 30, 2022

/retest

@lenox-joseph lenox-joseph requested a review from ggbecker April 21, 2022 19:23
@vojtapolasek vojtapolasek modified the milestones: 0.1.62, 0.1.63 May 16, 2022
@lenox-joseph lenox-joseph requested a review from a team as a code owner May 17, 2022 20:38
@codeclimate
Copy link

codeclimate bot commented May 17, 2022

Code Climate has analyzed commit d13bfb2 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 2

View more on Code Climate.

@Mab879 Mab879 removed their assignment Jun 15, 2022
… different requirements than CIS, etc and the existing rule fails 3rd-party checks from DISA.

Add rule for RHEL7 to cover auditing create_module.

Add RHEL7 to list of production items for auditing kmod.

Fixed STIG rule sshd_disable_x11_forwarding

Updated sshd ciphers/macs regex's to fix false failure.
Implement Bash remediation for RHEL7.
…watch` and `skip_action` for

audit_rules_privleged_commands.
Revise template to use ssg.utils function.
@openshift-ci
Copy link

openshift-ci bot commented Jun 21, 2022

@lenox-joseph: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-rhcos4-e8 e33667a link true /test e2e-aws-rhcos4-e8
ci/prow/e2e-aws-ocp4-cis-node e33667a link true /test e2e-aws-ocp4-cis-node
ci/prow/e2e-aws-ocp4-moderate-node e33667a link true /test e2e-aws-ocp4-moderate-node
ci/prow/e2e-aws-ocp4-high-node e33667a link true /test e2e-aws-ocp4-high-node
ci/prow/e2e-aws-rhcos4-moderate e33667a link true /test e2e-aws-rhcos4-moderate
ci/prow/e2e-aws-rhcos4-high e33667a link true /test e2e-aws-rhcos4-high
ci/prow/e2e-aws-ocp4-stig-node e33667a link true /test e2e-aws-ocp4-stig-node

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@marcusburghardt marcusburghardt added STIG STIG Benchmark related. RHEL7 Red Hat Enterprise Linux 7 product related. and removed DISA RHEL7 STIG Alignment labels Jun 23, 2022
@openshift-ci
Copy link

openshift-ci bot commented Jul 9, 2022

@lenox-joseph: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the needs-rebase Used by openshift-ci bot. label Jul 9, 2022
@yuumasato yuumasato modified the milestones: 0.1.63, 0.1.64 Jul 19, 2022
@lenox-joseph
Copy link
Contributor Author

Closing as DISA decided to change its check syntax instead and the changes that needs to be implemented can be easier done as single PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Used by openshift-ci bot. ok-to-test Used by openshift-ci bot. RHEL Red Hat Enterprise Linux product related. RHEL7 Red Hat Enterprise Linux 7 product related. STIG STIG Benchmark related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants