关注WX:【小白SEC】查看更多内容……


CVE-2021-4034:Linux Polkit 权限提升漏洞复现及修复

本文仅为验证漏洞,在本地环境测试验证,无其它目的


CVE 编号:

CVE-2021-4034


漏洞说明:

近期,国外安全研究团队在 polkit 的 pkexec 中发现存在的本地权限提升漏洞(CVE-2021-4034)

关于 Polkit pkexec for Linux

Polkit(以前称为 PolicyKit)是一个用于在类 Unix 操作系统中控制系统范围权限的组件。它为非特权进程与特权进程通信提供了一种有组织的方式。也可以使用 polkit 执行具有提升权限的命令,使用命令 pkexec 后跟要执行的命令(具有 root 权限)。


漏洞影响范围:

(参考:深信服千里目安全实验室)

  • Debain stretch policykit-1 < 0.105-18+deb9u2
  • Debain buster policykit-1 < 0.105-25+deb10u1
  • Debain bookworm, bullseye policykit-1 < 0.105-31.1
  • Ubuntu 21.10 (Impish Indri) policykit-1 < 0.105-31ubuntu0.1
  • Ubuntu 21.04 (Hirsute Hippo) policykit-1 Ignored (reached end-of-life)
  • Ubuntu 20.04 LTS (Focal Fossa) policykit-1 < 0.105-26ubuntu1.2)
  • Ubuntu 18.04 LTS (Bionic Beaver) policykit-1 <0.105-20ubuntu0.18.04.6)
  • Ubuntu 16.04 ESM (Xenial Xerus) policykit-1 <0.105-14.1ubuntu0.5+esm1)
  • Ubuntu 14.04 ESM (Trusty Tahr) policykit-1 <0.105-4ubuntu3.14.04.6+esm1)
  • CentOS 6 polkit < polkit-0.96-11.el6_10.2
  • CentOS 7 polkit < polkit-0.112-26.el7_9.1
  • CentOS 8.0 polkit < polkit-0.115-13.el8_5.1
  • CentOS 8.2 polkit < polkit-0.115-11.el8_2.2
  • CentOS 8.4 polkit < polkit-0.115-11.el8_4.2

漏洞类型:

本地提权


利用条件:

1、攻击者需要一个本地用户权限
2、恶意文件需要可执行


漏洞复现

方法一:

  1. 查看当前Centos为【CentOS Linux release 7.9.2009 (Core)】、当前用户为【test】(非root用户):在这里插入图片描述

  2. 上传测试文件到当前目录下,当前无执行权限,需要加执行权在这里插入图片描述

  3. 使用此文件需要经过gcc编译,如没有gcc自行下载,此测试文件来自:https://github.com/arthepsy/CVE-2021-4034

  4. 输入:gcc cve-2021-4034-poc.c -o exp

  5. 得到exp文件:./exp 即可执行,验证id,得到当前权限为root在这里插入图片描述
    方法二:

  6. 查看当前Centos为【CentOS Linux release 7.9.2009 (Core)】、当前用户为【test】(非root用户):在这里插入图片描述

  7. 上传整个测试目录到当前目录下,当前目录下文件无执行权限,需要加执行权,此测试文件来自:https://github.com/berdav/CVE-2021-4034在这里插入图片描述

  8. 输入make,得到【cve-2021-4034】文件,./cve-2021-4034执行,验证id,当前权限为root
    在这里插入图片描述


漏洞修复

1、系统检测(参考:深信服千里目安全实验室)

CentOS 用户可采用如下命令升级到安全版本或更高版本:

yum clean all && yum makecache
yum update polkit -y

验证修复,通过以下命令可查看 Polkit 是否为安全版本:

rpm -qa polkit

Ubuntu 用户可采用如下命令升级至安全版本或更高版本:

sudo apt-get update
sudo apt-get install policykit-1

验证修复,通过以下命令可查看 Polkit 是否为安全版本:

dpkg -l policykit-1

2、官方修复建议
Ubuntu:https://ubuntu.com/security/CVE-2021-4034

Redhat:https://access.redhat.com/security/cve/CVE-2021-4034

Debian:https://security-tracker.debian.org/tracker/CVE-2021-4034

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