in reply to Perl/CGI Security Question

Another issue if the data is on a shared server might be "Who is the script running as?"

If nobody, then your data will need permissions of 777 -> anyone can read or update your data files through a simple perl script if they know they are there.

If this is an issue, you (or your sys admin :) should install cgiwrap. Then you can run your script as owner, and set permissions on data to 700.

cLive ;-)

PS - I've written a grey hat cgi-script that acts as a simple 'explorer' for the machine you're on. On install, you can browse directories/files that are world readable on the server you're on. It wouldn't take much to turn it into an editor for all files that are world writable as well :)

Basically, if you're not the only user on the server, assume the data will be read if permissions are 777. If this is a problem, get cgiwrap up and running :)

Replies are listed 'Best First'.
Re: Re: Perl/CGI Security Question
by Perlmage (Acolyte) on Mar 30, 2001 at 11:30 UTC

    Erm... unless the data needs to be executable for some reason, plain files can (and probably should be) at most mode 666. Mode 777 (world readable, writable, executable) would not only let anyone modify the data, but may let anyone execute any program as the webserver user, depending on how the server's configured. It's very rare that a file will need to be mode 777, IME.

    Realistically, you could probably get away with mode 644 if you chowned the file to the user the webserver runs as.

      sorry,

      I have a weird superstition about using 666 permissions (call me silly, please). No, I'm not a christian, just think it's too much of a coincidence that 666 == pure evil in terms of file permissions :) and the extra 1 doesn't really matter that much... (or does it? thoughts...)

      But yes, you are right. Immaterial really, coz you should be running stuff at 700/600/400 with cgiwrap anyway (or equivalent :)

      later

      cLive ;-)

      >Realistically, you could probably get away with mode 644 if you chowned the file to the user the webserver runs as.

      644/666 - does it really make a difference if the script's not wrapped? Either way the file's open to abuse by other users on the server...

        In a real work environment you are likely to need to share files with others. In that case you should allow write access by the group and choose a group that includes other people who deserve access. See your site policy for more detailed guidance on this.

        As for 666, I have always suspected that the permission scheme was deliberately chosen to make rw access to the world work out to be 666 specifically to make people think twice about doing so. If it wasn't intended then it was a darned convenient choice...