[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Can the owner of a file/folder be given just read access?

Posted on 2014-01-11
Medium Priority
Last Modified: 2014-01-20
hi guys

Is it possible for the the owner of a file/folder to merely have read and execute permissions in Linux? And then have another user with full read/write/execute who is not the owner?

The reason being is that not long ago, we were hacked due to php vulnerabilities and someone used sql injection that took over the site. The loopholes in php have been patched. However, we believe the reason the person was able to do this was because the owner of the file/group for those directories had full write permissions, so when the php code executed it acted as 'the owner'. This way, if something like this was attempted again, the php script would attempt to execute as the owner and realise it doesn't have permissions and fail. I'm assuming?

Question by:Yashy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 98

Assisted Solution

by:John Hurst
John Hurst earned 400 total points
ID: 39773932
You need to make an administrator owner of the folder and then have that admin provide read permissions to the user.

Provide an ultra strong password for this admin account.

.... Thinkpads_User
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 total points
ID: 39773934
It's not likely that you will find a good solution if you go down that path.  A more appropriate direction is to Accept Only Known Good Values, and this probably means changing your PHP scripts (there is nothing in PHP that is inherently vulnerable).

This is required reading for any PHP developer:

This is old, but it explains a lot of the bad history of PHP security:

This is old, too, but it has been updated for modern times:

This blunder is still hanging around in some PHP installations, but most of them have already been destroyed by hackers:

This organization is worth joining:

And amazingly, there are still some developers who have not seen this:

HTH, and best of luck with your hardening project, ~Ray
LVL 98

Expert Comment

by:John Hurst
ID: 39773936
I should have also said that if you succeeded in your objective, no one could delete the file. Hence my suggestion above.

.... Thinkpads_User
Cyber Threats to Small Businesses (Part 2)

The evolving cybersecurity landscape presents SMBs with a host of new threats to their clients, their data, and their bottom line. In part 2 of this blog series, learn three quick processes Webroot’s CISO, Gary Hayslip, recommends to help small businesses beat modern threats.


Author Comment

ID: 39774158
Thanks for responding. See, I thought that when someone finds a php vulnerability, then if there is a security flaw in the php script, then the person will manage to execute a script purely because the server sees them as the rightful owner of those files and hence it will just permit that execution to take place. So the hacker isn't hacking onto our servers directly, but using the php vulnerabilities to execute a file.

But then if I make the administrator the owner with a password, let's say that a genius mastermind finds a way through the form fields on our site and finds a vulnerability, and it finds a way to use the 'Fopen' function and open a php file and save to it. If the admin account has a password, are you saying the mastermind won't be able to execute anything as they would get prompted? As last time, the owner was the EC2-user on Amazon's servers which you can only log on with if you have a private key which the hacker wouldn't have. So that's why I'm puzzled by the creation of a password, when a private key would possibly be more secure?

Hence why I thought if I could have the Owner as Ec2-user, but only give it read access. Then create a new user with full write access. So if there was a 'hack', then the server would see the execution coming from the server side owner (ec2-user), but as it only has read access would prevent it from executing anything? Does any of what I said make sense?
LVL 98

Expert Comment

by:John Hurst
ID: 39774167
I use Linux less than Windows, but if anyone or anything tries to access a folder where the owner has a difficult password, I have not seen them succeed, except if the entire machine was hacked. At the folder level, the password should be required and if the owner is different than the user then a script probably would not be able to figure it out.

... Thinkpads_User

Accepted Solution

ExpertNotReally earned 1200 total points
ID: 39775086
Yes, the owner can have read and execute writes over a file/folder and yes another user could have full rights over said file/folder.  The user who you would want to have full access would need to be part of a group that would then have the access. Which would look something like the following.

Create new group
groupadd groupname

Open in new window

Add existing user to the group
usermod -a -G groupname username

Open in new window

Change File/Folder Ownership
chown OwnerUsername:GroupJustCreated /path/to/file

Open in new window

Change Permissions
chmod 570 /path/to/file

Open in new window

Now before you think about doing this, if you do not have root access over the server or have yet to add anyone to the group you will lose access to the file/folder.  Another thing to consider is to check if the web server has ownership of the files/folders in question.  I know there are cases where changes must be made to the files/folders from within a web browser which usually requires the web server to have write permissions in order to save the changes.  If this is not the case simply verifying the server does not have write access should negate your issue.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Considering cloud tradeoffs and determining the right mix for your organization.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question