Joey The Saint has asked for the wisdom of the Perl Monks concerning the following question:
Hey folks,
I'm in a position now where I'd like to provide access to a binary on a web-server via a cgi script. I've been handed a cgi that does the job reasonably well, but I'm not convinced it's at all secure or robust, so I'd like some confirmation/advice on it.
The first problem is it wasn't written using CGI.pm and I'm not quite up to re-writing it the right way just now unless I absolutely have to. Here's what it does:
unless (open(PIPE, "search \"$pattern\" |")) { # barf out some error messages } # carry on processing the output from the search command
Now is it just me, or is this opening a sub-shell and thus providing a way for almost anyone to execute almost any code on my web-server with (at least) the permissions of the server's UID/GID? Is there a way I can insist that the open() command execute a restricted shell, or better yet only execute the 'search' command without a shell at all so I don't have to worry about evil escape sequences that I can't really quotemeta since they are regexps?
Thanks,
-J.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question about input pipes and sub-shells
by kjherron (Pilgrim) on Nov 14, 2001 at 20:49 UTC | |
by blakem (Monsignor) on Nov 15, 2001 at 00:02 UTC | |
|
Re: Question about input pipes and sub-shells
by suaveant (Parson) on Nov 14, 2001 at 20:11 UTC | |
by Joey The Saint (Novice) on Nov 14, 2001 at 20:33 UTC | |
by suaveant (Parson) on Nov 14, 2001 at 20:45 UTC |