Live data from Hacker News

Ask HN: In a microservice architecture, how do you handle managing secrets?

news.ycombinator.com

51–60 of 60 posts

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#51
We run a PHP hosting platform and that tickled us as well. We were especially upset with the common sense that storing secrets in ENV vars is a good idea — in PHP those vars are easily exposed. See our blog post: http://blog.fortrabbit.com/how-to-keep-a-secret — here we suggested:

1. create a secret key, store it with the code of your App 2. store the encrypted credentials in env vars

Later on we even launched our own solution for our clients, an app_secrets.yml file, which can be edited via Dashboard. http://help.fortrabbit.com/secrets

The nice thing is, that this file is partly managed by the platform for it's own credentials and partly by the user.

That has been running for a while now. The adaption rate is low until now. It turned out that not everything will fit into that ONE fault. Blackfire.io and NewRelic run as PHP extensions, thus the API-keys are stored with the extension setting.

We have also discussed to implement an some open source "Secret as a Service" but came to the conclusion that this can too easily turn into to be a SPOF.

I am amazed that this topic is getting discussed again and I have learned about many new concepts here.

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#52
post #30

You can encrypt and deploy secrets using Distelli. https://www.distelli.com/docs/user-guides/securing-your-appl... Disclaimer: I'm the founder at Distelli

This is not a trivial thing. Why should I trust you with my company's secrets?

How do you manage key storage securely? Can people at your company see my secrets? If somebody comes with a court order will you give them my secrets and not tell me? What encryption algorithms do you use? What experience do you have in reducing attack surfaces from internal and external threats? Is any of your software open source? Has your software been audited? Is it PCI (or any other standard) compliant?

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#53
We ended up creating https://github.com/meltwater/secretary to allow storing encrypted secrets in config files checked into Git by devteams. The encrypted secrets are passed as env vars through the continuous delivery pipeline, Mesos/Marathon and into containers. They're then decrypted and injected into the app environment at runtime, safely inside the container.

At startup the container reaches out to the Secretary daemon that holds the master keys, using public key cryptos to authenticate itself. The Secretary deamon uses Marathon to authenticate containers (checking their public keys stored in env vars) and validate that they're authorized for the specific secret in question (checking that the encrypted secret is indeed part of the containers env vars).

Meaning that Marathon is the single source of trust of which container can access what secrets. The problem then becomes controlling who and how changes are made to the Git repo containing the CD config, which is something Github does well with roles, status/deployment API and pull requests.

We had a similar problem as some describe with the distribution of the initial secret (i.e. Vault token) and one time Vault tokens being cumbersome in dynamic scaling envs. We didn't want the cleartext token ending up in config files nor in the https://github.com/meltwater/lighter config we use to drive our continuous delivery pipelines that go into Mesos/Marathon. We also had some other aspects like

* Wanting to keep secrets, app config and code versions promoted together throughout or deployment pipelines. Seeing secrets as another type of app config we wanted to track all config and versions for an app in the same way, in the same place to avoid mismatches or deployment dependencies.

* Wanting to enable our very independent devteams to easily manage secrets for their services, same was as they manage the app config, versions and rollout of their services. And delegate management of what service is authorized for what secrets to devteams (with both automated checks for unencrypted secrets, and some gentle manual coaching post-commit)

* Versioning and rolling upgrades for secrets? E.g. how to roll out a new secret in a Marathon rolling upgrade? Creating and managing versioned keys in Vault seemed somewhat cumbersome.

Perhaps something like that could be used to solve your initial secret distribution problem or even handle the secrets themselves until Vault has solved the initial secret problem..?

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#54
Because we are already using Consul we went with Vault. We are using it in a POC type setup now (only for a few services/scripts) but so far it's been pretty easy to work with. The API is fairly easy to use outside of the fact that there is no search function (or wasn't last time I checked). The documentation could be better but since it's a public project and I haven't submitted anything I'm not going to bash that :) The fact that it's a single binary is another thing we liked. just drop it out somewhere and run it.

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#55
post #3

