4 ms·
Classic UNIX behavior was that environment variables were public (any user could see them with the right flags to "ps") so it was well-known not to put anything
by bodyfour 12y ago
Classic UNIX behavior was that environment variables were public (any user could see them with the right flags to "ps") so it was well-known not to put anything secret there.
Most (all?) of the current brand of UNIX variants have locked this down quite a while ago, which is a good thing. There are still a few old boxes kicking around though so if you're writing code that is meant to be widely deployed please don't put stuff there. For example: https://github.com/keithw/mosh/issues/156 https://github.com/keithw/mosh/issues/156
Even if you are sure that your code will only be running on modern machines I think this article gives good advise. Unless you purge the secret environment variables when you launch they'll get sent to all of your subprocesses and it's quite possible that one of them won't consider their environment secret.
- jheriko 12y agoThis is the best argument for not doing this imo. "Classic UNIX behavior was that environment variables were public (any user could see them with the right flags to "ps") so it was well-known not to put anything secret there." The same logic applies to Windows environments and modern *nix too... Storing private data in a public location is obviously a bad idea.
- marcosdumay 12y agoOk, but that's classical behaviour. Modern *nix behaviour is treating the environment as private data. I don't get the reason for all that disagreement. Both methos have clear practival advantages and problems, and both are nearly as secure as the other. Use whatever fits better your problem.
- otterley 12y agoIt doesn't work that way anymore, though. Only root can see other processes' environments via ps(1) now.
- otterley 12y agoOn Linux, at least, only root can view a process' environment via ps(1). So it's at least as secure as the filesystem from an inspection point of view.
- deleted 12y ago[deleted]
- elchief 12y agoIt's not public. Only a given user or root can see the envvar. Same as a file.
- moe 12y agoClassic UNIX behavior was also to have plaintext passwords in /etc/passwd, the shadow file was invented much later... But why should we jump through hoops for something that was broken over 15 years ago? Do you still filter ping packets on your router because back in the '90s large pings would crash[1] many operating systems? [1] http://en.wikipedia.org/wiki/Ping_of_death http://en.wikipedia.org/wiki/Ping_of_death
- elchief 12y agoWhat, you don't run AIX 0.9?