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

    缓解方案:
    解决此漏洞的办法有两个第一是升级sodo,第二禁用。
    sudo官方已修复了该漏洞,建议用户在做好数据备份的情况下通过以下链接尽快升级更高版本:
    https://www.sudo.ws/download.html
    对于无法立即更新的客户,建议使用 systemtap 进行以下的临时缓解措施:

    1. 安装所需的 systemtap 软件包和依赖项,例如:
    1. yum install systemtap yum-utils kernel-devel-"$(uname -r)"

    对于 RHEL 7,使用以下命令安装 kernel debuginfo:

    1. debuginfo-install -y kernel-"$(uname -r)"

    对于 RHEL 8,使用以下命令安装 sudo debuginfo:

    1. debuginfo-install sudo

    2.创建以下systemtap 脚本:(将文件命为sudoedit-block.stap)

    1. probe process("/usr/bin/sudo").function("main") {
    2. command = cmdline_args(0,0,"");
    3. if (strpos(command, "edit") >= 0) {
    4. raise(9);
    5. }
    6. }

    3.使用以下命令安装脚本:(使用 root)

    1. nohup stap -g sudoedit-block.stap &

    (这将输出 systemtap 脚本的 PID 号)

    该脚本将使存在安全漏洞的 sudoedit 命令停止工作。sudo 命令仍将正常工作。上述更改在重启后将会丢失,因此必须在每次重启后重新进行更改。

    4.在安装了新的已修复了相关漏洞的 sudo 软件包后,终止(kill)systemtap 进程来删除 systemtap 脚本。 例如:

    1. 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

    升级:

    1. [root@test-dacs-ap02 tmp]# sh cve-2021-3156--2021-01-26-1453.sh
    2. This script (v1.0) is primarily designed to detect CVE-2021-3156 on supported
    3. Red Hat Enterprise Linux systems and kernel packages.
    4. Result may be inaccurate for other RPM based systems.
    5. Detected 'sudo' package: sudo-1.8.19p2-10.el7.x86_64
    6. This sudo version is vulnerable.
    7. Follow https://access.redhat.com/security/vulnerabilities/RHSB-2021-002 for advice.
    8. [root@test-dacs-ap02 tmp]#
    9. [root@test-dacs-ap02 tmp]# yum install sudo-1.9.5-3.el7.x86_64.rpm
    10. Loaded plugins: product-id, search-disabled-repos, subscription-manager
    11. This system is not registered with an entitlement server. You can use subscription-manager to register.
    12. Examining sudo-1.9.5-3.el7.x86_64.rpm: sudo-1.9.5-3.el7.x86_64
    13. Marking sudo-1.9.5-3.el7.x86_64.rpm as an update to sudo-1.8.19p2-10.el7.x86_64
    14. Resolving Dependencies
    15. --> Running transaction check
    16. ---> Package sudo.x86_64 0:1.8.19p2-10.el7 will be updated
    17. ---> Package sudo.x86_64 0:1.9.5-3.el7 will be an update
    18. --> Finished Dependency Resolution
    19. Dependencies Resolved
    20. ===============================================================================================================================
    21. Package Arch Version Repository Size
    22. ===============================================================================================================================
    23. Updating:
    24. sudo x86_64 1.9.5-3.el7 /sudo-1.9.5-3.el7.x86_64 9.1 M
    25. Transaction Summary
    26. ===============================================================================================================================
    27. Upgrade 1 Package
    28. Total size: 9.1 M
    29. Is this ok [y/d/N]: y
    30. Downloading packages:
    31. Running transaction check
    32. Running transaction test
    33. Transaction test succeeded
    34. Running transaction
    35. Warning: RPMDB altered outside of yum.
    36. Updating : sudo-1.9.5-3.el7.x86_64 1/2
    37. Cleanup : sudo-1.8.19p2-10.el7.x86_64 2/2
    38. epel | 4.7 kB 00:00:00
    39. update | 2.9 kB 00:00:00
    40. yum-server | 4.1 kB 00:00:00
    41. Verifying : sudo-1.9.5-3.el7.x86_64 1/2
    42. Verifying : sudo-1.8.19p2-10.el7.x86_64 2/2
    43. Updated:
    44. sudo.x86_64 0:1.9.5-3.el7
    45. Complete!
    46. [root@test-dacs-ap02 tmp]# sh cve-2021-3156--2021-01-26-1453.sh
    47. This script (v1.0) is primarily designed to detect CVE-2021-3156 on supported
    48. Red Hat Enterprise Linux systems and kernel packages.
    49. Result may be inaccurate for other RPM based systems.
    50. Detected 'sudo' package: sudo-1.9.5-3.el7.x86_64
    51. This sudo version is not vulnerable.
    52. [root@test-dacs-ap02 tmp]#
    53. [root@test-dacs-ap02 tmp]# ps -ef |grep 7590
    54. root 73288 73082 0 08:39 pts/0 00:00:00 grep --color=auto 7590
    55. [root@test-dacs-ap02 tmp]#
    56. [root@test-dacs-ap02 tmp]# kill -s SIGTERM 7590
    57. -bash: kill: (7590) - No such process
    58. [root@test-dacs-ap02 tmp]#