fix(cfg): don't fail CNI file checks when host-local IPAM dir is absent - #2120
Open
lexfrei wants to merge 1 commit into
Open
fix(cfg): don't fail CNI file checks when host-local IPAM dir is absent#2120lexfrei wants to merge 1 commit into
lexfrei wants to merge 1 commit into
Conversation
Checks 1.1.9 and 1.1.10 audit Container Network Interface file permissions and ownership by running `find /var/lib/cni/networks`. That path is the host-local IPAM state store, which only the flannel CNI populates. On clusters using a CNI with its own IPAM (Cilium, Calico, ...) the directory does not exist, so `find` returns nothing. An empty audit makes the use_multiple_values test match zero values, which scores as a hard FAIL where these checks are Automated and as WARN elsewhere -- a false positive unrelated to any real file permission or ownership problem. Make the audit tolerate an absent or empty directory: when no host-local IPAM files are present, emit a passing sentinel value so the check reports PASS. When files do exist, their real permissions and ownership are still evaluated, so genuine problems continue to fail. Also exclude the host-local `lock` file (created 0750) from the permission check so it no longer trips the 600 bitmask. Profiles updated (both 1.1.9 and 1.1.10): - k3s-cis-1.7, k3s-cis-1.8, k3s-cis-1.9 - rke-cis-1.7, rke-cis-1.23, rke-cis-1.24 - rke2-cis-1.7, rke2-cis-1.8, rke2-cis-1.23 Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
lexfrei
force-pushed
the
fix/cni-file-checks-tolerate-absent-ipam-dir
branch
from
August 14, 2026 08:38
b2b8e82 to
602d2b4
Compare
Author
|
Rebased onto current main, no conflicts. CI here hasn't run at all, the workflow is sitting in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Checks 1.1.9 and 1.1.10 audit CNI file permissions/ownership by running
find /var/lib/cni/networks. That directory is the host-local IPAM state store, populated only by CNIs that use host-local IPAM (e.g. the flannel backend that ships as the k3s default). Under a CNI with its own IPAM (Cilium, Calico, ...) the directory does not exist,findreturns nothing, and an emptyuse_multiple_valuesaudit is scored as FAIL (Automated profiles) or WARN (Manual profiles) — a false positive unrelated to any real permission or ownership problem. See #2119.Change
Rewrite the 1.1.9/1.1.10 audit so an absent or empty
/var/lib/cni/networksyields a passing sentinel value (permissions=<mode>/root:root) instead of an empty result. When host-local IPAM files do exist, their real permissions and ownership are still evaluated, so genuine issues continue to fail. The host-locallockfile (created 0750) is also excluded from the permission check so it no longer trips the 600 bitmask (previously only 1.1.9 in the k3s profiles excluded it).Profiles touched (both 1.1.9 and 1.1.10):
k3s-cis-1.7,k3s-cis-1.8,k3s-cis-1.9(single-command audit)rke-cis-1.7,rke-cis-1.23,rke-cis-1.24rke2-cis-1.7,rke2-cis-1.8,rke2-cis-1.23(two-command audit)Not touched, by design:
k3s-cis-1.23/k3s-cis-1.24already mark these checkstype: skip.rke2-cis-1.241.1.10 already guards with anelse echo "File not found"branch andbin_op: or.cis-*profiles keep these checks Manual (WARN) and stay aligned with upstream CIS; I left them as-is to avoid changing the CIS baseline. Happy to extend the same tolerance there if you prefer uniform coverage.Validation
Audit logic tested in isolation for both audit shapes: absent directory → passing sentinel; a real 600 file →
permissions=600; a real 644 file →permissions=644(the failing value still surfaces); a 0750lockfile → excluded.End-to-end on a k3s node running Cilium (
/var/lib/cni/networksabsent), same binary, config-dir difference only:Alternative considered
Aligning the k3s/rke/rke2 profiles to
scored: false(WARN), matching the genericcis-*profiles, would hide the hard FAIL but also stop flagging real permission/ownership problems on clusters that do use host-local IPAM. The audit-tolerance approach keeps the checks Automated and meaningful for those clusters while removing the false positive on the others, so I chose it over down-scoring. A third option — thetype: skipused byk3s-cis-1.23/1.24— disables the check even where it is valid; audit-tolerance is a strict improvement over that and could replace those skips in a follow-up.Fixes #2119