-
Notifications
You must be signed in to change notification settings - Fork 47
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
[Web] dotenv file variables exposed in plain text in browser developer tools #51
Comments
Any comment on this issue? |
Any update in this issue.. still library not secure in web |
Still need an update on this issue |
I would recommend against putting very sensitive data into your Even if you replace the env variables ahead of time into the code and obfuscate your code those variables are still retrievable via file / bundle inspection. It's just a certain degree of more effort. .env should be used to host non sensitive data for the front end of your application. Included but not limited to the API endpoints for an environment, build specific policies, feature flags for builds, 3rd party endpoints the app may use, timeout durations, refresh durations.. Non sensitive things that create a variation of your application for different environments. Operations that involve truly sensitive keys should be proxied through an API call to a service that can securely host and use these values. From the frontend, you cannot encrypt these variables without exposing the way to decrypt them. I'm interested to hear if we think there is any benefit in some kind of obfuscation weighed up against any performance woes of the approach etc. |
@java-james In my use-case I'm considering using this plugin to prevent hardcoding external api keys in my dart files. |
I think there is nothing to resolve since there is no issues that needs resolving. In my opinion, this issue could be closed since as mentioned there is nothing that needs to be resolved. |
Then, what is the use case of this package |
This explanation makes total sense (kind of obvious), but I would recommend to add this comment as a warning into the README.md the same way there is:
...that might induce a distracted developer in error about secrets being secret. |
Endpoint URLs, flags, keys or tokens that are intended for use on the frontend. Then what you can do is have different sets of the above for each environment configuration (local, dev, staging, prod). Makes it easy to point your frontend towards various environments. If you are dealing with secrets, they should be on the backend. The backend should then do the work with them and never reveal them to the frontend. It's normally pretty standard practice since even compiling your frontend code will include them within the code for someone to find. |
@kev-techi |
Extract .env Android app with "Apk Editor Studio" instead, you can use flutter build apk --dart-define=API_URL=https://dev.example.com |
@Heech Yep, very good recommendation thanks! I have added this to the readme under a new "Security Recommendations" section in the latest release. |
The contents of the environment file is available in plaintext via a browser's developer tools under the network tab when using the dotenv package for a Flutter Web project. The contents of the env file is quite sensitive so is this intended behaviour?
The text was updated successfully, but these errors were encountered: