-
Notifications
You must be signed in to change notification settings - Fork 756
CMP-3916: Fix sshd_disable_gssapi_auth remediation for Kubernetes #14108
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
base: master
Are you sure you want to change the base?
Conversation
Add shared Kubernetes configuration that disables GSSAPI authentication in SSHD by setting GSSAPIAuthentication to 'no' with higher priority. This is necessary because the default 50-redhat.conf file contains GSSAPIAuthentication set to 'yes', which must be overridden for compliance requirements.
|
/test e2e-aws-openshift-node-compliance |
|
/retest-required |
|
The rule fail_sshd_disable_gssapi_auth still fail with the PR: |
| # disruption = low | ||
| {{{ kubernetes_sshd_set() }}} | ||
| --- | ||
| {{{ kubernetes_sshd_dropin('GSSAPIAuthentication no', config_basename='75-complianceascode-sshd_disable_gssapi_auth.conf') }}} |
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 wonder if we just want to make this change for all k8s remediations - https://github.com/ComplianceAsCode/content/blob/master/shared/templates/sshd_lineinfile/kubernetes.template#L11
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.
SSHD configuration is processed lexographically and uses the first found value:
Unless noted otherwise, for each keyword, the first obtained value will be used.
https://man.openbsd.org/sshd_config
This remediation will come after the 50-*.conf settings.
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.
Can we keep this remediation in the distributed config so that it doesn't conflict with the 50-redhat.conf value, which sets this parameter to yes and the rule can't determine which one to use.
…g from '75-complianceascode-sshd_disable_gssapi_auth.conf' to '00-complianceascode-sshd_disable_gssapi_auth.conf' to ensure higher priority in SSHD settings for compliance requirements.
|
verification fail with a397a93:
|
| # disruption = low | ||
| {{{ kubernetes_sshd_set() }}} | ||
| --- | ||
| {{{ kubernetes_sshd_dropin('GSSAPIAuthentication no', config_basename='00-complianceascode-sshd_disable_gssapi_auth.conf') }}} |
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 we have to find a way to write this to the old configuration file (/etc/ssh/sshd_config) so that we don't end up with multiple values in the same directory. The rule doesn't know to use the 00-complianceascode-* value instead of the one in 50-redhat.conf.
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.
Are we able to try something like this to see if it only sets the parameter once?
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_disable_gssapi_auth/kubernetes/shared.yml b/linux_os/guide/services/ssh/ssh_server/sshd_disable_gssapi_auth/kubernetes/shared.yml
index c89d87fc25..456fb7d063 100644
--- a/linux_os/guide/services/ssh/ssh_server/sshd_disable_gssapi_auth/kubernetes/shared.yml
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_disable_gssapi_auth/kubernetes/shared.yml
@@ -3,6 +3,6 @@
# strategy = restrict
# complexity = low
# disruption = low
-{{{ kubernetes_sshd_set() }}}
+{{{ kubernetes_disable_sshd_config_option('GSSAPIAuthentication') }}}
---
-{{{ kubernetes_sshd_dropin('GSSAPIAuthentication no', config_basename='00-complianceascode-sshd_disable_gssapi_auth.conf') }}}
+{{{ kubernetes_disable_sshd_config_option_dropin('GSSAPIAuthentication') }}}
diff --git a/shared/macros/10-kubernetes.jinja b/shared/macros/10-kubernetes.jinja
index 15a7eea152..e66f7567b5 100644
--- a/shared/macros/10-kubernetes.jinja
+++ b/shared/macros/10-kubernetes.jinja
@@ -248,6 +248,29 @@ spec:
{{{ kubernetes_machine_config_file(path='/etc/ssh/sshd_config.d/' + config_basename, file_permissions_mode='0600', source=sshd_dropin_content, ocp_version_range=ocp_version_range) }}}
{{%- endmacro -%}}
+{{#
+ Disable SSH options in existing configuration files.
+
+ GSSAPI authentication is enabled by default in
+ `/etc/ssh/sshd_config.d/50-redhat.com`. Using a drop-in file for another
+ parameter in the same directory breaks the rule. Even if the drop-in file is
+ placed correctly, and disables the GSSAPI, the rule still detects that there
+ is a string in `/etc/ssh/sshd_config.d/50-redhat.conf` that has
+ `GSSAPIAuthentication yes`.
+
+ We need this specific macro so that we can override the setting in
+ `/etc/ssh/sshd_config.d/50-redhat.conf` on 4.13+ and `/etc/ssh/sshd_config` on
+ 4.12.
+
+#}}
+{{%- macro kubernetes_disable_existing_sshd_config_option(parameter) -%}}
+{{{ kubernetes_machine_config_file(path='/etc/ssh/sshd_config', file_permissions_mode='0600', source=parameter + ' no' , ocp_version_range='<4.13.0') }}}
+{{%- endmacro -%}}
+
+{{%- macro kubernetes_disable_existing_sshd_config_dropin(parameter) -%}}
+{{{ kubernetes_machine_config_file(path='/etc/ssh/sshd_config.d/50-redhat.conf', file_permissions_mode='0600', source=parameter + ' no' , ocp_version_range='>=4.13.0') }}}
+{{%- endmacro -%}}
+
{{% macro usbguard_config_source() %}}
#Updated the shared Kubernetes configuration to disable GSSAPI authentication by introducing new macros. This change ensures compliance by overriding the default settings in `/etc/ssh/sshd_config.d/50-redhat.conf` and `/etc/ssh/sshd_config` for different OpenShift versions.
|
@Vincent056: The following test failed, say
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-sigs/prow repository. I understand the commands that are listed here. |
|
Override the file /etc/ssh/sshd_config.d/50-redhat.conf might not be a good idea. There are several configurations in the file before auto-remediations applied; however, most of the configurations will disappear after auto remediation applied. After the remediation applied: |
Add shared Kubernetes configuration that disables GSSAPI authentication in SSHD by setting GSSAPIAuthentication to 'no' with higher priority. This is necessary because the default
50-redhat.conffile contains GSSAPIAuthentication set to 'yes', which must be overridden for compliance requirements.