-
Notifications
You must be signed in to change notification settings - Fork 4
fix(kubescape): except C-0007 delete-capable RBAC by object, not namespace #2446
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
Draft
devantler
wants to merge
4
commits into
main
Choose a base branch
from
claude/kubescape-c0007-rbac-exception
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
db4eacd
fix(kubescape): except C-0007 delete-capable RBAC by object, not name…
devantler c024859
fix(kubescape): match the crossplane provider CRB by revision-hash pa…
devantler 7b82f1e
fix(kubescape): mirror C-0007 by RBAC binding kind+name in the Headla…
devantler 70d5a05
Merge remote-tracking branch 'origin/main' into claude/kubescape-c000…
devantler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
125 changes: 125 additions & 0 deletions
125
k8s/bases/infrastructure/cluster-security-exceptions/delete-rbac.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| # Delete-capable-RBAC exception (Kubescape C-0007, "Roles with delete | ||
| # capabilities") for the infrastructure controllers and platform/app service | ||
| # accounts that require delete permissions BY DESIGN — GitOps reconcilers, | ||
| # operators, backup/restore, storage, virtualisation, cert/DB/secret managers, | ||
| # and tenant deployers all delete the resources they own. | ||
| # | ||
| # Why this is a separate CR matched by kind+name, and NOT a namespaceSelector | ||
| # entry in controller-rbac.yaml (mirrors wildcard-rbac.yaml / C-0187): Kubescape | ||
| # attaches an RBAC finding to the Role/ClusterRole/binding object, not to a | ||
| # namespaced workload, so a namespaceSelector never matches it. 19 of C-0007's | ||
| # 26 findings terminate on cluster-scoped ClusterRoleBindings whose namespace is | ||
| # empty — a namespace match can NEVER cover those. Matching each offending | ||
| # binding by kind+name is the mechanism that actually works. | ||
| # | ||
| # Deliberately explicit (one entry per binding) so C-0007 still flags any NEW or | ||
| # accidental delete-capable grant elsewhere — that residual signal is wanted. | ||
| # Names are regex-compared, so the one revision-hashed entry (the Crossplane | ||
| # provider CRB) matches by pattern and survives provider re-installs; the | ||
| # tofu-controller `tf-runner` RoleBinding is created on demand per Terraform | ||
| # apply (the exception no-ops while it is absent). Keep this list reconciled | ||
| # against a fresh scan (it can only be re-verified live once the scanner mount | ||
| # fix lands — see the kubescape HelmRelease postRenderer / helm-charts#862). | ||
| apiVersion: kubescape.io/v1beta1 | ||
| kind: ClusterSecurityException | ||
| metadata: | ||
| name: delete-capable-rbac-by-design | ||
| spec: | ||
| reason: >- | ||
| Infrastructure controllers, operators and tenant deployers legitimately | ||
| require delete permissions by design (GitOps reconciliation, operator | ||
| lifecycle, backup/restore, storage, virtualisation, cert/DB/secret | ||
| management). Each offending Role/binding is matched by kind+name so C-0007 | ||
| still catches any new or accidental delete-capable grant. | ||
| posture: | ||
| - controlID: C-0007 | ||
| action: ignore | ||
| match: | ||
| resources: | ||
| # --- cluster-scoped: ClusterRoleBinding -> ClusterRole (19) --- | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cdi-sa # CDI (KubeVirt storage import) | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cert-manager-controller-issuers | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cert-manager-controller-clusterissuers | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cert-manager-controller-certificates | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cert-manager-controller-challenges | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cloudnative-pg # CNPG Postgres operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: cluster-reconciler-flux-system # Flux kustomize/helm controllers | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: flux-operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: coroot-operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: crossplane-admin # Crossplane core (Group crossplane-masters) | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| # The trailing hash is the provider-revision hash, rewritten on every | ||
| # provider re-install, so match it by pattern — exception name matching | ||
| # is regex-based (kubescape/opa-utils exceptions comparator regexCompare), | ||
| # the same mechanism that lets the literal names above match. | ||
| name: "^crossplane:provider:provider-upjet-github-[0-9a-f]+:system$" | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: flagger # progressive delivery | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: "kro:controller" # KRO resource-graph operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: ksail-operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: kube-prometheus-stack-operator | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: kubevirt-apiserver | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: kubevirt-controller | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: longhorn-bind # Longhorn distributed storage | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRoleBinding | ||
| name: reloader-reloader-role-binding # config/secret change reloader | ||
| # --- namespaced: RoleBinding -> Role/ClusterRole (7) --- | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: ascoachingogvaner # tenant deployer SA (edit) | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: "kyverno:admission-controller" | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: "kyverno:cleanup-controller" | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: longhorn | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| # FRAGILE: tofu-controller creates this on demand per Terraform apply; | ||
| # it is absent between runs (the exception simply no-ops while absent). | ||
| name: tf-runner | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: velero-server # backup/restore | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: RoleBinding | ||
| name: wedding-app # tenant deployer SA (edit) | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.