Nano能够读取只写访问文件

min*_*001 8 rhel setuid permissions

用户对文件具有只写权限,无法catvi但能够nano正常。这怎么可能?

我想知道如果你只有一个文件的写访问权限会发生什么,这就是我测试它的方式。

# 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
Run Code Online (Sandbox Code Playgroud)

出于某种原因,nano能够读取文件(见截图)。我已经确认vi不是。我最初的假设是,拥有只写权限允许您只附加像echo "Hello" > hello.txt.

(有关我运行的实际命令,请参阅此屏幕截图。)

更新

ls -l "$(type -p nano)"显示权限-rwsr-xr-x root root

小智 10

-rwsr-xr-x root root结果ls -l "$(type -p nano)"是setuid。因此,无论谁运行 nano 都拥有 root 权限。这不是预期的,也不应该在任何正常环境中发生。与您的管理员一起了解重点是什么。

  • 好抓住@Tomasz。我认为这实际上是一个糟糕的安全漏洞,因为任何可以执行 `nano` 的人都可以查看和(更糟的是)编辑服务器上的任何给定文件。甚至可能以 root 身份退出。仔细阅读并*绝对*通知系统管理员。 (2认同)