Skip to content

feat(shield): unprivileged host-shield support for CIS benchmark checks#2591

Open
francesco-furlan wants to merge 7 commits intomainfrom
shield-host-unprivileged-caps
Open

feat(shield): unprivileged host-shield support for CIS benchmark checks#2591
francesco-furlan wants to merge 7 commits intomainfrom
shield-host-unprivileged-caps

Conversation

@francesco-furlan
Copy link
Copy Markdown
Contributor

@francesco-furlan francesco-furlan commented Apr 21, 2026

When running the host shield in unprivileged mode (host.privileged=false), KSPM Kubernetes & OpenShift CIS benchmark checks produce ~28 additional failures versus privileged mode. The failures fall in two categories:

  1. Missing Linux capabilities on the host-shield container

    • auditctl -l (Audit Log checks) fails with Operation not permitted — requires CAP_AUDIT_READ
    • iptables / nftables (firewall checks) fails with you must be root — requires CAP_NET_ADMIN
  2. Missing control-plane permissions on the host-shield ServiceAccount

    • ~12 checks fail with Forbidden when the KSPM analyzer queries clusterrolebindings, flowschemas, secrets, or runs pods/exec
    • On OpenShift, the analyzer additionally needs read access to securitycontextconstraints, kubeapiservers, and the config.openshift.io group (oauths, apiservers, networks, images)

Both categories are only exercised by Host Posture (KSPM); Host Vulnerability Management scans the filesystem via /host and does not need them. The gate is therefore features.posture.host_posture.enabled only, so VM-only deployments stay least-privileged.

Changes

  • templates/host/_helpers.tpl — append AUDIT_READ and NET_ADMIN to the non-privileged capability set when host posture is enabled.
  • templates/host/clusterrole.yaml — append the generic Kubernetes rules (clusterrolebindings/list, flowschemas/get,list, secrets/get, pods/exec/create) plus the OpenShift-specific block, both gated on host posture.
  • templates/common/_helpers.tpl — new common.is_openshift helper. Probes security.openshift.io/v1 (the same marker the existing SCC templates use) and honours extra_capabilities_api_versions for off-cluster rendering (e.g. ArgoCD server-side apply).
  • values.yaml / README.md — updated host.privileged comment to note that the required capabilities are granted automatically when disabled.
  • Chart.yaml — version bumped to 1.35.0.
  • Tests
    • New tests/host/clusterrole_test.yaml — 7 cases covering default (no rules), posture-only, VM-only (no new rules), OpenShift+posture, extra_capabilities_api_versions fallback, OpenShift but posture disabled, and labels/annotations propagation.
    • Expanded tests/host/security_context_test.yaml — posture-on adds AUDIT_READ/NET_ADMIN; posture-off and VM-only do not.

Checklist

  • Title of the PR starts with type and scope, (e.g. feat(agent,node-analyzer,sysdig-deploy):)
  • Chart Version bumped for the respective charts
  • Variables are documented in the README.md (or README.tpl in some charts)
  • Check GithubAction checks (like lint) to avoid merge-check stoppers
  • All test files are added in the tests folder of their respective chart and have a "_test" suffix

@francesco-furlan francesco-furlan requested a review from a team as a code owner April 21, 2026 11:04
When host.privileged=false on OpenShift, CIS benchmark scans fail on audit
rule queries (auditctl) and firewall inspection (iptables/nftables) because
the container lacks the required kernel capabilities. Grant AUDIT_READ and
NET_ADMIN automatically when Host Posture or Host Vulnerability Management
is enabled, and drop the "must be privileged" wording from the values.yaml
comment (no validation ever enforced it).
# Conflicts:
#	charts/shield/Chart.yaml
…checks

Grants the additional permissions required by the KSPM analyzer to run
Kubernetes & OpenShift CIS benchmark checks against the control plane.
Without these rules ~12 checks fail with "Forbidden" errors.

New rules are appended to templates/host/clusterrole.yaml and gated
behind the same feature flags already used in this branch for the
AUDIT_READ/NET_ADMIN capability additions:

  features.posture.host_posture.enabled OR
  features.vulnerability_management.host_vulnerability_management.enabled

Generic Kubernetes rules (clusterrolebindings list, flowschemas get/list,
secrets get, pods/exec create) render on any cluster under the posture/VM
gate. OpenShift-specific rules (security.openshift.io/scc,
operator.openshift.io/kubeapiservers, config.openshift.io/oauths etc.)
additionally require OpenShift detection.

OpenShift detection is factored into a new common.is_openshift helper in
templates/common/_helpers.tpl. It probes security.openshift.io/v1 —
the same marker the existing OpenShift SCC templates use and the example
documented in values.yaml — and honours extra_capabilities_api_versions
for off-cluster rendering (ArgoCD server-side apply).

Adds tests/host/clusterrole_test.yaml covering:
- default (no posture/VM) → no new rules
- posture enabled → 4 generic rules
- VM-only enabled → same generic rules
- OpenShift API detected + posture → generic + 3 OpenShift rule blocks
- extra_capabilities_api_versions fallback for OpenShift detection
- OpenShift detected but posture/VM disabled → no new rules
- labels/annotations propagation sanity check
@francesco-furlan francesco-furlan force-pushed the shield-host-unprivileged-caps branch from 13b0d39 to 15b7a8d Compare April 22, 2026 13:18
AUDIT_READ/NET_ADMIN and the control-plane RBAC rules
(clusterrolebindings, flowschemas, secrets, pods/exec, plus the
OpenShift SCC/operator/config rules) were previously gated on Host
Posture OR Host Vulnerability Management enabled. Only KSPM/CIS
benchmark checks need them — VM scans the host filesystem via /host
and does not call control-plane APIs or query the kernel audit
subsystem. Narrow the gate to Host Posture only so VM-only
deployments stay least-privileged.
@francesco-furlan francesco-furlan changed the title feat(shield): add AUDIT_READ/NET_ADMIN caps for unprivileged host shield feat(shield): unprivileged host-shield support for CIS benchmark checks Apr 22, 2026
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.

1 participant