Live data from Hacker News

The Twelve-Factor App (2011)

12factor.net

41–50 of 106 posts

Re: The Twelve-Factor App (2011)

#41
post #27

Earlier quoted context omitted.

Arbitrary file read vulnerabilities are extremely common.

Sure, but if you have one of them, then you can read the secret files out of /vault or whatever too.

Correct! This is why I explicitly said the following in the blog post I linked above:

> Once the application hits “readiness” status (as determined by health endpoints or the load balancer), the secrets volume should be unmounted and made inaccessible.

Re: The Twelve-Factor App (2011)

#42

One thing that I think could be updated in the 12F approach is the use of env vars for config, especially secrets. I’ve generally found it much better to mount these into the filesystem and read from there. It helps with, for example, secret rotation for long running processes. Relying on process restarts can be ugly in some setups, especially if startup time is expensive.

It's the part of 12 factor that makes me giggle a bit; like it how does it get into the environment? Reminds of the "Front fell off" comic sketch. "No, we towed it out of the environment" https://www.youtube.com/watch?v=3m5qxZm_JqM

"Well what's out there?"

"Nothing's out there."

"Well there must be something out there."

"There is nothing out there. All there is, is sea, and birds, and fish."

"And?"

"And 20,000 tons of crude oil."

"And what else"?

"And a fire."

"And anything else?"

"And the part of the ship that the front fell off. But there's nothing else out there. It's a complete void."

Re: The Twelve-Factor App (2011)

#43
post #41

Earlier quoted context omitted.

Sure, but if you have one of them, then you can read the secret files out of /vault or whatever too.

Correct! This is why I explicitly said the following in the blog post I linked above: > Once the application hits “readiness” status (as determined by health endpoints or the load balancer), the secrets volume should be unmounted and made inaccessible.

Then I'll just pull it from the processes memory directly. It's security through obscurity at best.

Re: The Twelve-Factor App (2011)

#44
post #34

Earlier quoted context omitted.

Hey dang. I have a question too. Does it really need a 2011 tag? I thought only blog posts and news articles got year tags. 12FA is guidelines website that is mostly timeless. What's the criteria for a year tag?

The year tags can and do go on anything, they're more for the readers than as some sort of commentary on the timeliness or lack thereof of the content. I think lots of people just find them handy to easily distinguish recent from not-so-recent stuff, as a very basic use case.

I’ve been curious what the oldest year tag applied on HN is.

Re: The Twelve-Factor App (2011)

#45

One thing that I think could be updated in the 12F approach is the use of env vars for config, especially secrets. I’ve generally found it much better to mount these into the filesystem and read from there. It helps with, for example, secret rotation for long running processes. Relying on process restarts can be ugly in some setups, especially if startup time is expensive.

> One thing that I think could be updated in the 12F approach is the use of env vars for config, especially secrets.

The 12F section on config already mentions quite prominently the use of config files.

Taken from https://12factor.net/config

> "Another approach to config is the use of config files which are not checked into revision control, such as config/database.yml in Rails. This is a huge improvement over using constants which are checked into the code repo, but still has weaknesses: it’s easy to mistakenly check in a config file to the repo; there is a tendency for config files to be scattered about in different places and different formats, making it hard to see and manage all the config in one place. Further, these formats tend to be language- or framework-specific."

Re: The Twelve-Factor App (2011)

#46
post #43
post #41

Earlier quoted context omitted.

Correct! This is why I explicitly said the following in the blog post I linked above: > Once the application hits “readiness” status (as determined by health endpoints or the load balancer), the secrets volume should be unmounted and made inaccessible.

Then I'll just pull it from the processes memory directly. It's security through obscurity at best.

It seems to me in line with the comment that the post quoted:

> Ultimately, secrets need to live somewhere and need to be accessed as plain text. Just make sure that the access as small window is as [sic] possible, and try to obliterate it after use, if possible.

This is not an all-or-nothing situation; it's a game of mitigation. If the process needs to retain the secret in memory, true, there's not much you can do about that. But I don't think that minimizing where else you're storing it is just security through obscurity. Fewer possible attack vectors is still fewer possible attack vectors.

Re: The Twelve-Factor App (2011)

#47

One thing that I think could be updated in the 12F approach is the use of env vars for config, especially secrets. I’ve generally found it much better to mount these into the filesystem and read from there. It helps with, for example, secret rotation for long running processes. Relying on process restarts can be ugly in some setups, especially if startup time is expensive.

In kubernetes I run external secrets, which is nice. I store The secrets in key value or file format in AWS Secrets Manager, which gets synchronized to the cluster into a secret. From there it gets mounted into the running pod via the envFrom or volume mount method.

External secrets are great, especially if your app can read them directly from k8s and avoid ever having them mounted as a volume (or in env var).

If your app can’t interface directly w/k8s, but it can read secrets from a file, you can use a small init program to fetch the k8s secret and write it to a named pipe. This is advantageous compared to mounting as a volume, because the pipe disappears after both ends close their connection to it.

Re: The Twelve-Factor App (2011)

#49
post #43

Earlier quoted context omitted.

Then I'll just pull it from the processes memory directly. It's security through obscurity at best.

It seems to me in line with the comment that the post quoted: > Ultimately, secrets need to live somewhere and need to be accessed as plain text. Just make sure that the access as small window is as [sic] possible, and try to obliterate it after use, if possible. This is not an all-or-nothing situation; it's a game of mitigation. If the process needs to retain the secret in memory, true, there's not much you can do a…

Now, if you encrypt them in memory, or even better obtain the creds in an audited fashion, use them and clear the memory promptly, it's slightly better.

Re: The Twelve-Factor App (2011)

#50

One thing that I think could be updated in the 12F approach is the use of env vars for config, especially secrets. I’ve generally found it much better to mount these into the filesystem and read from there. It helps with, for example, secret rotation for long running processes. Relying on process restarts can be ugly in some setups, especially if startup time is expensive.

EnvKey[1] can help with process reloading, and can facilitate both restarts and hot reload updates. (Disclaimer: I’m the founder.)

The pros/cons of environment variables vs. files (or other approaches) is also something I’ve thought about a lot while working on EnvKey.

We use environment variables as a default approach, since it seems to be the most common way to pass secrets/config to a process in the wild and we want to meet people where they’re at. But we also make it easy to use files or system calls instead (I think system calls are actually the most secure.)

One thing it’s always important to remember though in security: if you make the “secure way” too hard, people will route around it, making matters worse in practice. There’s always a balance to be struck.

Honestly, I’m skeptical that threat models where environments are exposed but files are safe are realistic enough to be worth worrying about. At that point, it seems like rearranging deck chairs on the Titanic.

It seems simpler to say “our last line of defense is the OS boundary.” You trust the host and go from there. If the host is breached, you’re screwed in a plethora of ways. There’s no point in sweating the particulars. Just don’t let it happen in the first place!

And when it comes to concerns about leaking the environment to sub-processes, this seems like a deeper problem. Even if you don’t store secrets in the environment, that doesn’t mean it’s safe to just send env vars off wherever. At this point, like it or not, environments are sensitive, because enough people and programs treat them as sensitive that it’s a self-fulfilling prophecy. If they might be leaked, then the leak is the security problem in my eyes, not the data in the environment.

1 - https://envkey.com

Post reply on HN