cat /proc/<pid>/environ
Other users' processes can't see /proc/$pid/environ, unlike using cmdline.
λ whoami
cjb
λ cat /proc/1/cmdline
/sbin/init%
λ cat /proc/1/environ
cat: /proc/1/environ: Permission deniedUnless the secret is some kind of one-time token, or time based token, but then it's also not relevant how the secret was passed to the process. It's invalidated soon.
Exactly; macOS doesn't use /proc.
By my estimation, I would guess the number is smaller than people think for a few reasons.
1. How many people who aren't technically saavy have external drives at all? If they do, it's probably a Time Machine volume. Which leads me to my second point...
2. Directory hardlinks - the tech which makes TM work - don't exist on APFS, so a fair number of these drives are probably still using HFS+, and last I checked, external SSDs of any sufficient capacity are still pretty costly, which brings me to the last point...
3. Given that APFS is really SSD-only (with a small asterisk for Fusion Drives), converting a TM volume on a spinning disk is a recipe for pain.
I'm not excusing the bug, only reiterating that its effect is probably less than you might imagine among people who aren't nerds (or HN readers for that matter).
> could you provide some references to the statement?
If you search the Usenet archives, you can find many discussions about this. It's one of those topics that came up frequently in the comp.unix newsgroup as early as 1991 that I see in some messages.
Usenet discussion from 1994:
"ps e gets you a processes environment. It is totally unsafe to store anything that should be secret. if there needs to be secret data, the best way to get it is with scanf(), once the program is running."[1]
And here is the Secure UNIX Programming FAQ from 1999:
"A security hole related to FreeBSD's 'ps' utility. The utility would allow users to view another process' environment variables. Consequently applications like pppd that accepted passwords via environment variables became vulnerable to unauthorized release of privileged information attacks. In fact, thehole was not related to 'ps' if you think about it critically. The application that places privileged information in the environment variable is at fault."[2]
[1]https://groups.google.com/forum/m/#!search/ then search for "ps shows command line parameters" (for the exact message, search for "ps e gets you a processes environment")
[2]http://faqs.cs.uu.nl/na-dir/unix-faq/programmer/secure-progr...
Now typically these processes only run for a short time so it’s difficult to catch passwords manually but it’s predictable so a script can.
Note that you do need to take care to clean up the environment if you create new, unprivileged subprocesses or these secrets may leak.