keep your secrets out of your environment! especially when you aren't providing any additional safety advice like making sure DEBUG is off
keep your secrets out of your environment! especially when you aren't providing any additional safety advice like making sure DEBUG is off
- https://diogomonica.com/2017/03/27/why-you-shouldnt-use-env-... - https://blog.forcesunseen.com/stop-storing-secrets-in-enviro...
They both recommend mounting them into a tmpfs, and then unmounting, but I've not yet tried this.
After all, if you have a single server, and the attacker can read a root protected file oe the spawned processes context, you are pwned already. As for exposing env var, popping os.environ is usually enough.
No need to pay for more than you must: bots and script kiddies are not mossad.
How would you avoid that?
Even this article, which recommends keeping your secrets in environment variables, tells you to implement that by storing them in the filesystem. The advice isn't to avoid storing your secrets in the filesystem; it's to avoid storing them in version control.
It is apparently an exercise for the reader to figure out why it's better to read your secrets out of the environment, which read them from a file you provided, than to read them from your own file yourself.
export DATABASE_URL="$(bw get password my_app/db_url/prod)"
And put that in a startup script (that can go in version control).If not, then it's a secret you must manage, and you are back to square one: either using a simpler solution, use a hardware key, or going full secure vault service, with privileged first request, and so on.
For a service, one would need some kind of secret management - but a shell script could set this variable/value for input to eg docker or a k8s setup. Or the service (eg: heroku) could handle it.
If you can call bitwarden from within the python code somehow, such as with subprocess, that would be better.
For the desktop, use the keyring module.
If you start to scale up your threat model, you should use a vault, but the setup is way more costly, and tricky to get the reboot story right (hence the priviledged first requests comments).
I've always accepted this was an attack vector, and some malicious library could extract env vars.
This actually makes a lot of sense, thanks!