in reply to Re: Security Uploading Files
in thread Security Uploading Files

1. I am using the authentication in place by the server.
2. Could you please point me in the right direction where I can look to see how to do this?
3. I disabled the use of scripts in the web server itself and through the file system. Is this not enough?
4. Good call forgot to do this.
5. Everytime I turn on the taint switch I get the error:

Too late for "-T" option at C:\web\...

6. I am using binmode() on the filehandles. Am I not using them correctly.

Also is there any way to check to see if a file is actually that type? e.g. .jpg is actually an image file or .doc is actually a word document? Thanks for the tips so far!

Replies are listed 'Best First'.
Re: Re: Re: Security Uploading Files
by Vautrin (Hermit) on Apr 18, 2004 at 19:37 UTC

    In regards to checking the amount of disk space left, you may want to partition your hard drive so that files are uploaded on a separate partition. Then, even if someone manages to try to upload a terabyte of data from /dev/urandom, all that gets filled will be your partition, and your computer should still be able to operate.


    Want to support the EFF and FSF by buying cool stuff? Click here.
      While you're doing that, mount the partition with noexec:
                    noexec Do not allow execution of  any  binaries  on
                           the  mounted file system.  This option might
                           be useful for a server that has file systems
                           containing  binaries for architectures other
                           than its own.
      
      Also good for parititions that are writable by untrusted users. It was suggested to me recently that the whole web root should be on a noexec partition, with cgi's symlinked from /usr/lib (or, presumably, other trusted partitions).

      --
      eval pack("H*", "7072696e74207061636b2822482a222c202236613631373036382229");
      # japh or forkbomb? You decide!
Re: Re: Re: Security Uploading Files
by Joost (Canon) on Apr 18, 2004 at 18:01 UTC
    The easiest way to check how much space is left, is probably to use "some commandline tool" (I use df, but that only works on UNIX).

    Depending on how you disable scripting, not everything might actually be turned off (i.e. in Apache, if you disable CGI scripts, you might still have PHP switched on, etc.) Just make sure you really turned it all off, or serve the files via another script.

    Taint mode in IIS (and maybe some other web servers) can AFAIK not be turned on via the shebang line, you probably need to switch it on in the server config somewhere (haven't done this in years, so I can't remember how exactly). If you turn it on in the server, scripts using perl -wT should run fine too.

    As for file types, not reliably. Check for extensions and mime-type, but people can always fake it. File::MimeInfo::Magic might be useful.

    edit: oh yes, I overlooked the binmode in your script. I think it's fine like that.

    Hope this helps.
    Joost.