Live data from Hacker News

Don't use ENV variables for secret data (2017)

diogomonica.com

111–120 of 147 posts

Re: Don't use ENV variables for secret data (2017)

#111
post #58

Earlier quoted context omitted.

Using AppRoles and consul-template. And if you're on Kubernetes, you can use https://github.com/sethvargo/vault-kubernetes-authenticator in an init container.

And how does k8s pass that value to the app?

You can use consul-template to generate a config file that lives in-memory (volumes.myvolume.emptyDir.medium = InMemory in a PodSpec).

Re: Don't use ENV variables for secret data (2017)

#112
post #105

Earlier quoted context omitted.

Cloud lock-in (not being able for example to manage cross-platform credentials) and cost. By itself AWS Secrets Manager is fine, but as with everything AWS, billing is pretty opaque. If you couple this with a poorly planed Lambda setup, costs can potentially uncontrollably scale. For what you are paying, AWS Secrets Manager seems too barebones/rigid.

Lock in shouldn't be too bad. It's create, get, set, list, delete, describe. I imagine the API footprint isn't much different if you switch over to something else. Most apps will just use get().

It shouldn't, but it can be very bad. And with vault you potentially circumvent that and end up with a tool that is way more flexible than Secrets Manager.

Re: Don't use ENV variables for secret data (2017)

#114

If you think that putting secrets in ENV is bad, you probably shouldn't take the advice of running ' docker service create --secret="secure-secret" redis:alpine ' either! Putting secrets in a command line makes them just as visible, in fact more so, to other processes. It also makes the secrets available to anyone regardless of permissions, since everyone can monitor the currently running processes and their args (e.…

they wind up in your bash history this way too

Re: Don't use ENV variables for secret data (2017)

#115

Also this pattern makes path traversal vulnerabilities (a thing not uncommon in web frameworks) have the potential to allow for privilege escalation on Linux via the /proc/self/environ file. I've been on a pentest where a recently disclosed path traversal bug in Rails was not patched in the environment I was testing and I thought I would get at least some credentials from at least one service, but every host used a d…

Any chance they documented that setup publicly? Would be interested to dive in to how all that works and gain any new insights

It's a large company that built their own bespoke internal credentials service running over a TCP port to the application with another proprietary protocol to push key material to hosts.

Can't say much more due to NDAs.

Edit: this service handles credentials and rotation for hundreds of thousands to millions of hosts.

Re: Don't use ENV variables for secret data (2017)

#116
post #69

Earlier quoted context omitted.

This comes back to where does the config file live and how is it managed?

The plain config file must live in memory (tmpfs). The encrypted config file on a hard drive that is accessed only to decrypt the file to memory.

No, I mean management of the secrets. Though it is a rather moot point as the same problems apply to most systems anyway.

Re: Don't use ENV variables for secret data (2017)

#117
post #66

I am progressively adopting Hashicorp Vault as the secrets manager of choice. It can be used by a variety of different scenarios -- directly into the application using AppRole, with Terraform using it's secrets provider, by developers, during vault authentication when they get their secrets and access regenerated. This way I am not bound to docker swarm, or keywhiz, or god forbid AWS Secrets Manager. As of now, I am…

Vault looks cool, but looking at the reference architecture [1] my guts tell me it's much easier to fuck up setting up a Vault cluster than environment variables. [1] https://learn.hashicorp.com/vault/operations/ops-reference-a...

If you are in AWS, you can use S3 for data storage and DynamoDB for HA. Our first install was set up using their 'best practices' and consul, being stateful, is frustrating to run in kubernetes. We migrated to using S3/Dynamo and now have fewer moving parts and haven't seen any issues.

Re: Don't use ENV variables for secret data (2017)

#118

Earlier quoted context omitted.

> not checked into the source code repository Or checked-in, for easy distribution, just encrypted: https://github.com/sobolevn/git-secret

I mean anything encrypted needs to be decrypted, meaning you have to... have the key stored in an environment variable on the server?

Or in a file, like ansible does it.

Re: Don't use ENV variables for secret data (2017)

#119

The advice is good. But why is ENV capitalized? The term is just "environment variable". One heuristic I use for evaluating technical material is orthography: if you spell or capitalize or spell something improperly, it's likely you'll get a lot else wrong too. As for secret storage: didn't we solve this problem with keyrings? If I must put a secret in long-term plaintext storage, I might as well put it in a file, wh…

>One heuristic I use for evaluating technical material is orthography: if you spell or capitalize or spell something improperly, it's likely you'll get a lot else wrong too.

And while the program env is lowercase, the environment is commonly referred to as ENV in technical literature, APIs and so on. If you didn't know that, it's likely you are getting a lot else wrong too...

Plus, the "heuristic" is bogus anyway. Though it might be fine for evaluating candidates for secretarial roles though...

Re: Don't use ENV variables for secret data (2017)

#120
post #44
post #25

Earlier quoted context omitted.

Maybe he's got a history of working with PHP? $_ENV is an autoglobal array that gets filled with environment variables. https://www.php.net/manual/en/reserved.variables.environment...

The example they use at the top of the article is in bash/shell, and seeing it written as in the article (as "ENV variables") is kinda like a code smell, indicating the author isn't really familiar with what they're criticizing. I think that's what GP is getting at, and it threw me as well - the article really only makes sense when looking at it from the perspective of the author not knowing how env vars are scoped.

It's very common to write ENV in all caps. You can be a bona fide master in UNIX and write it that way (just like some people write UNIX and others Unix).

Sorry, but technical knowledge/experience is not about particular spelling conventions and word proofing, anymore than they are about wearing "business" clothes...

Post reply on HN