Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Re: Re: Re: Vetting a CGI script

by iburrell (Chaplain)
on Nov 13, 2003 at 19:47 UTC ( #306909=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: Vetting a CGI script
in thread Vetting a CGI script

Definitely use when doing file uploads. It handles all the details.

It also writes the uploads to temp files. Since these are randomly named and placed in a temporary directory, these won't overwrite anything important. also takes care of removing the temp files once the script is done. With '-private_tempfiles', the file is deleted right after it is created so that nobody else can read. Only the process with the open filehandle can read it. also imposes size limits on uploads. This makes it harder for attackers to fill up the disk or slow down the network connection.

The next thing to consider is what happens with the uploaded file. Usually it gets copied someplace. It is important that the destination be controlled by the script and not by the uploaded file name. It is a good idea to hard code the destination directory. It should be separate from any script directories. It is also a good idea to keep the uploads separate from the static files. If the filename included with the upload is going to be used, it must be sanitized to remove dangerous characters and any path components.

Finally, most uploads should only be allowed to authenticated users. Allowing uploads from anonymous users is usually a bad idea.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://306909]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2017-08-16 18:18 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (272 votes). Check out past polls.