Skip to content
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

Secret exposure through environment variables #2409

Closed
than-pet opened this issue Jul 3, 2023 · 8 comments
Closed

Secret exposure through environment variables #2409

than-pet opened this issue Jul 3, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@than-pet
Copy link
Contributor

than-pet commented Jul 3, 2023

Describe the bug

  1. cost-analyzer deployment has the following "sensitive" environmental variables defined as plain text:
  • REMOTE_WRITE_PASSWORD
  • CLOUD_PROVIDER_API_KEY

  1. In addition, REMOTE_WRITE_PASSWORD environmental variable is always set even if the remoteWrite.postgres.enabled value is false.

Expected behavior

  1. These kind of values must be handled as kubernetes secrets in the generated charts. This approach is already implemented in the deployment yaml:
    https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/cost-analyzer-deployment-template.yaml#L379-L383
image
  1. REMOTE_WRITE_PASSWORD shouldn't be set as env variable when the remoteWrite.postgres is disabled.
    https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/cost-analyzer/templates/cost-analyzer-deployment-template.yaml#L648-L649
image
@than-pet than-pet added the bug Something isn't working label Jul 3, 2023
@kwombach12
Copy link

@than-pet Thanks for logging this. @thomasvn when youre back, can you take a look at this?

@thomasvn
Copy link
Member

@than-pet I agree that REMOTE_WRITE_PASSWORD should only be set when .Values.remoteWrite.postgres.enabled=true. Therefore this code block should instead look something like the following:

            {{- if .Values.remoteWrite.postgres.enabled }}
            - name: REMOTE_WRITE_ENABLED
              value: "true"
            - name: REMOTE_WRITE_PASSWORD
              value: {{ .Values.remoteWrite.postgres.auth.password }}
            {{- end }}

Are you interested in authoring the PR?

@bt-macole
Copy link

conversation seems to have focused on REMOTE_WRITE_PASSWORD want to draw attention back to CLOUD_PROVIDER_API_KEY also being marked as a leaked api key. Some more information on this one and making it optional/configurable would be good as well.

@thomasvn
Copy link
Member

@bt-macole The CLOUD_PROVIDER_API_KEY is only used for GCP clusters, and can be safely removed from your configuration if you're not deploying to GCP! It's currently expected to be there and is limited to only accessing Google's billing API.

@bt-macole
Copy link

@thomasvn thanks for the reply, I removed it via a patch already. I didn't see a way to do it via helm, which would make my life easier. certainly not urgent or blocking though.

@thomasvn
Copy link
Member

@bt-macole Ok thanks for the feedback! Yes I'd agree that it would be good to make CLOUD_PROVIDER_API_KEY a configurable option in Helm.

@than-pet
Copy link
Contributor Author

Are you interested in authoring the PR?

@thomasvn I created the PR to disable REMOTE_WRITE_PASSWORD variable if remoteWrite.postgres is not enabled.

Regarding my second point in this ticket, I have no clue on how to move the GCP billing API key into a kubernetes secret.

@chipzoller chipzoller changed the title Secret exposure trough environment variables Secret exposure through environment variables May 2, 2024
@chipzoller
Copy link
Collaborator

In 2.x REMOTE_WRITE_PASSWORD is no longer even used and as mentioned above the CLOUD_PROVIDER_API_KEY env var is a Kubecost-provided, non-sensitive API key only used to retrieve GCP pricing. It is also our desire to eliminate the default inclusion of it (tracked in #2767 and cross-referenced at the source in opencost/opencost#2311). Closing as no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants