Skip to content

fix(kubescape): enable riskAcceptance so SecurityException CRs are applied - #2298

Merged
devantler merged 1 commit into
mainfrom
claude/repair-kubescape-exceptions
Jun 27, 2026
Merged

devantler merged 1 commit into
mainfrom
claude/repair-kubescape-exceptions

Conversation

@devantler

Copy link
Copy Markdown
Contributor

Problem

The platform deploys 9 ClusterSecurityException CRs (k8s/bases/infrastructure/security-exceptions/), but the in-cluster dashboard shows "excluding 0 resources and 0 controls" — they have never taken effect. The repo's own docs assumed these "feed the in-cluster operator"; in reality they're orphaned.

Root cause (traced against the live cluster + chart source)

The kubescape-operator chart gates the RBAC that lets the operator/kubevuln/scanner read securityexceptions + clustersecurityexceptions behind capabilities.riskAcceptance (chart default disable):

# templates/operator/clusterrole.yaml
{{- if eq .Values.capabilities.riskAcceptance "enable" }}
- apiGroups: ["kubescape.io"]
  resources: ["securityexceptions", "clustersecurityexceptions"]

The platform never set it, so no ClusterRole grants securityexception access (verified live: kubescape/operator/kubevuln clusterroles have none). The scanner logs Loading exceptions… Loaded exceptions but loads an empty set.

Fix

capabilities.riskAcceptance: enable. This:

  • creates the securityexception RBAC, and
  • activates the CRD exception getter, which resolves the CRs' spec.match.namespaceSelector.matchExpressions against live namespaces. (Verified in kubescape/core/cautils/getter/crdexceptionsgetter.go — the "matchExpressions not applied" caveat there is only for objectSelector; namespaceSelector — which the platform's CRs use — is resolved via the k8s client.)

Important follow-up (no-exemptions direction)

Repairing the mechanism makes the existing 9 exceptions live, which will suppress the findings they cover (privileged infra, controller RBAC, SA tokens). Per the directive to prefer real fixes, those exceptions will be trimmed to only the genuinely-irreducible as real fixes land — e.g. Velero → CSI snapshots removes the velero node-agent exception. Exemptions stay a last resort behind real fixes; this PR only makes a minimal, reviewed exception set able to function.

🤖 Generated with Claude Code

…plied

The platform deploys 9 ClusterSecurityException CRs in
k8s/bases/infrastructure/security-exceptions/, but the dashboard shows
"excluding 0 resources and 0 controls" — they have never taken effect.

Root cause: the kubescape-operator chart gates the RBAC that lets the
operator/kubevuln/scanner read securityexceptions + clustersecurityexceptions
behind `capabilities.riskAcceptance` (chart default: `disable`). The platform
never set it, so no component has permission to read the CRs; the scanner logs
"Loaded exceptions" but loads an empty set. Confirmed against the live cluster:
no ClusterRole grants securityexception access.

Enabling it:
- creates the securityexception RBAC (operator/kubevuln/scanner clusterroles), and
- activates the CRD exception getter, which resolves the CRs'
  spec.match.namespaceSelector.matchExpressions against live namespaces
  (verified in kubescape core/cautils/getter/crdexceptionsgetter.go — the
  "matchExpressions not applied" caveat there is only for objectSelector, not
  namespaceSelector, which the platform's CRs use).

NOTE / follow-up: this makes the existing exception set live, which will
suppress the findings those 9 CRs cover (privileged infra, controller RBAC, SA
tokens). Per the no-exemptions direction, those exceptions will be trimmed to
only the genuinely-irreducible as real fixes land (e.g. Velero -> CSI snapshots
removes the velero node-agent exception). Exemptions are a last resort behind
real fixes; this PR only repairs the mechanism so a minimal, reviewed exception
set can actually function.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@devantler
devantler marked this pull request as ready for review June 27, 2026 14:38
@devantler
devantler added this pull request to the merge queue Jun 27, 2026
@devantler
devantler removed this pull request from the merge queue due to a manual request Jun 27, 2026
@devantler
devantler merged commit c199323 into main Jun 27, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from 🫴 Ready to ✅ Done in 🌊 Project Board Jun 27, 2026
@devantler
devantler deleted the claude/repair-kubescape-exceptions branch June 27, 2026 15:02
@botantler-1

botantler-1 Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.80.9 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Assistant

Correction to the PR description: the velero exception is a KEEP, not a trim. The maintainer confirmed the velero node-agent stays — it provides backup defense-in-depth (off-site data-mover + FSB fallback), so its C-0057/0048/0045 findings are genuinely irreducible. velero is therefore one of the legitimately-irreducible exceptions this repair is for, not an example of one to remove once "fixed." (The "Velero → CSI removes the velero exception" line in the body is superseded — see #2301, closed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant