awohld has asked for the wisdom of the Perl Monks concerning the following question:
How big is the risk of someone exploiting this script to hack the server? Particularly I'm worried about someone inserting some code into the file that the CPU would execute. Or put "../../../../../etc/passwd" in the file that would capatilize on the "open" or similar command.
I was thinking maybe I should PGP encrypt this file on the server. I'm also making a partition on the server that will just have "upload" data on it; to stop Denial of Service attacks (by filling up my hard drive).
How can I make this more secure? How can this be comprimised?
Here's my code:
#!/usr/bin/perl -w use strict; use CGI; my $upload_dir = "/upload"; my $query = new CGI; my $filename = $query->param("filename"); my $uldate = time; $filename =~ s/.*[\/\\](.*)/$1/; my $upload_filehandle = $query->upload("filename"); open UPLOADFILE, ">$upload_dir/$uldate"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Upload Script: Security Issue???
by Xaositect (Friar) on Jun 28, 2005 at 21:16 UTC | |
|
Re: File Upload Script: Security Issue???
by gellyfish (Monsignor) on Jun 28, 2005 at 21:04 UTC | |
|
Re: File Upload Script: Security Issue???
by hubb0r (Pilgrim) on Jun 28, 2005 at 21:01 UTC | |
by awohld (Hermit) on Jun 28, 2005 at 21:17 UTC | |
by fmerges (Chaplain) on Jun 28, 2005 at 21:41 UTC | |
|
Re: File Upload Script: Security Issue???
by cmeyer (Pilgrim) on Jun 28, 2005 at 21:12 UTC |