I am running perl cgi scripts on Apache (1.3.33) webserver.
I have set-up individual working directories for all users in the path,say, /usr/local/wd/<unique user id>
If user 'sam' logs in and executes some programs, the logfiles are stored in the path /usr/local/wd/sam/.
I have written a perl-cgi script to view the log files using HTML::Templates.
CGI script
# Create the HTML Page from the Templates print $query->header(); $user = ... #get username $log_file = .... #get logfile my $template = "err.tmpl"; # Instantiate a new HTML::Template object my $template = HTML::Template->new( filename => $template ); $template->param( username => $user ); $template->param( log_file => $log_file ); # Generate the HTML page print $template->output();
Template File (err.tmpl)
<html> <head><title>Show Log Files</title></head> <body > <script> function show_file(){ window.open('/wd/<tmpl_var name = "username">/<tmpl_var name = "log +_file">') ; } </script> <form method="post" enctype="application/x-www-form-urlencoded" name=" +results"> <table align="center"> <tr><td><a href="javascript:show_file()">Log File</a></td></tr> </table> </form></body></html>
As I have set a soft link for 'wd' to '/usr/local/wd/' , I am able to open the link and view the logfile and everything seemed to be fine.
Then, I realized that by pasting the url ( say http://host.com/wd/sam/logfile1.log ) in the browser,I am able to view the logfile. Also, it opens up the possibility that I can paste http://host.com/wd/ and look at all the folders and files of all users as the webserver runs as a special user.
I am not sure how to prevent this if someone tries to access the folders in the above approach. ( I use CGI::Session to keep track of 'logged in' status of the user for all other pages but when it comes to viewing the logfiles, it goes out of control of CGI::Session )
Looking for some suggestions on how to handle this securely.
In reply to Perl CGI - Viewing logfiles - Security Issues by stumbler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |