Replace SCE checks with OVAL for all_apparmor_profiles_enforced and c…#14773
Conversation
…heck_ufw_active SCE scripts are executed by OpenSCAP by writing them to /tmp and running them. When /tmp has the noexec mount option (required by CIS 1.1.2.4), the scripts fail silently, producing incorrect results. - all_apparmor_profiles_enforced: add OVAL check that counts profiles in /sys/kernel/security/apparmor/profiles and verifies all are in enforce mode; remove sce/shared.sh; extend bash remediation to Debian products. - check_ufw_active: add OVAL check that reads ENABLED=yes from /etc/ufw/ufw.conf; add bash remediation for Debian; remove sce/shared.sh. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @israel-villar. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
The rule already has an OVAL check (oval/shared.xml) that verifies the sum of enforced + complaining profiles equals the total loaded profiles. The SCE script fails silently when /tmp has the noexec mount option (required by CIS 1.1.2.4), since OpenSCAP writes scripts to /tmp before executing them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I think we shouldn't remove the SCE checks, they can be useful for many users. OVAL checks can coexist with SCEs in the rule. If a rule has both OVAL and SCE, OVAL is used by default. Users can specify their preference of SCEs over OVAL by setting OSCAP_PREFERRED_ENGINE=SCE environment variable. So I'd prefer keeping SCEs and adding OVALs alongside them. I'm puzzled by the issue you have that when /tmp has the noexec mount option, the scripts fail silently producing incorrect results. This was an issue in past but it should be fixed in OpenSCAP since version 1.3.2 by OpenSCAP/openscap#1418. Today I tried to install a fresh VM with a separate /tmp partition with noexec flag and SCE scripts were executed normally and didn't fail at all. I tried this on RHEL 9 with OpenSCAP 1.3.13, so there might be some Ubuntu-specific problem that I miss. Could you share more details about your issue ( OpenSCAP version, ARF results, specific rules, ...)? |
|
@israel-villar We now found that somebody had the same problem before: OpenSCAP/openscap#2243 (comment) |
OVAL and SCE can coexist: OVAL is used by default, SCE remains available via OSCAP_PREFERRED_ENGINE=SCE for users who prefer it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Redesign OVAL: check for absence of non-enforce profiles instead of comparing counts. The previous count-based approach returned error instead of fail when no enforced profiles existed, because OpenSCAP returns an empty variable (not 0) when the source object has no items. - Fix test scenarios: make rsyslog restart non-fatal. Debian 13 does not install rsyslog by default, causing setup scripts to exit with code 5. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jan-cerny As you suggested in your previous comment, we've restored the SCE checks so they coexist with the new OVAL checks — OVAL will be used by default, and users can opt into SCE via OSCAP_PREFERRED_ENGINE=SCE. Regarding the /tmp noexec issue: you were right, installing openscap-utils (which provides oscap-run-sce-script) fixed it. The package was missing from our test environment. We confirmed this on a Debian 13 VM with OpenSCAP 1.4.2, with /tmp explicitly mounted noexec — SCE scripts execute correctly. We also found and fixed two issues while testing:
|
…heck_ufw_active
SCE scripts are executed by OpenSCAP by writing them to /tmp and running them. When /tmp has the noexec mount option (required by CIS 1.1.2.4), the scripts fail silently, producing incorrect results.
Description:
all_apparmor_profiles_enforced: addoval/shared.xmlthat reads/sys/kernel/security/apparmor/profilesand verifies all profiles arein enforce mode; remove
sce/shared.sh; extend bash remediation toDebian products.
check_ufw_active: addoval/shared.xmlthat checksENABLED=yesin
/etc/ufw/ufw.conf; addbash/shared.shfor Debian and Ubuntu;remove
sce/shared.sh.Rationale:
/tmpand runningthem. When
/tmphas thenoexecmount option — required byCIS 1.1.2.4 — the scripts fail silently, producing incorrect scan
results.
Review Hints:
debian13andubuntu2404to verify no regression:./build_product debian13 --datastream-only./build_product ubuntu2404 --datastream-only/tmpwithnoexecandscan with the SCE-based content — both rules return pass regardless
of system state.