漏洞可能影响到RHEL系统版本有:


缓解方案:
解决此漏洞的办法有两个第一是升级sodo,第二禁用。
sudo官方已修复了该漏洞,建议用户在做好数据备份的情况下通过以下链接尽快升级更高版本:
https://www.sudo.ws/download.html
对于无法立即更新的客户,建议使用 systemtap 进行以下的临时缓解措施:
- 安装所需的 systemtap 软件包和依赖项,例如:
yum install systemtap yum-utils kernel-devel-"$(uname -r)"
对于 RHEL 7,使用以下命令安装 kernel debuginfo:
debuginfo-install -y kernel-"$(uname -r)"
对于 RHEL 8,使用以下命令安装 sudo debuginfo:
debuginfo-install sudo
2.创建以下systemtap 脚本:(将文件命为sudoedit-block.stap)
probe process("/usr/bin/sudo").function("main") {command = cmdline_args(0,0,"");if (strpos(command, "edit") >= 0) {raise(9);}}
3.使用以下命令安装脚本:(使用 root)
nohup stap -g sudoedit-block.stap &
(这将输出 systemtap 脚本的 PID 号)
该脚本将使存在安全漏洞的 sudoedit 命令停止工作。sudo 命令仍将正常工作。上述更改在重启后将会丢失,因此必须在每次重启后重新进行更改。
4.在安装了新的已修复了相关漏洞的 sudo 软件包后,终止(kill)systemtap 进程来删除 systemtap 脚本。 例如:
kill -s SIGTERM 7590
(其中 7590 是 systemtap 进程的 PID)
警告:请勿尝试通过删除符号链接来禁用 sudoedit。这不并足以使缓解措施生效。Qualys在官方博客(https://blog.qualys.com/vulnerabilities-research/2021/01/26/cve-2021-3156-heap-based-buffer-overflow-in-sudo-baron-samedit)提供了漏洞的更多细节和概念证明视频。
考虑到该漏洞的攻击面很广,Qualys建议所有用户立即为此漏洞应用补丁,以下版本的sudo容易受到攻击:
- 从1.8.2到1.8.31p2的所有旧版(1.8.2之前的版本是安全的);
- 从1.9.0到1.9.5p1的所有稳定版本。
用户可以通过https://github.com/gh-Devin/sudo-cve-2021脚本来检测sudo版本是否有漏洞,用户也可以通过以下方法测试系统是否易受攻击。
以非root用户身份登录系统,运行命令“sudoedit-s/”。如果系统容易受到攻击,它将返回以“sudoedit”开头的错误提示。如果系统已打补丁,它将返回以“usage”开头的错误提示。
cve-2021-3156—2021-01-26-1453.sh
升级:
[root@test-dacs-ap02 tmp]# sh cve-2021-3156--2021-01-26-1453.shThis script (v1.0) is primarily designed to detect CVE-2021-3156 on supportedRed Hat Enterprise Linux systems and kernel packages.Result may be inaccurate for other RPM based systems.Detected 'sudo' package: sudo-1.8.19p2-10.el7.x86_64This sudo version is vulnerable.Follow https://access.redhat.com/security/vulnerabilities/RHSB-2021-002 for advice.[root@test-dacs-ap02 tmp]#[root@test-dacs-ap02 tmp]# yum install sudo-1.9.5-3.el7.x86_64.rpmLoaded plugins: product-id, search-disabled-repos, subscription-managerThis system is not registered with an entitlement server. You can use subscription-manager to register.Examining sudo-1.9.5-3.el7.x86_64.rpm: sudo-1.9.5-3.el7.x86_64Marking sudo-1.9.5-3.el7.x86_64.rpm as an update to sudo-1.8.19p2-10.el7.x86_64Resolving Dependencies--> Running transaction check---> Package sudo.x86_64 0:1.8.19p2-10.el7 will be updated---> Package sudo.x86_64 0:1.9.5-3.el7 will be an update--> Finished Dependency ResolutionDependencies Resolved===============================================================================================================================Package Arch Version Repository Size===============================================================================================================================Updating:sudo x86_64 1.9.5-3.el7 /sudo-1.9.5-3.el7.x86_64 9.1 MTransaction Summary===============================================================================================================================Upgrade 1 PackageTotal size: 9.1 MIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transactionWarning: RPMDB altered outside of yum.Updating : sudo-1.9.5-3.el7.x86_64 1/2Cleanup : sudo-1.8.19p2-10.el7.x86_64 2/2epel | 4.7 kB 00:00:00update | 2.9 kB 00:00:00yum-server | 4.1 kB 00:00:00Verifying : sudo-1.9.5-3.el7.x86_64 1/2Verifying : sudo-1.8.19p2-10.el7.x86_64 2/2Updated:sudo.x86_64 0:1.9.5-3.el7Complete![root@test-dacs-ap02 tmp]# sh cve-2021-3156--2021-01-26-1453.shThis script (v1.0) is primarily designed to detect CVE-2021-3156 on supportedRed Hat Enterprise Linux systems and kernel packages.Result may be inaccurate for other RPM based systems.Detected 'sudo' package: sudo-1.9.5-3.el7.x86_64This sudo version is not vulnerable.[root@test-dacs-ap02 tmp]#[root@test-dacs-ap02 tmp]# ps -ef |grep 7590root 73288 73082 0 08:39 pts/0 00:00:00 grep --color=auto 7590[root@test-dacs-ap02 tmp]#[root@test-dacs-ap02 tmp]# kill -s SIGTERM 7590-bash: kill: (7590) - No such process[root@test-dacs-ap02 tmp]#
