Skip to content

fix: never trust a Helm release's own Hooks during internal recovery uninstalls - #2146

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:helm-uninstall
Dec 4, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:helm-uninstall

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

handleUpgradeError/recoverRelease and handleInstall's consecutive-failure self-healing both call Helm's uninstall action, with hooks enabled by default, on a release whose recorded state (status, and the Hooks field that comes with it) Sveltos did not verify. Anyone with write access to Secrets in the release namespace can forge that state: relabel the current release as superseded, inject a next-revision Secret with status "unknown" and a pre-delete hook of their choosing, then trigger a redeploy. The upgrade fails with "has no deployed releases", recoverRelease decides to uninstall to clear the inconsistency, and the forged hook runs with addon-controller's own (often cluster-admin-level) credentials for the managed cluster - a confused-deputy privilege escalation from whatever RBAC the attacker had in their own namespace.

Add forceDisableHooks to getHelmUninstallClient/uninstallRelease/ doUninstallRelease and set it for the two call sites that are an internal recovery heuristic rather than an admin decision: recoverRelease, and handleInstall's uninstall-after-N-consecutive- failures. Both read release state addon-controller never produced and has no reason to trust. The other three uninstallRelease callers (explicit HelmChartActionUninstall, a ClusterSummary's own teardown when its ClusterProfile/Profile is deleted or stops matching, and the stale/orphaned-release cleanup loop) are admin-driven lifecycle decisions and keep respecting the chart's own DisableHooks option, unchanged.

Reproduced end-to-end on local kind clusters (management + managed, push mode): a ServiceAccount with only the built-in edit role in one namespace forged a release this way and had addon-controller create a ClusterRoleBinding granting it cluster-admin. Rebuilding with this fix and replaying the same forgery, the recovery still clears the inconsistent release but the forged hook no longer runs.

handleInstall's path is harder to trigger than recoverRelease's: the same release-state read gates both whether handleInstall is entered (status nil/Uninstalled) and whether Helm's own Uninstall.Run skips hooks (it always does when status is already Uninstalled), so a static forged state can't satisfy both at once - reaching it for real would need winning a race between two near-simultaneous reads. Fixed anyway as free defense in depth: this is an internal heuristic, not an admin intent, so it should never have trusted hook content regardless of how hard it is to reach.

…uninstalls

handleUpgradeError/recoverRelease and handleInstall's consecutive-failure
self-healing both call Helm's uninstall action, with hooks enabled by
default, on a release whose recorded state (status, and the Hooks field
that comes with it) Sveltos did not verify. Anyone with write access to
Secrets in the release namespace can forge that state: relabel the
current release as superseded, inject a next-revision Secret with
status "unknown" and a pre-delete hook of their choosing, then trigger
a redeploy. The upgrade fails with "has no deployed releases",
recoverRelease decides to uninstall to clear the inconsistency, and the
forged hook runs with addon-controller's own (often cluster-admin-level)
credentials for the managed cluster - a confused-deputy privilege
escalation from whatever RBAC the attacker had in their own namespace.

Add forceDisableHooks to getHelmUninstallClient/uninstallRelease/
doUninstallRelease and set it for the two call sites that are an
internal recovery heuristic rather than an admin decision:
recoverRelease, and handleInstall's uninstall-after-N-consecutive-
failures. Both read release state addon-controller never produced and
has no reason to trust. The other three uninstallRelease callers
(explicit HelmChartActionUninstall, a ClusterSummary's own teardown
when its ClusterProfile/Profile is deleted or stops matching, and the
stale/orphaned-release cleanup loop) are admin-driven lifecycle
decisions and keep respecting the chart's own DisableHooks option,
unchanged.

Reproduced end-to-end on local kind clusters (management + managed,
push mode): a ServiceAccount with only the built-in edit role in one
namespace forged a release this way and had addon-controller create a
ClusterRoleBinding granting it cluster-admin. Rebuilding with this fix
and replaying the same forgery, the recovery still clears the
inconsistent release but the forged hook no longer runs.

handleInstall's path is harder to trigger than recoverRelease's: the
same release-state read gates both whether handleInstall is entered
(status nil/Uninstalled) and whether Helm's own Uninstall.Run skips
hooks (it always does when status is already Uninstalled), so a static
forged state can't satisfy both at once - reaching it for real would
need winning a race between two near-simultaneous reads. Fixed anyway
as free defense in depth: this is an internal heuristic, not an admin
intent, so it should never have trusted hook content regardless of how
hard it is to reach.
@gianlucam76
gianlucam76 merged commit b001a5b into projectsveltos:main Dec 4, 2026
14 checks passed
@gianlucam76
gianlucam76 deleted the helm-uninstall branch December 4, 2026 13:18
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