Skip to content

add service_auditd_enabled ignition remediation #5162

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

Merged
merged 1 commit into from
Mar 12, 2020

Conversation

mrogers950
Copy link
Collaborator

I've been testing this out but it's not working yet; First I logged into a node and ran systemctl disable auditd to test this out. The scan runs, but there's no hit for the disabled systemd unit. I poked around for the service disable code, I noticed the following in the jinja macros:

{{%- macro systemd_ocil_service_disabled(service) %}}
    To check that the <code>{{{ service }}}</code> service is disabled in system boot configuration, run the following command:
    <pre>$ systemctl is-enabled <code>{{{ service }}}</code></pre>
    Output should indicate the <code>{{{ service }}}</code> service has either not been installed,
    or has been disabled at all runlevels, as shown in the example below:
    <pre>$ systemctl is-enabled <code>{{{ service }}}</code><br/> disabled</pre>

    Run the following command to verify <code>{{{ service }}}</code> is not active (i.e. not running) through current runtime configuration:
    <pre>$ systemctl is-active {{{ service }}}</pre>

    If the service is not running the command will return the following output:
    <pre>inactive</pre>

    By default the service will also be masked, to check that the <code>{{{ service }}}</code> is masked, run the following command:
    <pre>$ systemctl show <code>{{{ service }}}</code> | grep "LoadState\|UnitFileState"</pre>

    If the service is masked the command will return the following outputs:

    <pre>LoadState=masked</pre>

    <pre>UnitFileState=masked</pre>

{{%- endmacro %}}


{{%- macro systemd_ocil_service_enabled(service) %}}
    Run the following command to determine the current status of the
    <code>{{{ service }}}</code> service:
    <pre>$ systemctl is-active {{{ service }}}</pre>
    If the service is running, it should return the following: <pre>active</pre>
{{%- endmacro %}}

The service_disabled macro checks that the systemd unit is disabled, I was basically expecting the inverse for service_enabled, but it's a running check instead. I thought this might be why the check did not work, so I then tried killing auditd (making systemctl is-active return "inactive"), but no dice. I think I'm missing something else here..
/cc @JAORMX @jhrozek

@yuumasato
Copy link
Member

@mrogers950 Do you get pass result during evaluation?

The OCIL macros are instructions for manual checking and verification. They are not strictly exactly what the scanner is doing.

Looking up at the OVAL template for service enabled, it should pass when:

  • auditd is installed AND auditd is running AND the service is configured to start (enabled)

and the content does the service checks by using systemdunitdependency_test.

I remember that systemd probe support for offline mode is not implemented.
@evgenyz Do you think this could affect the scan?

@evgenyz
Copy link
Member

evgenyz commented Feb 21, 2020

The probe actually does not support offline mode. It was working in offline mode in 1.3.1 due to an error. Error was fixed in 1.3.2.

@evgenyz
Copy link
Member

evgenyz commented Feb 21, 2020

Probe uses DBus to communicate with systemd about modules status. In pure offline mode this would not work because we don't have the target system running. OpenShift's offline mode is different. I'd say it's a hybrid between online and offline modes, when you have your runtime knobs where they supposed to be (well, almost), but the root filesystem is elsewhere (not in '/').

We are planning to address this issue, but right now the probe is not usable.

@jhrozek
Copy link
Collaborator

jhrozek commented Feb 24, 2020

Probe uses DBus to communicate with systemd about modules status. In pure offline mode this would not work because we don't have the target system running. OpenShift's offline mode is different. I'd say it's a hybrid between online and offline modes, when you have your runtime knobs where they supposed to be (well, almost), but the root filesystem is elsewhere (not in '/').

We are planning to address this issue, but right now the probe is not usable.

Planning where? If there's an internal tracker feel free to reply via e-mail instead of here. It's almost certain that we'd need a variant of this check for other rules, so it would be nice to fix the issue...

@evgenyz
Copy link
Member

evgenyz commented Feb 24, 2020

We are planning to address this issue, but right now the probe is not usable.

Planning where? If there's an internal tracker feel free to reply via e-mail instead of here. It's almost certain that we'd need a variant of this check for other rules, so it would be nice to fix the issue...

We are planning to plan it. It is not yet even formulated. We are going to have some discussion about the whole "offline" approach and how to extend it this week. I'll make an update once we will have something.

@yuumasato
Copy link
Member

I have a vague memory of hearing / discussing that the some checks would have to be done via the MachineConfig fetched from the cluster / node. Hence the need for yamlfilecontent probe.

Is it the case that services enabled / disabled fall into this category?

@jhrozek
Copy link
Collaborator

jhrozek commented Mar 11, 2020

I have a vague memory of hearing / discussing that the some checks would have to be done via the MachineConfig fetched from the cluster / node. Hence the need for yamlfilecontent probe.

Is it the case that services enabled / disabled fall into this category?

I don't think so, we don't need to fetch anything from the node to learn that a service is enabled or running.

Copy link
Collaborator

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

The questions about the probe were discussed separately, it is one of the offline probes that needs fixing. However, the remediation as a whole is OK and we can merge it.

@yuumasato
Copy link
Member

Ok, thanks for clarification.

@yuumasato yuumasato added this to the 0.1.50 milestone Mar 11, 2020
@yuumasato yuumasato self-assigned this Mar 11, 2020
@yuumasato
Copy link
Member

@mrogers950 Do you plan to make changes to this PR? As it is marked WIP.

@mrogers950 mrogers950 changed the title [WIP] add service_auditd_enabled ignition remediation add service_auditd_enabled ignition remediation Mar 11, 2020
@mrogers950
Copy link
Collaborator Author

@yuumasato I've updated the PR, thanks!

@yuumasato yuumasato merged commit dd6392f into ComplianceAsCode:master Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants