为什么 su world 可执行?

为什么 su world 可执行?

我有一个由多个用户远程登录的无头服务器。其他用户都不在 sudoers 文件中,因此他们无法通过sudo.然而,由于权限su是,-rwsr-xr-x没有什么可以阻止他们尝试暴力破解 root 密码。

有人可能会说,如果用户知道 root 密码,他们无论如何都可以破坏系统,但我认为情况并非如此。 OpenSSH 配置为PermitRootLogin noPasswordAuthentication no,并且其他用户都没有对服务器的物理访问权限。据我所知,世界执行权限/usr/bin/su是用户尝试在我的服务器上获得 root 权限的唯一途径。

更令我困惑的是它似乎没有用。它允许我直接运行su而不需要做sudo su,但这并不是什么不便。

我是否忽略了什么?世界的执行许可su只是出于历史原因吗?删除该权限是否有任何我尚未遇到的缺点?

答案1

遗漏了一点伊尔卡丘的回答问题是,提升到 root 只是 的一种特定用途su。 su 的一般用途是在另一个用户的登录帐户下打开一个新的 shell。那个其他用户可以root(也许最常见的是),但su可以用来假设任何本地系统可以验证的身份。

例如,如果我以 user 身份登录jim,并且想要调查mike已报告但无法重现的问题,我可能会尝试以 user 身份登录mike,并运行给他带来麻烦的命令。

13:27:20 /home/jim> su -l mike
Password:(I type mike's password (or have him type it) and press Enter)
13:27:22 /home/mike> id
uid=1004(mike) gid=1004(mike) groups=1004(mike)
13:27:25 /home/mike> exit  # this leaves mike's login shell and returns to jim's
13:27:29 /home/jim> id
uid=1001(jim) gid=1001(jim) groups=1001(jim),0(wheel),5(operator),14(ftp),920(vboxusers)

使用-l选项su会使其模拟完整登录(每个man页面)。

然而,上述操作需要知道 的mike密码。如果我有sudo访问权限,即使没有他的密码我也可以登录mike

13:27:37 /home/jim> sudo su -l mike
Password:(I type my own password, because this is sudo asking)
13:27:41 /home/mike>

总之,可执行文件的权限su如您所示的原因是因为su通用工具系统上的所有用户都可以使用它。

答案2

从历史上看(在非 GNU unice 上),它不是,或者至少它会手动检查您是否在一个名为“wheel”的组中,并且允许su.su由于 RMS 当时关于访问控制的思想,GNU 版本没有重现此功能:

Why GNU `su' does not support the `wheel' group
===============================================

   (This section is by Richard Stallman.)

   Sometimes a few of the users try to hold total power over all the
rest.  For example, in 1984, a few users at the MIT AI lab decided to
seize power by changing the operator password on the Twenex system and
keeping it secret from everyone else.  (I was able to thwart this coup
and give power back to the users by patching the kernel, but I wouldn't
know how to do that in Unix.)

   However, occasionally the rulers do tell someone.  Under the usual
`su' mechanism, once someone learns the root password who sympathizes
with the ordinary users, he or she can tell the rest.  The "wheel
group" feature would make this impossible, and thus cement the power of
the rulers.

   I'm on the side of the masses, not that of the rulers.  If you are
used to supporting the bosses and sysadmins in whatever they do, you
might find this idea strange at first.

您可以通过谷歌搜索“wheel group rms”或类似内容找到更多有关此事的信息。

答案3

然而,由于权限su是,-rwsr-xr-x没有什么可以阻止他们尝试暴力破解 root 密码。

是的。假设您常用的 Linux 系统,该pam_unix.so模块确实会将失败的身份验证尝试延迟约两秒,但我认为没有任何东西可以阻止同时尝试。

当然会记录失败的尝试:

Aug 16 22:52:33 somehost su[17387]: FAILED su for root by ilkkachu

如果您有任何类型的系统来监控密码,那么暴力破解密码应该会显着地显示在日志中。如果您有不受信任的本地用户,也许您应该这样做。不受信任的本地用户还可能尝试使用任何仅限本地的权限提升漏洞,并且它们比远程权限提升更为常见。

更令我困惑的是它似乎没有用。

当然它很有用,root如果你知道密码,它可以让你将自己提升到 。

它允许我直接运行su而不需要做sudo su,但这并不是什么不便。

sudo su有点多余。无需使用两个旨在允许您以另一用户身份运行程序的程序,一个就足够了。如果你想运行 shell,只需使用sudo -ior sudo -s(或等)。sudo /bin/bash

我是否忽略了什么?世界对su的执行许可只是出于历史原因吗?

往上看。好吧,并不是所有系统都有sudo替代方案,我不确定您是否认为这是历史性的。

删除该权限是否有任何我尚未遇到的缺点?

不完全是,据我所知不。我思考某些系统已su设置为只有特定组(“ wheel”)的成员才能运行它。sudo如果您愿意,也可以这样做( chown root.sudousers /usr/bin/sudo && chmod 4710 /usr/bin/sudo)。

或者,如果不需要,您可以删除其中一个或两个程序。虽然在 Debian 上,sulogin软件包一起提供,所以将整个软件包删除可能不是一个好主意。 (像这样的配对loginsu在一起确实看起来有点历史性。)

答案4

su 需要是全世界可执行的,这样每个人都可以运行它。在许多系统中,它可用于通过提供密码来更改为另一个用户。

如果您担心有人暴力破解 root 密码,您可以将其禁用。 (使哈希无效,因此没有给定的密码可以匹配它)

我不知道是否达成共识,但我认为能够直接以 root 身份登录本身就是一个安全问题。

相关内容