We use Kubernetes, which includes its own secrets API: http://kubernetes.io/v1.1/docs/user-guide/secrets.html I can't remember which issue this was on, but it seemed like there was some discussion on their GitHub project about making pluggable secrets backends (HashiCorp's Vault was mentioned). Kubernetes' secrets API is still very basic, but I think the fundamental concept is very sound and has a great foundation to…

Are the k8s Secrets still stored in plaintext in the etcd datastore? Seems that this feature is a bit half-baked right now -- though I'd love to me mistaken on this point. The k8s docs mention shredding your apiserver hard drives once you're done with them; that's hardly feasible in a cloud environment.

Also on access control, any process with root on any node in your cluster can get access to all your secrets (since the kubelet needs to be able to do so). There are no user access controls either; any cluster admin can dump all the secrets.

This stuff is clearly documented, so it's not an indictment on k8s; I just get the feeling that the feature isn't really ready for production use yet.

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#56
post #30

You can encrypt and deploy secrets using Distelli. https://www.distelli.com/docs/user-guides/securing-your-appl... Disclaimer: I'm the founder at Distelli

This is not a trivial thing. Why should I trust you with my company's secrets? How do you manage key storage securely? Can people at your company see my secrets? If somebody comes with a court order will you give them my secrets and not tell me? What encryption algorithms do you use? What experience do you have in reducing attack surfaces from internal and external threats? Is any of your software open source? Has yo…

All good questions. We do not store your secrets. You do not give us your secrets. Your secrets do not live on our servers. No one at our company can see your secrets or access them.

We provide you with an agent that you install on your own servers and that agent is marked as a key management server. That agent is contacted to do asymmetric key encryption.

Here is a more detailed blog post about this: https://www.distelli.com/blog/keeping-your-application-secre...

Also we use standard encryption algorithms and have not written our own crypto (and never will).

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#58
post #55
post #3

We use Kubernetes, which includes its own secrets API: http://kubernetes.io/v1.1/docs/user-guide/secrets.html I can't remember which issue this was on, but it seemed like there was some discussion on their GitHub project about making pluggable secrets backends (HashiCorp's Vault was mentioned). Kubernetes' secrets API is still very basic, but I think the fundamental concept is very sound and has a great foundation to…

Are the k8s Secrets still stored in plaintext in the etcd datastore? Seems that this feature is a bit half-baked right now -- though I'd love to me mistaken on this point. The k8s docs mention shredding your apiserver hard drives once you're done with them; that's hardly feasible in a cloud environment. Also on access control, any process with root on any node in your cluster can get access to all your secrets (since…

afaik the only part of kubernetes accessing etcd is the master. Nodes don't need and can't access etcd directly.

That still leaves the secret in plain view on the nodes that run the pod that needs the service. It would be great to be able to umount the secret when not needed anymore.

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#59
post #58
post #55

Earlier quoted context omitted.

Are the k8s Secrets still stored in plaintext in the etcd datastore? Seems that this feature is a bit half-baked right now -- though I'd love to me mistaken on this point. The k8s docs mention shredding your apiserver hard drives once you're done with them; that's hardly feasible in a cloud environment. Also on access control, any process with root on any node in your cluster can get access to all your secrets (since…

afaik the only part of kubernetes accessing etcd is the master. Nodes don't need and can't access etcd directly. That still leaves the secret in plain view on the nodes that run the pod that needs the service. It would be great to be able to umount the secret when not needed anymore.

Correct, the etcd instance is only accessed by the master, which uses etcd to back the apiserver. But any root process on the nodes can access the secrets through the apiserver (there's no access control at this point).

Re: Ask HN: In a microservice architecture, how do you handle managing secrets?

#60

Earlier quoted context omitted.

Yes, but is there a succinct howto on this?

1) Have an EC2 instance with a role-specific IAM Role 2) Create a S3 bucket 3) Write a bucket policy that whitelists specific IAM Roles to specific key paths within the bucket.

4) Put secrets in that bucket (duh)
Post reply on HN