SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CHMOD settings for upload folder

    I have created a page that allows users to upload videos and I would like to try and make it more secure.

    Currently the page is password protected. The password is stored in the php page as a sha1 hash. Therefore when the user enters a password and clicks submit, it compares a hashed version of what they entered with the hashed version hard coded in the php page.

    If the passwords match, they are then presented with the form to upload a video.

    I have no checks on the file type as the client wants it to accept every video file format and checking for extensions was not that feasible as I imagine there is a large number of possible extensions. So currently any file type is allowed. I don't feel too comfortable about this.

    The files are uploaded to a folder in the root called "media" which is currently set to chmod 777 - I am sure it doesn't need to have this much access rights but wanted to at least be sure it works for testing. Would appreciate advice on what chmod setting I should use for this "media" folder.

    There is no need to display the videos online in any form. I have created a password protected admin area (just using the shared hosting control panel to set up the password protected directory). The admin area enables the admin to view a list of all videos uploaded and provides a link to each to download a zipped copy of the video. So the admin does not requiire the ability to view the videos online.

    So I wondered if there is a way to secure the "media" folder to prevent anyone else viewing or downloading the video files?

    Any advice much appreciated.
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,671
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Chucky,

    Why would you enable file execution? Why would you enable file execution for VISITORS? IMHO, 666 is not only appropriate but the safer chmod.

    Secure the folder against reading? Subtract 4 from the chmod digits (except yours [OWNER], of course). That should prevent access but I'd move your media directory outside the "webspace" if you really want to ensure that the files are not read by anyone but you (and PHP - so it can ZIP the file for you and move the ZIP file to a location within the "webspace").

    Regards,

    DK

    Regards,
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks David

    I tried to change the permissions of the media folder to 666 but it keeps defaulting to 766 when I review the settings.

    Also you recommend moving the media folder outside the webspace - however when I log in via FTP it puts me straight into the root and does not allow me to go up a level. I assume I would need to go up a level to create the media folder outside the webspace?

    Many thanks
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,671
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    chucky,

    You've created a user's FTP for your upload. Go back to cPanel and create one for you as the owner of the account and set it to your account's root (not the website's DocumentRoot). Putting "secure" information there (outside the webspace) protects it from access via browsers (albeit, not from FTP using your account's FTP).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •