-
Notifications
You must be signed in to change notification settings - Fork 52
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
Security .env issue when set VITE_SINGLETON_API_KEY & apiKey saved to local storage #161
Comments
The application itself is a SPA, so whether the API KEY is passed this way or not will expose the API KEY on the front end. And the API KEY can be found in local storage of your browser as well if you are not in SINGLETON mode. Maybe this should be write into docs to make it clear? |
"The application itself is a SPA, so whether the API KEY is passed this way or not will expose the API KEY on the front end."
I just have download from github and then added the The I ran The API KEY became exposed in |
I think the docs should inform about exposing master key, it can cause leaks of master key. The docker image is not exposing the API KEY, but if download the source and build, passing VITE_ env variables, the key will be found into assets js files(This is a major security issue). Sensitive information must not defined in VITE_ variables. The API KEY found in local storage may leak by XSS attack (I understand it is a SPA, but this risk should be noted)
|
SINGLETON mode is designed to be used in local or internal network actually. The risk of leaks of master key should be mentioned in documents. Could you post a PR for this, or I will add this into README file later. |
Singleton mode usage docs have been updated. |
VITE_xxxx variables are exposed on the frontend
Configure import.meta.env.VITE_SINGLETON_API_KEY will expose meilisearch master key to the world.
From Vite Docs
https://vite.dev/guide/env-and-mode.html#env-files
Important
SECURITY NOTES
.env.*.local files are local-only and can contain sensitive variables. You should add *.local to your .gitignore to avoid them being checked into git.
Since any variables exposed to your Vite source code will end up in your client bundle, VITE_* variables should not contain any sensitive information.
More about the security issue.
vitejs/vite#14412
To Reproduce
Screenshots
Environments (please complete the following information):
The text was updated successfully, but these errors were encountered: