On a Linux machine, if we allowed the user bob with home directory /home/bob to put any content (malicious or not) into the file /home/bob/dangerfile.txt

-rw-r--r-- 1 root root  61K Aug 24 13:59 dangerfile.txt

Would this pose any security risk? Assuming that bob is not a root user, it seems like the only risk would be filling up the disk space if there wasn't a quota.

Motivation: In setting up a Docker container, I noticed that if you mapped a local volume, the resulting files would root:root since they were created by the Docker daemon. Ignoring the other security shortcomings of Docker for the time, this question asks if dangerfile.txt poses any risk to the system.

  • something something symlinks? Just throwing that out there.
    – J Kimball
    Commented Aug 27, 2015 at 19:49

4 Answers 4


I think it highly unlikely this would represent any risk. Even if dangerfile.txt were executable, it would still be executed as bob and lack the ability to do root-like things.


If Bob already owns /home/bob, having a file in there owned by root and editable by him or another group does not pose any security risk in and of itself.

The risk in having files editable by bob but owned by root would lie in shell scripts, or files that are sourced/referenced by shell scripts. E.g. if a script in /root/backup.sh soruces a world-writable file in /tmp/blah.txt, then bob could edit than and insert arbitrary commands, like adding himself to the sudoers group.

There would also be a risk if the file was executable with the setuid flag (shows up in ls as + at the end of the permissions), but this isn't the case.

You may want to look into the 'setfacl' command in Linux to setup more advanced permissions than basic POSIX/UNIX ones if need be.

  • Implication that a script might trust contents of a file owned by root more? It could read and incorporate any file.
    – JDługosz
    Commented Aug 27, 2015 at 23:55
  • I agree with this one, the real danger is not in the file being editable, the real danger lies in the purpose of this file. If this file is not used, no danger. Otherwise, the exact threat would depend on the file usage (is it a script file, configuration or data file, etc.)... Commented Aug 28, 2015 at 15:18

It could hardly be worse than if he could put arbitrary content into

-rwxrwxr-x 1 bob bob 61K Aug 24 13:59 dangerfile.txt

which he probably can.


No, there is not any inherent risk here. If some kind of attack is accessing files owned by root, it could access files with any other permissions anyway.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .