fix: redact helm registry password from execute errors by SebTardif · Pull Request #4175 · loft-sh/vcluster · GitHub
Skip to content

fix: redact helm registry password from execute errors - #4175

Open
SebTardif wants to merge 1 commit into
loft-sh:mainfrom
SebTardif:fix/helm-password-redaction
Open

SebTardif wants to merge 1 commit into
loft-sh:mainfrom
SebTardif:fix/helm-password-redaction

Conversation

@SebTardif

@SebTardif SebTardif commented Sep 12, 2026 •

Copy link
Copy Markdown

What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix

What does this pull request do? Which issues does it resolve?

helm registry login is invoked with --password on the argv. execute() joined those args into the error string. ProcessHelmChart then writes err.Error() onto the virtual kube-system/vcluster-deploy ConfigMap, so anyone who can read that ConfigMap (or debug logs) sees the registry password after a failed login.

Registry login with --password was added in #1043 (2023-05-18).

This redacts --password <value> and --password=<value> in the error and debug strings. The argv passed to helm is unchanged. --password-stdin is left alone.

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where a failed Helm registry login could write the registry password into the virtual vcluster-deploy ConfigMap.

What else do we need to know?

Related pattern: kubernetes/kubernetes#71149 sanitizes secrets in rest.Config string output.

Validation:

  • Red: go test ./pkg/helm/ -run TestRedactHelmArgs failed on main (redactHelmArgs() = "... --password s3cret ...")
  • Green: same test passes after the fix
none

Note

Low Risk
Logging/error-string-only change with no behavior change to Helm invocations; reduces exposure of registry credentials on failure paths.

Overview
Fixes a credential leak when Helm registry login fails: execute() now formats debug logs and error messages through redactHelmArgs, which masks --password values (separate arg or --password= form) while leaving the real argv passed to helm unchanged. --password-stdin is not treated as a secret value.

Adds TestRedactHelmArgs covering common flag shapes and asserting passwords do not appear in the redacted string.

Reviewed by Cursor Bugbot for commit 4791942. Bugbot is set up for automated code reviews on this repo. Configure here.

Helm registry login passes --password on the argv. execute() joined
those args into the error string, which ProcessHelmChart writes onto
the virtual kube-system vcluster-deploy ConfigMap.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif
SebTardif requested a review from a team as a code owner September 12, 2026 03:57

@blacksoxx blacksoxx left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, a password in a ConfigMap is an easy one to miss. I checked out the branch: go test ./pkg/helm/ is green, vet and the repo's lint config are clean on the package, and TestRedactHelmArgs cannot pass on main since the function does not exist there.

Traced the exposure path to confirm the description: loginArgs in helm.go:225 is the only place the password enters argv, execute is the only place argv is logged or put into an error (the debug lines for delete and get-values never carry it), and pkg/controllers/deploy/deploy.go:150 copies lastError.Error() into the status message of the deploy ConfigMap. So redacting in execute closes it.

Looks good to me. One optional thought, not a blocker: --password-stdin would remove the value from argv entirely and make this class of leak impossible, but that touches how login invokes helm, so a separate change if the maintainers want it.

This branch has not been deployed

No deployments
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.

2 participants