logoalt Hacker News

tptacektoday at 6:43 PM4 repliesview on HN

It's not my intuition that materializing secrets to files is a better way to protect them than just injecting them into the environment, where they don't persist.


Replies

abofhtoday at 7:13 PM

Dev/shm is used to materialize them, and then you have the ability to isolate the downstream code you might use from accessing it by dropping permissions or sandboxing it away from a file. You cannot really hide your environment from anything in process, since it's such a low level construct.

Thus it's easier to leak environment unintentionally, leaking file contents takes effort.

show 1 reply
crotetoday at 7:17 PM

It doesn't need to be a traditional file. You can pass it as essentially a read-once file by using stdin. Depending on your desire for modernity, similar behavior can be obtained by leaving a file handle open for the exec-ed process to inherit, via a Unix socket, or even a lightweight TCP daemon.

NewJazztoday at 6:59 PM

The env is technically still kind of a file on linux at least (through /proc).

Sometimes I feel like stdin or an unlinked memory mapped file might be the best location for this stuff. Wish Linux had a cloexec+1 option, where an fd is closed after two execs, so you can set up a child process for success.

show 1 reply
solarengineertoday at 7:15 PM

(Edit: I need to read up on this better)