Jump to content

CHMOD security settings


php_joe

Recommended Posts

I have a webpage that some hacker managed to load a file onto.

 

My website's help support suggested that I should not use chmod 0777 since it is not secure.

 

However, I need to allow my site's visitors to open files & write information to them.

 

My question:

Is there a setting that will allow site members to create, open, write to, and delete files using my pages but will not allow them to create their own pages outside of my control?

Link to comment
Share on other sites

Are these files ever executed? Is the path accessible to the user, i.e., they can type it into the address bar?

 

Some are, some are not. What I'm mainly worried about is someone injecting a file into a folder and using it to create new files or modify & damage existing files.

 

chmod dir to 555 or 755?

 

It might help also to restrict your world writeable files to a specific directory.

 

I'll try 555, thanks!

 

Do you know how to resitrict access to the folder so that files on my site can access it but visitors can not access it directly?

Link to comment
Share on other sites

Do you know how to resitrict access to the folder so that files on my site can access it but visitors can not access it directly?

 

"Visitors" use PHP via the webserver to access your pages; they don't do it directly.  So whichever user the webserver runs under is who is accessing your filesystem and permissions+ownership will apply to that user.

 

Unless, by "visitors," you mean users who are actually logged on to your system, then you can set the permissions to 600 or something.

Link to comment
Share on other sites

Are these files ever executed? Is the path accessible to the user, i.e., they can type it into the address bar?

 

Some are, some are not. What I'm mainly worried about is someone injecting a file into a folder and using it to create new files or modify & damage existing files.

 

Who controls the execution? What prevents a user from creating "file.txt", but adding a shebang line of "#!/usr/bin/perl" for example, and then executing their file?

Link to comment
Share on other sites

"Visitors" use PHP via the webserver to access your pages; they don't do it directly.  So whichever user the webserver runs under is who is accessing your filesystem and permissions+ownership will apply to that user.

 

I've seen websites that have a folder full of images. If you try to view the image directly then it redirects you or says "forbidden" but it still shows up on the webpages.

 

I tried changing the folder's permissions, but whenever I deny access to the folder all I get is a red X where the image on the webpage should be.

 

I know that I can put all the remote files in a secret folder. I'm just worried about some hacker guessing the member account's folder's name, or using a search program to find it.

Link to comment
Share on other sites

I've seen websites that have a folder full of images. If you try to view the image directly then it redirects you or says "forbidden" but it still shows up on the webpages.

 

I think the only way to do that is through the webserver configuration, and it can still be overcome if a user can set the HTTP_REFERER value.  It can't be done via file permissions.  You'd have to set a rewrite rule or something in the httpd.conf file to only server images if requests come from a certain HTTP_REFERER value.  You can restrict directory listings in the httpd.conf (and possibly by turning read access off a directory but leaving it on the files inside the dir).

 

Your webserver is the user accessing the files on the system, regardless of if a user types in the address directly, clicks a link, or is "logged in" one of your web applications.  Whatever permissions you have set always refer to that user.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.