Skip to content

helm 3 shows secrets with --dry-run option in clear text #7275

Closed

Description

@darkstarmv

Output of helm version:

helm version version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
Output of kubectl version:

kubectl version Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"darwin/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

Issue

helm3 --dry-run command prints content of the secrets where helm2 just the fact that secret has been created.
This creates issue running helm --dry-run in CI/CD tools as it exposes secrets.

 helm upgrade --install myrelease  mychart  --set thanos.sayamlbase64=TESTSECRET  --dry-run
Release "myrelease" has been upgraded. Happy Helming!
NAME: myrelease
LAST DEPLOYED: Thu Dec 19 15:11:43 2019
NAMESPACE: kube-system
STATUS: pending-upgrade
REVISION: 400
TEST SUITE: None
HOOKS:
MANIFEST:
---
# Source: mychart/templates/thanos-objstore-config-secret.yaml
apiVersion: v1
data:
  thanos.yaml: TESTSECRET
kind: Secret
metadata:
  name: thanos-objstore-config
  namespace: kube-system
type: Opaque
---
helm2 upgrade --install release-name chart  --set thanos.sayamlbase64=TESTSECRET  --dry-run
Release "release-name" has been upgraded. Happy Helming!
LAST DEPLOYED: Thu Dec 19 14:51:59 2019
NAMESPACE: kube-system
STATUS: DEPLOYED

RESOURCES:
==> v1/Secret
NAME                    TYPE    DATA  AGE
thanos-objstore-config  Opaque  1     80d

