News for hackers. Stuff that matters.
Re:The Twelve-Factor App (2011) by eriner_ on Thursday April 28, 2022 @10:11PM (#31200584)
I agree completely. Storing secrets in environment variables is wrong: https://blog.forcesunseen.com/stop-storing-secrets-in-enviro...

Even unsetting environment variables leaves them in /proc/self/environ. There isn't a thread-safe way to unset environment variables in POSIX, so even if you `unset TOP_SECRET` from within a program the contents of /proc/self/environ will remain unchanged and available.

Re:The Twelve-Factor App (2011) by josephcsible on Thursday April 28, 2022 @10:13PM (#31200597)
But /proc/*/environ is only readable by the user the process is running as and root, so if you can read it, you're already on the other side of the airtight hatchway.
Re:The Twelve-Factor App (2011) by eriner_ on Thursday April 28, 2022 @10:26PM (#31200695)
Arbitrary file read vulnerabilities are extremely common.
Re:The Twelve-Factor App (2011) by josephcsible on Thursday April 28, 2022 @10:48PM (#31200818)
Sure, but if you have one of them, then you can read the secret files out of /vault or whatever too.
Re:The Twelve-Factor App (2011) by eriner_ on Friday April 29, 2022 @12:12AM (#31201353)
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) by metadat on Friday April 29, 2022 @12:25AM (#31201423)
Then I'll just pull it from the processes memory directly. It's security through obscurity at best.
Re:The Twelve-Factor App (2011) by mumblemumble on Friday April 29, 2022 @12:39AM (#31201515)
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) by metadat on Friday April 29, 2022 @01:26AM (#31201753)
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) by Rapzid on Friday April 29, 2022 @03:21AM (#31202339)
Just an arbitrary file read vulnerability away at /proc/$pid/mem
Re:The Twelve-Factor App (2011) by mrslave on Friday April 29, 2022 @05:44AM (#31203255)
I really like my applications to at least try to reestablish dropped connections though. But I do appreciate the minimization mindset with respect to secrets.

The last time I was responsible for the scaffolding of a new software service it supported reading secrets from a file. It confused the operations team and I was just told to include support for an environment variable. Oh well, I tried.

Re:The Twelve-Factor App (2011) by hedora on Thursday April 28, 2022 @11:50PM (#31201197)
Or, if you only have access to proc, from the process's heap.
Re:The Twelve-Factor App (2011) by CameronNemo on Friday April 29, 2022 @03:28AM (#31202389)
How do you actually unmount the volume with kubernetes once the secrets are read and the process is ready? I've never heard of a feature like that.
Re:The Twelve-Factor App (2011) by thinkmassive on Friday April 29, 2022 @08:22AM (#31204220)
From my comment farther below:

> 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) by aliswe on Friday April 29, 2022 @05:02AM (#31203007)
you dont ... you remove the mapping and restart the pod.