Researcher Discloses Methods For Bypassing All OS X Security Protections
Trailrunner7 writes: For years, Apple has enjoyed a pretty good reputation among users for the security of its products. That halo has been enhanced by the addition of new security features such as Gatekeeper and XProtect to OS X recently, but one researcher said that all of those protections are simple to bypass and gaining persistence on a Mac as an attacker isn't much of a challenge at all. Gatekeeper is one of the key technologies that Apple uses to prevent malware from running on OS X machines. It gives users the ability to restrict which applications can run on their machines by choosing to only allow apps from the Mac App Store. With that setting in play, only signed, legitimate apps should be able to run on the machine. But Patrick Wardle, director of research at Synack, said that getting around that restriction is trivial. "Gatekeeper doesn't verify an extra content in the apps. So if I can find an Apple-approved app and get it to load external content, when the user runs it, it will bypass Gatekeeper," Wardle said in a talk at the RSA Conference here Thursday. "It only verifies the app bundle. If Macs were totally secure, I wouldn't be here talking," Wardle said. "It's trivial for any attacker to bypass the security tools on Macs."
And using the same logic I can get root on any Unix box.
1) Find an application that has root
2) Get it to load external content
3) The new content bypasses all the protections on the box.
Gatekeeper prevents downloaded applications that are untrusted from accidentally being run. It doesn't prevent trusted applications from doing anything.
The clueless meter went off the charts for me at "by the addition of new security features such as Gatekeeper and XProtect to OS X recently" -- XProtect has been around since mid-10.6, and Gatekeeper is just a wrapper around XProtect.
The actual Synack presentation is better (I saw the precursor at CSW): "Gatekeeper doesn't verify an extra content in the apps. So if I can find an Apple-approved app and get it to load external content, when the user runs it, it will bypass Gatekeeper," is the real security flaw here. CSW had a good presentation on how to do this leveraging dylibs. With a simple exploit dropping a crafted dylib, you can run any code you can force the user to download via drive-by as root. And it's persistent, without adding a bunch of extra junk to the target system.
That said, this method still relies on working exploits (or more often, patched torrents of popular software). The skill level to pull off the entire attack chain is fairly high too -- you're going to see governments and organized crime using these techniques, not your average bot herder.
Aloha - hopefully this provides some more context and technical insight into my 'claims.' I'm honestly not trying to overhype everything and feel I have a decent understanding how computers/malware/exploits work -thanks to my time at the NSA ;). My goal is simply to show that Apple's built-in security mechanisms are trivial to bypass by malware/local attackers.
1) So yes, Gatekeeper is designed to only allow downloaded code to execute if its signed, or from the Mac App Store. This prevents a lot of attacks, such as user's infecting themselves with trojans, or downloads that have been modified in transit (e.g. by a remote attacker w/ some network level access). The technique I described (full technical details here: https://www.virusbtn.com/pdf/magazine/2015/vb201503-dylib-hijacking.pdf), allows anybody to inject unsigned code into internet downloads. Then, even if the user has set Gatekeeper to only allow code from the Mac App Store, the unsigned code is allowed to run. Since most (e.g. all OS X AV security products and about 2/3 of the apps in my dock) OS X software is distributed via HTTP and/or user's are dumb and download all sorts of shady code - IMHO, this bypass is a problem. Yes, I understand the user still has to run the code - my point is that we can completely bypass Gatekeeper.
2) In OS X, kernel extensions must be signed. The techniques I described are known (see: https://reverse.put.as/2013/11/23/breaking-os-x-signed-kernel-extensions-with-a-nop/), but allow any unsigned kernel extension to be loaded, even on Yosemite.
3) I also showed the Apple blotched the rootpipe patch, meaning any local user can priv-esc to get r00t, even on fully patched OS X 10.10.3 or 10.10.4 beta (video of poc: https://vimeo.com/125345793).
4) XProtect (Apple's built in AV product) is signature-based, thus can be trivial bypassed. Yes this is obvious.
Its done every year at Pwn2Own.
Not sure how to 'demo' this to you guys - but this is exactly how to do it: .dmg or .zip file that contains Instruments.app as well as the external folders/frameworks with the dylibs that app tries to load - these can be unsigned/malicious :) :/
1) Find a Apple-signed or Mac App store binary the contains an *external relative reference* to a dylib. Apple's Instruments.app works great
2) Create a
3) Hide the files/folders, and create a top-level icon/alias to Instruments.app. This icon can be anything (e.g. 'Flash Installer'). This makes the download look believable
4) Get users to download this ('free photoshop!' - see OSX/iWorm for an example of Mac user's being dumb) *or* inject this into internet downloads if you have network-level presence. Tons of OS X software is distributed over HTTP
5) Even if the user has Gatekeeper set to 'only allow code from the Mac App Store' when the user runs the download the unsigned dylibs will be loaded and execute. In other words, Gatekeeper fails to do what it was designed to do - prevent MiTM attacks/user's from running unsigned code.
more technical details here [PDF]: https://www.virusbtn.com/pdf/magazine/2015/vb201503-dylib-hijacking.pdf
4) Get users to download this ('free photoshop!' - see OSX/iWorm for an example of Mac user's being dumb) *or* inject this into internet downloads if you have network-level presence. Tons of OS X software is distributed over HTTP :/
so, again, like every other OS X exploit, this depends solely on Social Networking to propagate.
So, IOW, after about 100 or so Macs worldwide get infected, whatever package was responsible for spreading malware via this method would be added to Apple's malware list, be pushed out automatically to all users of OS X, and, like those infrequent times before, that would be that...
Then, Apple simply adds checking of DyLibs and other add-ons to OS X, and closes this hokey forever. Problem solved!
So, thanks to the black hat who brought this exploit to Apple's attention; so that they can take care of it.