Nano Permissions – How Nano Reads Write-Only Access Files

permissionsrhelsetuid

User has write-only permissions on a file, unable to cat or vi but is able to nano normally. How is this possible?

I was wondering what happens if you only have write-access on a file and this was how I tested it.

# cd /home/tester
# cat hello.txt
Hello World!
# ls -l hello.txt
-rw------- 1 root root 13 Nov 17 01:55 hello.txt
# chmod o+w hello.txt
# ls -l hello.txt
-rw-----w- 1 root root 13 Nov 17 01:55 hello.txt
# su tester
$ cd ~
$ cat hello.txt
cat: hello.txt: Permission denied
$ nano hello.txt

For some reason, nano is able to read the file (see screenshot). I've confirmed vi is not. My original hypothesis is that having write only permission allows you to only append the file like echo "Hello" > hello.txt.

(See this screenshot for the actual commands I ran.)

Update

ls -l "$(type -p nano)" shows permissions -rwsr-xr-x root root.

Best Answer

-rwsr-xr-x root root in the result of ls -l "$(type -p nano)" means it is setuid. As a result, whoever runs nano has root privileges. This is not expected and shouldn't be happening in any normal environment. Find out with your administrator what the point is.

Related Question