Activity

  1. bacongobbler commented on Dec 20, 2019

    @bacongobbler
    Member

    Hi @darkstarmv. It looks as though helm install --dry-run intentionally displays this output:

    if strings.EqualFold(s.release.Info.Description, "Dry run complete") || s.debug {

    What is your recommended course of action here?

    We could relax this constraint to only display this output when the --debug flag is applied. However, I am concerned about this breaking backwards compatibility, and that there may be users who are relying on this behaviour since this was intentionally introduced.

    @thomastaylor312 any thoughts here?

  2. darkstarmv commented on Dec 20, 2019

    @darkstarmv
    Author

    i think by default --dry-run should not print debug output. Each user has to provide additional flags if they would like to see more information.

  3. thomastaylor312 commented on Dec 20, 2019

    @thomastaylor312
    Contributor

    I can see the argument, but at this point we can't change that output because of our backwards compatibility guarantees. So anything that we'd want to implement shouldn't break that

  4. darkstarmv commented on Dec 21, 2019

    @darkstarmv
    Author

    so, helm2 was not printing secrets and now helm3 does, should it be changed not to print?

    helm2 upgrade --install release-name chart  --set thanos.sayamlbase64=TESTSECRET  --dry-run
    Release "release-name" has been upgraded. Happy Helming!
    LAST DEPLOYED: Thu Dec 19 14:51:59 2019
    NAMESPACE: kube-system
    STATUS: DEPLOYED
    
    RESOURCES:
    ==> v1/Secret
    NAME                    TYPE    DATA  AGE
    thanos-objstore-config  Opaque  1     80d
    
  5. thomastaylor312 commented on Jan 7, 2020

    @thomastaylor312
    Contributor

    So given our backwards compatibility guarantees, we cannot remove the secret output by default. However, we would be more than willing to review and accept any implementation that uses a feature flag (something like --sanitize) to prevent those values from printing. I'll relabel this as a feature and anyone can implement it

  6. vaivanov commented on Feb 12, 2020

    @vaivanov

    any updates on this?

  7. bobbywatson3 commented on Feb 27, 2020

    @bobbywatson3

    We'd rather not have secrets splashed across each jenkins job's console output. Any update on this? A --sanitize flag would be excellent.

  8. bacongobbler commented on Feb 27, 2020

    @bacongobbler
    Member

    No updates. Feel free to contribute!

  9. EssentialMix commented on Mar 3, 2020

    @EssentialMix

    @thomastaylor312 i am not quite understand your comment about backwards compatibility. Helm 2 with dry-run did not exposed secrets, and Helm 3 expose them. So actually there is breaking compatibility changes introduced in Helm 3. Also if regular update/run do not expose secrets, i would expect from dry-run same. Because dry-run means: run as regular, but don't apply changes. We see different behavior here. It would be confusing if we would need to use extra flag for getting same behavior for dry-run and regular run.

  10. EssentialMix commented on Mar 3, 2020

    @EssentialMix

    I guess this is really depends how we are treating it, as feature or bug? For me this is definitely a bug in dry-run mode.

  11. jkroepke commented on May 7, 2020

    @jkroepke

    I would say "it works as expected".

    The helm diff plugin have a similar functionality. But there is available flag to explicit mask secrets.

  12. myuseridbws commented on Jun 14, 2020

    @myuseridbws

    @EssentialMix has it right. Helm 3 broke the backward compatibility of the Helm 2 --dry-run behavior.

    Helm 2 --dry-run did not print any output (let alone secrets) as you can see here:

    $ helm version
    Client: &version.Version{SemVer:"v2.16.3", GitCommit:"1ee0254c86d4ed6887327dabed7aa7da29d7eb0d", GitTreeState:"clean"}
    Server: &version.Version{SemVer:"v2.16.3", GitCommit:"1ee0254c86d4ed6887327dabed7aa7da29d7eb0d", GitTreeState:"clean"}
    
    $ helm install . --dry-run                                    
    NAME:   anxious-marmot
    <end-of-output>
  13. 45 remaining items

  14. joejulian commented on Jun 5, 2023

    @joejulian
    Contributor

    This looks like there are several suggestions and tools to address the issue. Closing.

  15. pipeworks-asmith commented on Jun 6, 2023

    @pipeworks-asmith

    Not sure I agree that this should be closed, as it feels like a pretty flagrant miss from a security perspective. Just because duct tape exists doesn't mean we shouldn't expect our tools to work without them.

  16. wirwolf commented on Jun 6, 2023

    @wirwolf

    Please reopen the issue. Ith an important problem and I wait to fix it in helm

  17. OhZedTee commented on Jun 15, 2023

    @OhZedTee

    I'm curious why there's no open CVE against a blatant security vulnerability that's been open for 3 years. It almost seems like a callout is needed here.

  18. m1rm commented on Aug 9, 2023

    @m1rm

    For others bumping into this.

    helm template --debug --values also exposes the secrets.

    A way to avoid the secrets showing up in the CLI output is to pipe the result of the command to sed and mutate it:

    sed '/^kind: Secret/,/^---/{//!d;};'

    For us this resulted in the section looking like this in the output:

    [...]
    apiVersion: v1
    kind: Secret
    ---
    [...]
    

    yet I fully agree with all others here stating, that this should be solved in helm directly

  19. rafaelbattesti commented on Sep 28, 2023

    @rafaelbattesti

    I know a lot of folks already came here to say how much of a security breach this is, but I'll say it again because it shocks me that Helm as a graduated CNCF project closes this issue like it's nothing after 3.5 years.
    And just like @OhZedTee I'm curious as well.

  20. codersasha commented on Oct 12, 2023

    @codersasha

    For anyone still experiencing this issue -- this is a sed command that deletes everything from USER-SUPPLIED VALUES: down:

    helm install --debug ... | sed '/USER-SUPPLIED VALUES:/,$d'

    We now use this in our deploys, so we can debug when a deploy fails, but not print any secrets/configuration that may reveal sensitive data.

  21. molnare commented on Dec 6, 2023

    @molnare

    We used yq, tail and head to redact any element's value in any depth with any name. (Raspberry PI 4, Ubuntu 23.10, helm vesion 3.10.1)
    Say for example the field name has to be redacted everywhere then with yq 4.40.4, tail and head I can do the following:

    helm upgrade --install --dry-run --debug my-release ./path/to/chart/ | tail -n +11 | head -n -4|yq eval '(.. | select(has("name")) | .name) |= "REDACTED"'

    What is happening:

    • tail removes the first 11 lines. That part is metadata like NAME, LAST DEPLOYED, NAMESPACE, etc. and it isn't for yq consumption
    • head removes the 4 lines from the end because that is also metadata. For now I only saw NOTES: as metadata.
    • yq will evaluate every element which has a subelement name. If it finds one then the name's value will be replaced with REDACTED.

    If we want to redact more than one element value then multiple yq statements can be chained one after another:

    helm upgrade --install --dry-run --debug my-release ./path/to/chart/ | tail -n +11 | head -n -4 | yq eval '(.. | select(has("name")) | .name) |= "REDACTED"'  | yq eval '(.. | select(has("securityContext")) | .securityContext) |= "REDACTED"'

    This will replace name and securityContext values everywhere with REDACTED. There is probably a better shorter way of writing this, but I found it more readable.

    Note: Omitting --debug from helm chart will print less metadata. In that case tail should be reduced to +9 from +11.

  22. github-usr-name commented on Jan 3, 2024

    @github-usr-name

    This looks like there are several suggestions and tools to address the issue. Closing.

    There are zero suggestions or tools to address the critical security issue. Rather, there are a several kludges that can be used to workaround it as long as every single team member remembers to use a non-obvious pipe consistently, all the time. That does not address the issue. Adding a --sanitize flag or similar that natively performs the operation without breaking backwards compatibility would be a good resolution.

  23. oscerd commented on Mar 11, 2024

    @oscerd

    Do we know the organization or individual who allocated the CVE? This could be useful for tracking. If someone know about it, please let me know. Thanks.

  24. TobyTheHutt commented on Mar 13, 2024

    @TobyTheHutt

    I opened the CVE. My apologies for not notifying you sooner.
    If you need information on use cases or other information, feel free to get in touch.

  25. oscerd commented on Mar 13, 2024

    @oscerd

    I opened the CVE. My apologies for not notifying you sooner. If you need information on use cases or other information, feel free to get in touch.

    Thanks for letting me know.

  26. peterwwillis commented on May 14, 2024

    @peterwwillis

    When trying to add the kludges mentioned, there's an unfortunate side-effect: piping output without -o pipefail shell option, means that when Helm dies with an error, the secret-munging thing being piped to returns success rather than failure, so any jobs looking for Helm exit status show success every time. This can be worked around by enabling -o pipefail or using Bash's PIPESTATUS and checking the Helm part of the pipe... but this is now getting a little complicated.

    The maintainers said they would be willing for somebody else to contribute a new feature flag to hide secret values. But I would argue that far fewer people depend on this "feature", than will be affected by the security hole it introduces.

    Therefore, I would urge @bacongobbler , @thomastaylor312 , and any other Helm contributors, to reconsider the Helm backwards compatibility guarantee here, and implement a fix themselves to implicitly stop showing secret values. Yes, this will be a breaking change. But nobody will blame you for breaking compatibility in order to close a pretty big security hole. I think you would probably expect the same of a different project...

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions