3 ms·
From the article: But it irritates me when I need to get at gpg from a web application, and can't just use a "libgpg". I have to fork a gpg process, setup file
by ajross 18y ago
From the article:
But it irritates me when I need to get at gpg from a web application, and can't just use a "libgpg". I have to fork a gpg process, setup file descriptors just right, write input to a pipe, wait for input on another pipe, and then parse the result
It boggles the mind that a perl programmer, of all people, would think this. The relevant code for the above is generally something like:
my $data = `gpg --decrypt --passphrase=$PASSWD $FILE`;
or:
open INPUT, "gpg --decrypt --passphrase=$PASSWD $FILE|";
while(<INPUT>) { ... }
The incredibly tight integration with external programs (e.g. the code to "setup file descriptors just right" consists of one byte!) is the very essence of what makes perl great and special. I'm just dumbfounded here. He likes perl but doesn't understand how to fork a process?
I mean, the whole premise of the point is counter to the perl philosophy, which is that you're already on a great and useful platform and just need a tool to tie things together nicely. If you want a single platform designed around the idea that all meaningful tasks are available in a library without leaving the sandbox, you are looking at Java or .NET, certainly not perl...
- jrockway 18y agoNow $PASSWD is available to anyone running "ps". The GPG manual suggests that you open a separator file descriptor for the passphrase. Basically, it's easy to do things if you aren't aiming for security or correctness, but in this case, I am.
- ajross 18y agoHeh, cool, the trap worked: $PASSWD was available to everyone on the box anyway. You stick it in memory, it's readable. That's the way life works. You probably stuck it in a database too, right? Did you lock down the socket from local users? Probably not. Did you store the database password off-line? Probably not, because you wanted unattended startup to work. The bottom line is that if you want to do password storage in your web app that is secure against local users, you have vastly more work to do than just finding a CPAN library somewhere.
- jrockway 18y agoHeh, cool, the trap worked: You win the Internets!
- bestes 18y agoHeh, cool, the trap worked: Not cool. At all. (I don't know enough security to determine if you are correct or not, so my comment only applies to your tone)
- ajross 18y agoOK, just curious: how is the posting of judgemental one-liners unrelated to the subject at hand somehow less of an etiquette violation than a perfectly harmless (yet responsive and topical) rhetorical snipe? I mean, as flames go this was pretty mild sauce. Can't you spend your time policing some of the legitimate flame wars that pop up here instead?
- bretthoerner 18y agoEh, maybe my UNIX-fu is weak... Say UID 100 is running PID 200 which has "my password" in memory. How does UID 300 read the memory of PID 200? If it requires a security flaw, I don't think it's fair to compare to the ease of using 'ps' ... if it doesn't, please explain so I can learn something today. :)
- ajross 18y agoOn a linux box, read /proc/200/mem. Or just allocate a bunch of memory and force it to swap out, then read the swapfile. Season liberally with local root exploits if needed (these come in bucketfuls on most unices). This is a classic attack: while it's not terribly practical, it's a whole lot easier than trying to brute force the password stream. I'm not saying local-attacker password security can't be locked down securely. Simply that doing so is a much more complicated proposition than "use a library". In practice, most web applications are not secured against hostile local users. I'm not sure I've ever seen one that was. So to my mind, ruling out some of the most powerful tools you have (perl's IPC facilities) in a vain attempt to achieve a security level that the rest of your architecture doesn't support seemed silly.
- nailer 18y ago> It boggles the mind that a perl programmer, of all people, would think this. I moderated you up assuming you were about to provide a better way to perform the task then nastily calling an external command to do it. I should have read your post fully first.
- edu 18y agoThe idea is that in perl is very usual and common place to call externals programs, the thing is that you don't need to setup the filedescriptors manually as jrockway says he does in the article.