Live data from Hacker News

Ask HN: What tools should I use to manage secrets from env files?

news.ycombinator.com

41–50 of 83 posts

Re: Ask HN: What tools should I use to manage secrets from env files?

#41

The place I work has a list of security guidelines that is, like, ten pages long and full of links to more detailed explanations. The exact advice depends on how you’re running your services. My starting advice, for cloud, is this: 1. Run in multiple, separate accounts. Don’t put everything in one account. This could be as simple as having a beta account for testing and a separate production account. 2. Use cloud-bas…

> If you are TheBigDuck234, then you access your cloud resources using a TheBigDuck234 account, always.

Or have a 'sudo' TheBigDuck234-to-AdminAcct mechanism if possible, or TheBigDuck234_admin account.

On my Linux machines I do sudo-to-root, but on macOS, my daily driver account does not have sudo access so I have to first su to "admin" and then can sudo from there (for GUI requests I enter "admin" (or whatever)).

Re: Ask HN: What tools should I use to manage secrets from env files?

#42
A while ago, I had this exact problem and I threw a template together using a combination of age + passage + agenix (nix) solution to automate my secret management solution.

https://github.com/Swoorup/passage-nix-secrets-template

EDIT: This is meant to used in a nix-based deployment setting, and also you don't want to commit the identities file unless you use yubikeys (Something which I forgot to mention in the readme).

Re: Ask HN: What tools should I use to manage secrets from env files?

#45
Usually `.env` files are sourced into your development shell and also ignored by `.gitignore`.

The problem with `.env` files is that you're leaving credentials unencrypted on disk and it's easy to leak these files during screen sharing and with multiple projects there will eventually there will be so many secrets spread/sprawled everywhere that you lose track of what credentials are being used and what are expired. You want to be able to inject the required keys only when needed and leave no trace behind when not needed.

I wrote about this in our documentation for Polykey: https://polykey.com/docs/how-to-guides/developers/developmen...

We are still working out the kinks but I expect that one should be able to easily do `. <(polykey secrets env project-vault)` in whatever development shell you have, perhaps even reference a schema for expected keys.

Re: Ask HN: What tools should I use to manage secrets from env files?

#46

The place I work has a list of security guidelines that is, like, ten pages long and full of links to more detailed explanations. The exact advice depends on how you’re running your services. My starting advice, for cloud, is this: 1. Run in multiple, separate accounts. Don’t put everything in one account. This could be as simple as having a beta account for testing and a separate production account. 2. Use cloud-bas…

> If you are TheBigDuck234, then you access your cloud resources using a TheBigDuck234 account, always. Or have a 'sudo' TheBigDuck234-to-AdminAcct mechanism if possible, or TheBigDuck234_admin account. On my Linux machines I do sudo -to-root, but on macOS, my daily driver account does not have sudo access so I have to first su to "admin" and then can sudo from there (for GUI requests I enter "admin" (or whatever)).

So, this would be done in AWS by having e.g. IAM roles that you can assume from your user account. Your user account is your identity, and the IAM role that you assume is what grants you permissions. You can then log something like “this action was performed by Admin assumed by TheBigDuck234”, because the original identity is also recorded.

There are some rough edges around the experience here if you really do want the best security posture, but you don’t have to go all the way. You can just create your one IAM user (just one per person) and then create multiple roles. When you log into the console, you authenticate as the user and then choose the account + role you want to use. I recommend creating a “read only” role. The purpose is to let people poke around in the console and debug problems without risking creating problems in production infrastructure—this is more of an operations than a security problem, though.

Re: Ask HN: What tools should I use to manage secrets from env files?

#47
Another new (open source!) tool to check out in this space is https://dmno.dev

It's a bit different than most of the other tools listed here, in that it is designed to generally solve the papercuts of dealing with config (both sensitive and not), and is not coupled to storing your sensitive config in a specific platform (paid or otherwise).

You define a simple schema for all of your config, and you get validations, built-in documentation, full type safety, and the ability to compose config together in any way you choose. You can also easily share config across a monorepo (if you are using one).

Additionally, our drop-in integrations (node, vite, nextjs, astro, remix, more on the way) go a bit deeper and do things like help you detect and stop leaked secrets, redact secrets in logs, and deal with the footguns of boot vs build time config in hybrid rendering environments.

As for storing/syncing sensitive data, we currently have 2 plugins but more are in the works and will be guided by user demand. The first lets you store your secrets encrypted within your repo (like dotenvx, git-crypt, etc), and the second lets you sync with 1password. Personally we think the 1password plugin makes sense for a lot of teams, since they are probably already using it. You can wire up individual items to your schema, or pull from dotenv style text blobs. You can (and should!) segment items into multiple vaults, and use multiple service accounts to access them. You can even mix and match plugins to pull secrets from multiple services.

(see https://dmno.dev/docs/plugins/encrypted-vault/ + https://dmno.dev/docs/plugins/1password/)

In the future, we'll have deeper support for things like key rotation and single-use keys, k8s, way more backends, etc. It's all open source, so come and tell us what you need (or even help us build it) and we'll make it happen!

If it's not obvious already, I am the creator :)

PS - Feel free to hit me up for more info or a demo - theo at dmno dot dev

Re: Ask HN: What tools should I use to manage secrets from env files?

#49

What about https://dotenvx.com/ ?

This is by far the simplest solution. It’s easier to understand and setup than the other solutions mentioned. It simply encrypts the value portion of the variable so its safe to commit the entire env file. The only draw back is developers could still potentially commit private keys the repo or commit the decrypted env file. If you’re working with env variables that don’t require updates often it’s a decent solution.

Re: Ask HN: What tools should I use to manage secrets from env files?

#50

Usually `.env` files are sourced into your development shell and also ignored by `.gitignore`. The problem with `.env` files is that you're leaving credentials unencrypted on disk and it's easy to leak these files during screen sharing and with multiple projects there will eventually there will be so many secrets spread/sprawled everywhere that you lose track of what credentials are being used and what are expired. Y…

It may seem this is snark, but I promise I don't mean it that way: why do you not drink your own champagne? https://github.com/MatrixAI/Polykey/blob/v1.13.0/.github/wor...

I see references to gitlab CI yamls in the source tree, implying you are multi-CI which seems like an extra awesome way to showcase the one source of truth for credentials. Bonus confetti if Ploykey were able to auth as the CI job via https://docs.github.com/en/actions/security-for-github-actio... or https://docs.gitlab.com/ee/ci/yaml/#id_tokens

Post reply on HN