Live data from Hacker News

Crypto Tools for DevOps: Git-Crypt – Tozny

tozny.com

21–30 of 39 posts

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#21
post #2

Don't keep encrypted secrets in your git repositories, if for no other reason than that it makes access revocation deceptively difficult --- but also because it encourages you to have a development team in which ordinary devs have a full complement of secrets on their laptops at all times. Instead, keep secrets "out of band" and supply them to applications as part of your deployment process.

Well, not in your main repo. But secrets like other config benefit from versioning and so the perfect place to keep them is in a version control system no? You can sharply limit who has access; and perhaps only allow access via some web api. For small teams or lone developers I think git-crypt is great.

I would contend that they do not benefit from versioning and, as I pointed out above, can sometimes suffer as a result of it.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#22
post #21

Earlier quoted context omitted.

Well, not in your main repo. But secrets like other config benefit from versioning and so the perfect place to keep them is in a version control system no? You can sharply limit who has access; and perhaps only allow access via some web api. For small teams or lone developers I think git-crypt is great.

I would contend that they do not benefit from versioning and, as I pointed out above, can sometimes suffer as a result of it.

Which part of versioning is the problem? Is it the history keeping?

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#23
post #14

Earlier quoted context omitted.

I don't think it's quite as complicated as you make it out to be. 1. Write a script that will, when given a specific key, will decrypt a file, extract a specific credential that matches the key, and return it. (Credential Extractor-Writer) 2. Put the CEW file somewhere the devs don't have access. (Credential Store) 3. Make a script to connect to a specific host and port using PKI or public-key auth (HTTPS, SSH), and…

I am not arguing you can't implement a solution. You literally just repeated what I said by specifying A specific implementation. My point earlier is that you will never be able to keep anything secret. There is always a point of trust you have to give up and hope your extreme defense system doesn't crack / expose.

Ah, I thought you were just saying it's too complicated. Of course nothing is totally secure. But there is a point where "extreme" mitigations are called for, and not considered extreme, and the scope of potential problems of trust can be limited.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#25
post #3
post #2

Don't keep encrypted secrets in your git repositories, if for no other reason than that it makes access revocation deceptively difficult --- but also because it encourages you to have a development team in which ordinary devs have a full complement of secrets on their laptops at all times. Instead, keep secrets "out of band" and supply them to applications as part of your deployment process.

Just curious - what's the preferred way of passing secrets from the deployment process to the application? Environment variables? Simple to use and understand but can leak to child processes and crash reports. Files on disk? Usually can also be read by children. Via stdin on app startup? Seems simple... Some other way?

For many purposes passing in secrets by any of the above mechanisms can be fine, though as you noted there are caveats. Whether they matter depends strongly on your situation.

There are some things you can do outside of the physical means of passing the secrets that can help reduce risk:

- Give applications very constrained credentials that only give them access to what they actually need. This won't stop the credentials from getting compromised, but it at least reduces the risk of them doing so and -- assuming the credentials also serve as identification for the application -- allows you to trace back a compromise to the application it came from, which may make recovery easier.

- Use time-limited credentials that need to be renewed periodically. This is harder to implement without logic in the application, but it can potentially be done by having a file on disk (possibly ramdisk) that the application re-reads somewhat often and that gets updated by some other process.

- Pass an application a one-time-usable token via any of your given mechanisms and then have it reach out to some other service with that token to get the real secrets it needs. Since the token is invalidated on first use, the window of compromise is small and in particular this can help mitigate the child-process-related vulnerabilities as long as the app is careful to read its credentials before doing any other work.

Hashicorp Vault combined with the utility "consul-template" (which is now a bit of a misnomer since it talks to vault too) can be helpful building-blocks for implementing these ideas.

As noted above, whether this is warranted or suitable depends on your context and risk-tolerance. All security stuff requires cost/benefit analysis, since nothing is a magic bullet.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#26
Vault from hashicorp was built to solve the use case described in the article.

However, encrypting source code, in general, especially from hosting services like github is still a valid use case for many scenarios. GitZero attempts to solve it, but it provides no specific guarantees that the source code (for free tier) is inaccessible to the hosting service

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#27
post #3
post #2

Don't keep encrypted secrets in your git repositories, if for no other reason than that it makes access revocation deceptively difficult --- but also because it encourages you to have a development team in which ordinary devs have a full complement of secrets on their laptops at all times. Instead, keep secrets "out of band" and supply them to applications as part of your deployment process.

Just curious - what's the preferred way of passing secrets from the deployment process to the application? Environment variables? Simple to use and understand but can leak to child processes and crash reports. Files on disk? Usually can also be read by children. Via stdin on app startup? Seems simple... Some other way?

https://www.torus.sh/ is built for exactly that.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#28
post #3
post #2

Don't keep encrypted secrets in your git repositories, if for no other reason than that it makes access revocation deceptively difficult --- but also because it encourages you to have a development team in which ordinary devs have a full complement of secrets on their laptops at all times. Instead, keep secrets "out of band" and supply them to applications as part of your deployment process.

Just curious - what's the preferred way of passing secrets from the deployment process to the application? Environment variables? Simple to use and understand but can leak to child processes and crash reports. Files on disk? Usually can also be read by children. Via stdin on app startup? Seems simple... Some other way?

Checkout https://github.com/square/keywhiz, it's built specifically for this purpose.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#29
post #7

Earlier quoted context omitted.

We ran into this problem with terraform and we needed a fix quickly. The problem is that they recommend you check in your .tfstate files, which does make sense; they do need to be synchronized between everyone who might be working on the repo. However, we learned later down the line that in some cases, the state files might contain secrets. So we rolled out git-crypt for all .tfstate files to future-proof ourself aga…

Why not store your remote state in S3 buckets? They support encryption at rest.

Then you need a different secret in the application: the key to the data in the S3 buckets.

Ultimately, you have to supply at least one secret to the application at runtime, and then it can bootstrap its way to others if needed.

Re: Crypto Tools for DevOps: Git-Crypt – Tozny

#30
post #3
post #2

Don't keep encrypted secrets in your git repositories, if for no other reason than that it makes access revocation deceptively difficult --- but also because it encourages you to have a development team in which ordinary devs have a full complement of secrets on their laptops at all times. Instead, keep secrets "out of band" and supply them to applications as part of your deployment process.

Just curious - what's the preferred way of passing secrets from the deployment process to the application? Environment variables? Simple to use and understand but can leak to child processes and crash reports. Files on disk? Usually can also be read by children. Via stdin on app startup? Seems simple... Some other way?

I'm working on a saas-based solution to this problem: https://www.envkey.com

It requires no additional ops or key management, protects against unwanted overwrites, has much simpler access controls than IAM, and provides a lightweight UI to manage everything.

It uses language SDKs to decrypt and inject config on process startup, so you don't even need an additional deployment step. You just add the 'envkey' library (on rubygems and npm so far), set a single environment variable, and then you can access all your config as if it was stored in local environment variables. The idea is to make this something that you rarely have to think about.

I have a (desktop-only) demo working if anyone's interested in giving it a try: https://demo.envkey.com/demo

Feedback is very welcome.

Post reply on HN