fix(shield): correct response_actions ClusterRole RBAC scoping#2605
Merged
francesco-furlan merged 2 commits intomainfrom Apr 29, 2026
Merged
fix(shield): correct response_actions ClusterRole RBAC scoping#2605francesco-furlan merged 2 commits intomainfrom
francesco-furlan merged 2 commits intomainfrom
Conversation
97e5a53 to
5999276
Compare
…flag `cluster.response_actions.<action>.is_enabled` only short-circuited when an individual action's `trigger` was explicitly set to "none"; it never consulted `features.respond.response_actions.enabled`. With chart defaults (master flag false), every per-action gate still resolved to "true" and the cluster-shield ClusterRole was granted `delete` on `pods`, `networkpolicies`, and `volumesnapshots`, plus the `isolate_network` / `rollout_restart` / `get_logs` / `volume_snapshot` rules — a real least-privilege violation, surfaced by a customer during an RBAC security review. The helper now returns "false" early when the master flag is falsy. Per-action `trigger: "none"` overrides remain effective when the master flag is on, so user-facing per-action disablement keeps working. Adds unit tests covering: defaults no longer leak per-action rules, and per-action `trigger: "none"` still suppresses only the targeted rule when the master flag is enabled.
The seven `response_actions.*` rule blocks in
`templates/cluster/clusterrole.yaml` lived outside the outer
`{{ if .Values.cluster.rbac.create }} ... {{ end }}` wrapper. With
`cluster.rbac.create: false`, the document head (apiVersion / kind /
metadata / rules:) was correctly suppressed but the per-action rule
snippets still rendered, producing a top-level YAML array that Helm
could not parse:
Error: YAML parse error on shield/templates/cluster/clusterrole.yaml:
error unmarshaling JSON: while decoding JSON:
json: cannot unmarshal array into Go value of type util.SimpleHead
Move the closing `{{ end }}` past the response_actions blocks so the
entire ClusterRole template (including those rules) is suppressed when
`cluster.rbac.create` is false, matching the pattern already used in
`templates/host/clusterrole.yaml`. Bumps the chart to 1.36.1 and adds
regression unittests covering the failure mode.
Reported and originally fixed by @EdwardArchive in #2604; this commit
folds the same change into the broader response_actions RBAC fix on
this branch.
Closes #2603
Co-Authored-By: Edward Kim <[email protected]>
5999276 to
e1e84ac
Compare
Contributor
|
Thank you for hard work @francesco-furlan ! |
Contributor
Author
Thank you for raising the issue @EdwardArchive ! 🚀 |
AlbertoBarba
approved these changes
Apr 29, 2026
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.
Summary
Fixes two related defects in the cluster-shield ClusterRole template that caused
response_actionsRBAC to render incorrectly.Bug 1 — per-action gates ignored the master
enabledflagcluster.response_actions.<action>.is_enabled(intemplates/cluster/_config.tpl) only short-circuited when an individual action'striggerwas explicitly"none"— it never consultedfeatures.respond.response_actions.enabled. With chart defaults (master flagfalse), every per-action gate still resolved to"true"and the cluster-shield ClusterRole was granteddeleteonpods,networkpolicies, andvolumesnapshots, plus theisolate_network/rollout_restart/get_logs/volume_snapshotrules. Real least-privilege violation.Bug 2 — response_actions blocks rendered outside the
cluster.rbac.createwrapperThe seven
response_actions.*rule blocks intemplates/cluster/clusterrole.yamllived outside the outer{{- if .Values.cluster.rbac.create }} ... {{- end }}guard. Withcluster.rbac.create: false, the document head (apiVersion / kind / metadata / rules:) was correctly suppressed but the per-action rule snippets still rendered, producing a top-level YAML array that Helm could not parse:Reported by @EdwardArchive in #2603.
Fix
templates/cluster/_config.tpl:is_enabledreturnsfalseearly when the masterfeatures.respond.response_actions.enabledflag is falsy. Per-actiontrigger: "none"overrides remain effective when the master flag is on.templates/cluster/clusterrole.yaml: moved the{{- end }}of thecluster.rbac.createwrapper past the sevenresponse_actions.*blocks so they live inside it (matching the working pattern intemplates/host/clusterrole.yaml).Chart.yaml: bumped to1.36.1.Behavior matrix
response_actions.enabled<action>.triggerfalse(default)false"none"truetrue"none"cluster.rbac.createresponse_actions.enabledtrue(default)falsefalse(default)helm templateerrorfalsetruehelm templateerrorTests
charts/shield/tests/cluster/clusterrole_test.yaml:response_actions disabled by default does not leak per-action RBAC— assertspods: delete,get,networkpolicies: get,delete,volumesnapshots: delete,get,watch,patch, andpods/log: getare absent under chart defaults.cluster.rbac.create false renders no ClusterRole—hasDocuments: count: 0.cluster.rbac.create false with response_actions enabled still renders no ClusterRole— covers the original failure mode from [BUG]cluster.rbac.create: falsecauseshelm templateto fail withSimpleHeadunmarshal error intemplates/cluster/clusterrole.yaml#2603.response_actions enabled with delete_pod trigger none suppresses only delete_pod rule— verifies fine-grained per-action overrides still work.helm unittest --strict -f "tests/**/*_test.yaml" charts/shield: 463 / 463 pass (459 baseline + 4 new).Test plan
helm unittestpasses (463/463)helm templatewithcluster.rbac.create: falseno longer errorsfeatures.respond.response_actions.enabled: truestill emits all per-action rulesenabled: true+ per-actiontrigger: "none"suppresses only that ruleCloses #2603