跳到正文

Sudo 堆缓冲区溢出致本地提权漏洞

高危 未验证 漏洞情报EXP 公开

漏洞描述

Sudo是一个功能强大的实用程序,大多数基于Unix和Linux的操作系统都包含Sudo。它允许用户使用其他用户的安全特权运行程序。2021年1月27日,阿里云应急响应中心监控到国外安全研究人员披露了Sudo 堆缓冲区溢出致本地提权漏洞,漏洞编号为 CVE-2021-3156。任何本地用户(包括普通用户和系统用户,sudoer和非sudoers)若成功利用该漏洞,可在无需密码的情况下获得root权限。

解决建议

1. 下载升级sudo软件包,下载链接为: https://www.sudo.ws/dist/

2. 使用 systemtap 执行以下命令进行临时缓解:

首先,安装所需的 systemtap 软件包和依赖项:


systemtap yum-utils kernel-devel-"$(uname -r)"

然后,对于RHEL 7,使用命令安装 kernel debuginfo:debuginfo-install -y kernel-"$(uname -r)"。

对于RHEL 8,使用命令安装 sudo debuginfo:debuginfo-install sudo。

接着,创建以下 systemtap 脚本,并将文件命名为 sudoedit-block.stap:


probe process("/usr/bin/sudo").function("main") {
command = cmdline_args(0,0,"");
if (strpos(command, "edit") >= 0) {
raise(9);
}
}
最终,使用root权限以下命令安装脚本:


# nohup stap -g sudoedit-block.stap &
该脚本将使得易受攻击的sudoedit二进制文件停止工作。 sudo命令仍将照常工作。上述更改在重启后失效,必须在每次重启后重新应用。

一旦安装了补丁程序,就可以通过取消systemtap进程来删除systemtap脚本。 例如,通过使用:


# kill -s SIGTERM 7590 (其中7590是systemtap进程的PID)

参考链接

http://packetstormsecurity.com/files/161160/Sudo-Heap-Based-Buffer-Overflow.html
http://packetstormsecurity.com/files/161230/Sudo-Buffer-Overflow-Privilege-Escalation.html
http://packetstormsecurity.com/files/161270/Sudo-1.9.5p1-Buffer-Overflow-Privilege-Escalation.html
http://packetstormsecurity.com/files/161293/Sudo-1.8.31p2-1.9.5p1-Buffer-Overflow.html
http://seclists.org/fulldisclosure/2021/Feb/42
http://seclists.org/fulldisclosure/2021/Jan/79
http://www.openwall.com/lists/oss-security/2021/01/26/3
http://www.openwall.com/lists/oss-security/2021/01/27/1
http://www.openwall.com/lists/oss-security/2021/01/27/2
http://www.openwall.com/lists/oss-security/2021/02/15/1
http://www.openwall.com/lists/oss-security/2021/09/14/2
https://kc.mcafee.com/corporate/index?page=content&id=SB10348
https://lists.debian.org/debian-lts-announce/2021/01/msg00022.html
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CALA5FTXIQBRRYUA2ZQNJXB6OQMAXEII/
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LHXK6ICO5AYLGFK2TAX5MZKUXTUKWOJY/
https://security.gentoo.org/glsa/202101-33
https://security.netapp.com/advisory/ntap-20210128-0001/
https://security.netapp.com/advisory/ntap-20210128-0002/
https://support.apple.com/kb/HT212177
https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-sudo-privesc-jan2021-qnYQfcM
https://www.beyondtrust.com/blog/entry/security-advisory-privilege-management-for-unix-linux-pmul-basic-and-privilege-management-for-mac-pmm-affected-by-sudo-vulnerability
https://www.debian.org/security/2021/dsa-4839
https://www.kb.cert.org/vuls/id/794544
https://www.openwall.com/lists/oss-security/2021/01/26/3
https://www.oracle.com//security-alerts/cpujul2021.html
https://www.oracle.com/security-alerts/cpuapr2022.html
https://www.oracle.com/security-alerts/cpuoct2021.html
https://www.sudo.ws/stable.html#1.9.5p2
https://www.synology.com/security/advisory/Synology_SA_21_02