Ethical Hacking Training Institute
Extreme Hacking | Sadik Shaikh | Cyber Suraksha Abhiyan

Credits: Yakov Shafranovich
SummaryAndroid devices can be crashed forcing a halt and then a soft rebootby downloading a large proxy auto config (PAC) file when adjusting theAndroid networking settings. This can also be exploited by an MITMattacker that can intercept and replace the PAC file. However, the bugis mitigated by multiple factors and the likelihood of exploitation islow.This issue has been fixed in the November 2016 Android security bulletin.Background a Proxy Auto Config (PAC) FilesProxy Auto Config (PAC) files are text files that can be used as partof the network settings configuration to allow a web browser and othersoftware that accesses the web. These files define which proxy serversshould be used for which types of requests. They usually contain aJavascript function which can be called by the web browser todetermine the type of proxy server to use. An example PAC file appearshere:function FindProxyForURL(url, host) { if (isResolvable(host)) return "DIRECT"; else return "PROXY proxy.mydomain.com:8080"; }}A related standard called Web Proxy Auto-Discovery Protocol (WPAD)allows devices to find the locations of PAC files via DHCP and/or DNS.However, WPAD is not currently supported on Android.Vulnerability DetailsWhen configuring a network in Android, one of the options available inthe aAdvanceda section is ability to indicate a Proxy Auto Config(PAC) URL which will point to a PAC file described above. The currentcode in Android does not check whether the PAC file may be too largeto load into memory, which allows an MITM attacker to replace a knownPAC file (if served without SSL) with a large one of their own andcrash the Android phone.The vulnerability is that the Java code does not check how large thedata file actually is. If a file is served that is larger than thememory available on the device, this results in all memory beingexhausted and the phone halting and then soft rebooting. The softreboot was sufficient to recover from the crash and no data was lost.While we have not been able to achieve remote code execution, thiscode path can potentially be exploited for such attacks and wouldrequire more research.The vulnerable code resides here a (PacManager.java, lines 120-127):private static String get(Uri pacUri) throws IOException { URL url = new URL(pacUri.toString()); URLConnection urlConnection = url.openConnection(java.net.Proxy.NO_PROXY); return new String(Streams.readFully(urlConnection.getInputStream()));}Specifically, the affected code is using Streams.readFully to read theentire file into memory without any kind of checks on how big the fileactually is.Because this attack require a user to configure a PAC file, and anattacker to be present and know about that file, and the file needs tobe served without SSL to make the attack work, the possibility of anattacker pulling this off is low. This is also true because Android,unlike other operating systems does not support the WPAD protocol toretrieve PAC files automatically which can be exploited using a rougeaccess point or network.Steps To Replicate (on Ubuntu 16.04)1. Install NGINX:sudo apt-get install nginx2. Use fallocate to create a large PAC file in a/var/www/html/asudo fallocate -s 2.5G test.pac3. Go in to advanced network settings on the Android device and addthe following URL as the PAC URL: http://192.168.1.x/test.pacSave the settings which will trigger the bug. Once the phone startsdownloading the files, the screen will go black and it will reboot.Mitigation StepsUsers should apply the November 2016 Android bulletin.www.extremehacking.org
Sadik Shaikh | Cyber Suraksha Abhiyan, Ethical Hacking Training Institute, CEHv9,CHFI,ECSAv9,CAST,ENSA, CCNA, CCNA SECURITY,MCITP,RHCE,CHECKPOINT, ASA FIREWALL,VMWARE,CLOUD,ANDROID,IPHONE,NETWORKING HARDWARE,TRAINING INSTITUTE IN PUNE, Certified Ethical Hacking,Center For Advanced Security Training in India, ceh v9 course in Pune-India, ceh certification in pune-India, ceh v9 training in Pune-India, Ethical Hacking Course in Pune-India
Sadik Shaikh | Cyber Suraksha Abhiyan, Ethical Hacking Training Institute, CEHv9,CHFI,ECSAv9,CAST,ENSA, CCNA, CCNA SECURITY,MCITP,RHCE,CHECKPOINT, ASA FIREWALL,VMWARE,CLOUD,ANDROID,IPHONE,NETWORKING HARDWARE,TRAINING INSTITUTE IN PUNE, Certified Ethical Hacking,Center For Advanced Security Training in India, ceh v9 course in Pune-India, ceh certification in pune-India, ceh v9 training in Pune-India, Ethical Hacking Course in Pune-India