Live data from Hacker News

Do not use secrets in environment variables

nodejs-security.com

21–30 of 96 posts

Re: Do not use secrets in environment variables

#21

“Even if exposed or leaked, it is one secret to rotate rather than all of your secrets, scattered across all of your services and their environment variables.” I don’t think this is true. You’d rotate all secrets in the store, as they could be accessed/compromised.

You'd hopefully have access records to show which ones were accessed... but yea, all accessed secrets need to be rotated, not just the gateway-secret. And without that kind of record you need to assume "all".

Re: Do not use secrets in environment variables

#23

“Even if exposed or leaked, it is one secret to rotate rather than all of your secrets, scattered across all of your services and their environment variables.” I don’t think this is true. You’d rotate all secrets in the store, as they could be accessed/compromised.

That’s what 1Password means, right? If your credentials to 1Password leaks all you have to do is change that one password. Problem solved! /s

Re: Do not use secrets in environment variables

#24
Hang on a second. One of the reasons is you might "do this", where "this" is rendering your environment variables into your HTML. First of all, just don't do that. Secondly, What's stopping you from doing the same thing with a secret in a proper managed secret repository?

Re: Do not use secrets in environment variables

#25
post #19

systemd 247+ now discourages using env vars for secrets, because there are the LoadCredential and related options that are much more secure, with better isolation and encryption features. https://www.freedesktop.org/software/systemd/man/latest/syst...

I would argue that's a systemd quirk due to D-Bus design. Environment variables for processes in Linux for the most part cannot be read by processes of non-root users, so out of the box they are "secure" for the user starting the process.

Re: Do not use secrets in environment variables

#26

In what world does this work? $ curl http://your-website.com/public/../../../../proc/12345/environ If your server is serving up your whole filesystem, you likely have a lot of big problems.

Usually they work in PHP world

what a nonsense notion... are you living in 1997?

Re: Do not use secrets in environment variables

#27

In what world does this work? $ curl http://your-website.com/public/../../../../proc/12345/environ If your server is serving up your whole filesystem, you likely have a lot of big problems.

That specific example? If you’ve done an amazing bad job of configuring a web server.

Similar examples that involve passing paths as e.g. query strings? When you’ve written an application that takes a real file path as a parameter and haven’t done any of several things that can prevent that from pointing to files you don’t want it to.

Re: Do not use secrets in environment variables

#28
So don’t provide secrets to your service via environment variable, it can leak?

Instead, expose all your secrets via a public API with IP filtering, then give the credentials to this service to your app - as an environment variable - and voila!

This just seems like increasing complexity in a part of your system that should be as simple and non-dynamic as humanly possible, for the upside of.. much larger attack surface?

We inject secrets, as env vars, in each Deployment. No runtime access to any secrets store, gives the ability to generate new secrets for each deployment, and minimal complexity for such a critical aspect of the system.

Re: Do not use secrets in environment variables

#29
> To call out a practical example: 1Password.

Of all the examples that could have been 'called out', this is the least practical one. Jumping from the problem statement straight to hosting with a third party provider completely ignores the huge risk that comes with it. Using environment variables is risky so just give your secrets to some third party... which then provides environment variables anyway. This entire section ought to be dropped, it almost reads like a sponsored bit and there are much better and more widely used solutions used such as sops and vault.

Re: Do not use secrets in environment variables

#30
post #18

This article has about as much insight as I would expect from a "nodejs-security.com" article. This article spends a good deal of time conflating two things: putting stuff in .env and using environment variables. The application-parsed .env file is one of the most poorly thought-through ideas that has taken hold in modern application development. It takes something you can do in literally a couple lines of shell (as…

You're going from something simple straight to Terraform and secret storage systems like Vault (KMS and similar).

While I'm not the biggest fan of where we are right now, it's better than the complexity of integrating with a secret engines.

What I really think is ideal is to dump individual secrets into files and only load the decryption key into memory. That way at runtime secrets can be read and decrypted without polluting ENV and avoiding them from lingering around.

Another integration, that would be great if it existed, would be if more web frameworks (the perspective I'm seeing this problem from) would integrate with the Linux memfd_secret api. Which would work great with implementations such as php-fcgi, but no so much with greeanthreaded systems.

Post reply on HN