Skip to content
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

RHEL 8/9 - configure_usbguard_auditbackend results in notapplicable and in final scan in fail #8487

Closed
mildas opened this issue Apr 4, 2022 · 17 comments
Assignees
Labels
productization-issue Issue found in upstream stabilization process.

Comments

@mildas
Copy link
Contributor

mildas commented Apr 4, 2022

Description of problem:

The configure_usbguard_auditbackend rule results in notapplicable, because platform: usbguard is not met.
Then during remediations, usbguard is installed which causes configure_usbguard_auditbackend fail results in final scan.

SCAP Security Guide Version:

a8eee3a

Operating System Version:

RHEL 9

Steps to Reproduce:

  1. python3 tests/test_suite.py profile --libvirt qemu:///system test_suite_vm --datastream /tmp/ssg-rhel9-ds.xml --xccdf-id scap_org.open-scap_cref_ssg-rhel9-xccdf-1.2.xml --mode online --remediate-using oscap xccdf_org.ssgproject.content_profile_ospp

Actual Results:

xccdf_org.ssgproject.content_rule_configure_usbguard_auditbackend - fail

Expected Results:

xccdf_org.ssgproject.content_rule_configure_usbguard_auditbackend - pass

@mildas mildas added the productization-issue Issue found in upstream stabilization process. label Apr 4, 2022
@mildas
Copy link
Contributor Author

mildas commented Apr 4, 2022

The issue got introduced in #8445
@Xeicker @jan-cerny

@mildas
Copy link
Contributor Author

mildas commented Apr 4, 2022

Relevant also on RHEL8

@mildas mildas changed the title RHEL 9 - configure_usbguard_auditbackend results in notapplicable and in final scan in fail RHEL 8/9 - configure_usbguard_auditbackend results in notapplicable and in final scan in fail Apr 4, 2022
@Xeicker
Copy link
Contributor

Xeicker commented Apr 4, 2022

I think this is actually related on how the remediation is generated or applied. Because the remediation for configure_usbguard_auditbackend never runs, even thought it manages the notapplicable scenario.

This would also be an issue on any environment which doesn't have installed by default the package mentioned in the platform section

@jan-cerny
Copy link
Collaborator

Thanks for reporting this problem. Do you think that this can be solved by ordering of rules?

@rhmdnd
Copy link
Collaborator

rhmdnd commented Apr 5, 2022

We're experiencing this in the OCP4 CI for fedramp high and moderate profiles.

#8452

@mildas
Copy link
Contributor Author

mildas commented Apr 6, 2022

@jan-cerny I don't think this can be solved by ordering. Correct me if I'm wrong, but openscap-scanner remediates only rules that resulted in fail during scan phase. And configure_usbguard_auditbackend doesn't fail.

Workaround is running oscap xccdf eval --remediate twice. That would scan and fix configure_usbguard_auditbackend because usbguard platform gets fulfilled by first remediations run.

@rhmdnd
Copy link
Collaborator

rhmdnd commented Apr 6, 2022

In the OCP case, we have an end-to-end test that ensures we have the same number of checks at the start and end of the test, which scans and remediates an environment using various profiles. The test applies the remediation after the first scan, which results in two additional rules in subsequent scans, breaking the assumption we had that checks shouldn't increase, or decrease, during the test. We don't update content in-between scans.

If a remediation installs a package, and if CPEs are used for package checks, then we can't say checks won't change between scans.

Is that the intended usage for CPEs? I was under the impression CPEs were for immutable system details, but maybe that's wrong?

@jan-cerny
Copy link
Collaborator

@mildas thanks, that sounds likely

Ordering would help if the remediation would be executed right after rule is evaluated before evaluating the next rule. Then, a remediation for package_usbguard_installed could be executed before configure_usbguard_auditbackend is evaluated. But OpenSCAP doesn't work this way. So ordering doesn't help and you need to remediate twice.

@ggbecker
Copy link
Member

In the OCP case, we have an end-to-end test that ensures we have the same number of checks at the start and end of the test, which scans and remediates an environment using various profiles. The test applies the remediation after the first scan, which results in two additional rules in subsequent scans, breaking the assumption we had that checks shouldn't increase, or decrease, during the test. We don't update content in-between scans.

If a remediation installs a package, and if CPEs are used for package checks, then we can't say checks won't change between scans.

Is that the intended usage for CPEs? I was under the impression CPEs were for immutable system details, but maybe that's wrong?

CPEs also cover applicability of applications which is usually denoted by the prefix cpe:/a. In our project we already had many of these CPEs, so it's natural that eventually a problem like this would occur. In my opinion we should not assume that applicability stays the same, on the other hand we are still uncertain how to treat properly this kind of issue. In terms of rules passing, usually a second round of remediation solves the it.

@mildas mildas added the first-boot-remediation first-boot-remediation update. label May 3, 2022
@mildas
Copy link
Contributor Author

mildas commented May 5, 2022

First boot remediation doesn't help as this problem is also in remediating already installed systems.

@yuumasato
Copy link
Member

What if we relied on xccdf:requires instead of xccdf:platform for these rules?

With xccdf:platform, rules that configure a package that is not installed will evaluate to notapplicable.
If the profile has a rule to install the package, a second remediation run is necessary.
If the profile doesn't install the package the rule will keep evaluating to not applicable (Basically configure the package if it is installed, but ignore the rule otherwise).

With xccdf:requires, rules that configure a package will evaluate to false (as long as the required rule that installs the package is selected in the profile).
If a profile selects the required rule, both rules will evaluate to fail in the first run, and both rules will be remediated.
If the profile doesn't select the required rule, it means the profile doesn't care about the package, and very likely the rule configuring the package should not even be selected.
The use of xccdf:requires would kill the behavior of "configure a package if it is installed, but ignore it otherwise".

@yuumasato
Copy link
Member

Well, I just realize that another approach is to remove xccdf:platform and not add anything.

What would we lose or miss if configure_usbguard_auditbackend dropped its platform: usbguard?

@yuumasato
Copy link
Member

yuumasato commented Jun 17, 2022

It looks like there is demand for the behavior of "configure a package if it is installed, but ignore it otherwise":
Note: If the USBGuard daemon is not installed and enabled, this requirement is not applicable.
https://vaulted.io/library/disa-stigs-srgs/red_hat_enterprise_linux_8_security_technical_implementation_guide/V-230470

But the RHEL8 STIG profile selects the rule package_usbguard_installed, so the profile is already making the choice.
Anyone who wants to not install usbgard will have to tailor the rule out, and in this case they could also tailor other usbguard rules out....

@mildas
Copy link
Contributor Author

mildas commented Jun 17, 2022

Both options - replacing platform with requires or dropping platform - sounds good to me.

All our profiles with configure_usbguard_auditbackend also select package_usbguard_installed so our shipped content doesn't configure not installed package. If anyone wants to tailor it out, then it's theirs responsibility to tailor configuration rules our too.

@mildas
Copy link
Contributor Author

mildas commented Aug 11, 2022

There is no easy fix - must be fixed on scanner side.

@mildas mildas added the blocked Issue that can't be fixed in content. label Aug 11, 2022
@jan-cerny
Copy link
Collaborator

@mildas Can you explain how it should be fixed?

@matusmarhefka
Copy link
Member

Closing, reported an issue in openscap - OpenSCAP/openscap#1880

@matusmarhefka matusmarhefka removed the blocked Issue that can't be fixed in content. label Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
productization-issue Issue found in upstream stabilization process.
Projects
None yet
Development

No branches or pull requests

7 participants