Skip to content

Security Problem With Process Env #423

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

Merged
merged 1 commit into from
May 5, 2024
Merged

Conversation

PedroGSantos
Copy link
Contributor

@PedroGSantos PedroGSantos commented Apr 30, 2024

I have a problem using the current code using process.env in the config file of vite. Currently, the process.env from Node.JS invokes all enviroment variables from the SO. Consequently, when we build the application, we can see all enviroment variables by searching in the developer tools of the browser.

Here's an example

  • Creating a password env variable:
    Env Variable Created

  • Searching for this variable and others from the SO:
    env exposed

Especially in a CI/CD flow, this is a crucial problem because a host that runs a CI/CD flow can have password env variables in the SO.

To solve this, I just removed the function that invoke all SO env, I created a .env file and I use this guidelines provided by VITE to create env variable: https://vitejs.dev/guide/env-and-mode#env-files

This guidelines specify that we need to create a env with the prefix VITE and references like this console.log(import.meta.env.VITE_SOME_KEY)

Enviroment:

  • Browser: Google Chrome 123.0.6312.58
  • SO: Ubuntu 22.04.4 LTS

Process.env is a variable in Node.js that invokes all enviroment variable from the host, including sensitive variables, exposing them in build files
@PedroGSantos
Copy link
Contributor Author

PedroGSantos commented Apr 30, 2024

Do I need to create a issue for this PR?

@mrholek

@mrholek mrholek merged commit 422944f into coreui:main May 5, 2024
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