When Security Gets in the Way. PenTesting Mobile Apps That Use Certificate Pinning



Similar documents
Mobile Application Hacking for Android and iphone. 4-Day Hands-On Course. Syllabus

Penetration Testing for iphone Applications Part 1

Bypassing SSL Pinning on Android via Reverse Engineering

Mobile Application Security

ios Testing Tools David Lindner Director of Mobile and IoT Security

Best Practice Guide (SSL Implementation) for Mobile App Development 最 佳 行 事 指 引. Jointly published by. Publication version 1.

Mobile Application Hacking for ios. 3-Day Hands-On Course. Syllabus

Blackbox Android. Breaking Enterprise Class Applications and Secure Containers. Marc Blanchou Mathew Solnik 10/13/

ABSTRACT' INTRODUCTION' COMMON'SECURITY'MISTAKES'' Reverse Engineering ios Applications

Mobile Security Framework

A Java API for X.509 Proxy Certificates

An Application Package Configuration Approach to Mitigating Android SSL Vulnerabilities

Capario B2B EDI Transaction Connection. Technical Specification for B2B Clients

Pentesting ios Apps Runtime Analysis and Manipulation. Andreas Kurtz

Securing ios Applications. Dr. Bruce Sams, OPTIMAbit GmbH

CRYPTOGRAPHY 456 ANDROID SECURE FILE TRANSFER W/ SSL

Sascha Fahl, Marian Harbach, Matthew Smith. Usable Security and Privacy Lab Leibniz Universität Hannover

Pentesting iphone Applications. Satishb3

Mobile Application Security Testing ASSESSMENT & CODE REVIEW

Introduction to Mobile Access Gateway Installation

SSL Considerations for CAS: Planning, Management, and Troubleshooting. Marvin Addison Middleware Services Virginia Tech October 13, 2010

AppConnect FAQ for MobileIron Technology Partners! AppConnect Overview

Pentesting Android Apps. Sneha Rajguru

SSL implementieren aber sicher!

CS255 Programming Project 2

Owner of the content within this article is Written by Marc Grote

Security Evaluation of Mobile Applications using 'App Report Cards': Android By Raul Siles October 2015

AGENDA. Background. The Attack Surface. Case Studies. Binary Protections. Bypasses. Conclusions

Project X Mass interception of encrypted connections

Mobile Application Security and Penetration Testing Syllabus

Citrix Receiver for Mobile Devices Troubleshooting Guide

SYLLABUS MOBILE APPLICATION SECURITY AND PENETRATION TESTING. MASPT at a glance: v1.0 (28/01/2014) 10 highly practical modules

Debugging Mobile Apps

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

DEF CON 19: Getting SSLizzard. Nicholas J. Percoco Trustwave SpiderLabs Paul Kehrer Trustwave SSL

Configuration Guide BES12. Version 12.3

Enterprise Application Security Workshop Series

Pentesting Mobile Applications

Android Developer Fundamental 1

Owner of the content within this article is Written by Marc Grote

DEVELOPING CERTIFICATE-BASED PROJECTS FOR WEB SECURITY CLASSES *

ios Design Patterns Jackie Myrose CSCI 5448 Fall 2012

BlackBerry Enterprise Service 10. Version: Configuration Guide

MOBILE SECURITY. As seen by FortConsult. Lars Syberg Head of Security Services

The power of root on Android emulators

WebView addjavascriptinterface Remote Code Execution 23/09/2013

SAP Mobile - Webinar Series SAP Mobile Platform 3.0 Security Concepts and Features

Configuration Guide BES12. Version 12.2

Smartphone Security for Android Applications

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

AppUse - Android Pentest Platform Unified

Fahim Uddin 1. Java SDK

Android & ios Application Vulnerability Assessment & Penetration Testing Training. 2-Day hands on workshop on VAPT of Android & ios Applications

the cross platform mobile apps dream Click to edit Master title style Click to edit Master text styles Third level Fourth level» Fifth level

Advanced Testing and Continuous Integration

Usage of Evaluate Client Certificate with SSL support in Mediator and CentraSite

Configuration Guide BES12. Version 12.1

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

IUCLID 5 Guidance and Support

User-ID Configuration

Now SMS/MMS Android Modem Quick Start Guide

Configuring Secure Socket Layer (SSL) for use with BPM 7.5.x

SSL and Browsers: The Pillars of Broken Security

TACKYDROID. Pentesting Android Applications in Style

Why Eve and Mallory Love Android An Analysis of Android SSL (In)Security

Mobile Payment Security

DreamFactory & Modus Create Case Study

Title: Appium Automation for Mac OS X. Created By: Prithivirajan M. Abstract. Introduction

Remote Desktop Gateway. Accessing a Campus Managed Device (Windows Only) from home.

Running a Program on an AVD

Mobilitics Inria-CNIL project: privacy and smartphones

Running Android Applications on BlackBerry 10 developer.blackberry.com/android

Practical Android Projects Lucas Jordan Pieter Greyling

Attacking SMS. BlackHat USA RingZero

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

Introduction to the Secure Gateway (SEG)

-Android 2.3 is the most used version of Android on the market today with almost 60% of all Android devices running 2.3 Gingerbread -Winner of

Administering Jive Mobile Apps

This is DEEPerent: Tracking App behaviors with (Nothing changed) phone for Evasive android malware

Why Eve and Mallory Love Android An Analysis of Android SSL (In)Security

Security Testing Guidelines for mobile Apps

Server Software Installation Guide

Advanced ANDROID & ios Hands-on Exploitation

Accessing PostgreSQL through JDBC via a Java SSL tunnel

geniusport mobility training experts

Using EMC Unisphere in a Web Browsing Environment: Browser and Security Settings to Improve the Experience

Apache Tomcat & Reverse Proxies

What s Cool in the SAP JVM (CON3243)

Security Guide. BlackBerry Enterprise Service 12. for ios, Android, and Windows Phone. Version 12.0

Introduction to Oracle Mobile Application Framework Raghu Srinivasan, Director Development Mobile and Cloud Development Tools Oracle

Defeat SSL Certificate Validation for Google Android Applications

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

CompTIA Mobile App Security+ Certification Exam (Android Edition) Live exam ADR-001 Beta Exam AD1-001

BlackBerry Enterprise Service 10. Universal Device Service Version: Administration Guide

Lab 4 In class Hands-on Android Debugging Tutorial

Transcription:

When Security Gets in the Way PenTesting Mobile Apps That Use Certificate Pinning Justine Osborne Alban Diquet

Outline What is Certificate Pinning? Definition and Background Consequences for Mobile Blackbox Testing ios Certificate Pinning Within an ios App Intercepting the App's Traffic: MobileSubstrate Extension Android Certificate Pinning Within an Android App Intercepting the App's Traffic: Custom JDWP Debugger Conclusion

Outline What is Certificate Pinning? Definition and Background Consequences for Mobile Blackbox Testing ios Certificate Pinning Within an ios App Intercepting the App's Traffic: MobileSubstrate Extension Android Certificate Pinning Within an ios App Intercepting the App's Traffic: Custom JDWP Debugger Conclusion

Certificate Pinning Hard- code in the client the certificate known to be used by the server Pin the server's certificate itself Takes the CA system out of the equation Pin the CA certificate used to sign the server's certificate Limit trust to certificates signed by one CA or a small set of CAs Significantly reduces the threat of a rogue CA and of CA compromise Implemented in Chrome 13 for Google services

Certificate Pinning in Mobile Apps Mobile is the ideal platform to implement certificate pinning A mobile App only needs to connect to a small set of servers The App's developers write the client- side code A small list of trusted CA certificates can be included in the App itself The device's trust store is completely ignored Certificate pinning is already being deployed Chrome for Android, Twitter, Cards.io

Mobile Blackbox Testing Some of the tester s tasks: Reversing the binary Analyzing the App's behavior at runtime (File I/O, IPC, etc...) Intercepting the App's network traffic using a proxy The tester's proxy has to masquerade as the server Requires adding the proxy's CA certificate to the device trust store This will not work if the App does certificate pinning

What This Presentation is About No simple solutions to defeat certificate pinning: Decompile the App's package/binary Change the certificate(s)? Patch SSL validation methods? Re- package and side- load the new binary Blackbox assessments are usually short projects Introducing new tools to make this easy: ios SSL Kill Switch Android SSL Bypass

Outline What is Certificate Pinning? Definition and Background Consequences for Mobile Blackbox Testing ios Certificate Pinning Within an ios App Intercepting the App's Traffic: MobileSubstrate Extension Android Certificate Pinning Within an ios App Intercepting the App's Traffic: Custom JDWP Debugger Conclusion

Network Communication on ios Several APIs to do network communication on ios NSStream, CFStream, NSURLConnection Most ios Apps use NSURLConnection High level API to perform the loading of a URL request Verifies the server's certificate for https: URLs Developers can override certificate validation To disable certificate validation (for testing only!) To implement certificate pinning

NSURLConnection NSURLConnection has the following constructor: - (id)initwithrequest:(nsurlrequest *)request delegate:(id <NSURLConnectionDelegate>)delegate The delegate has to implement specific methods Those methods get called as the connection is progressing They define what happens during specific events Connection succeeded, connection failed, etc... Two documented ways to do custom certificate validation

NSURLConnectionDelegate

Custom Certificate Validation

Custom Certificate Validation

Jailbroken ios Development MobileSubstrate Available on jailbroken devices de facto framework that allows 3rd- party developers to provide run- time patches to system functions MobileSubstrate patches are called extensions or tweaks

MobileSubstrate Extension One example: WinterBoard Hooks into the SpringBoard APIs Allows users to customize their home screen

ios SSL Kill Switch MobileSubstrate extension that patches NSURLConnection at runtime Automatically loaded with every App on the device Hooks into the constructor for NSURLConnection: - (id)initwithrequest:(nsurlrequest *)request delegate:(id <NSURLConnectionDelegate>)delegate Replaces the delegate with a delegate proxy The delegate proxy forwards method calls to the original delegate Except calls to any method that performs custom certificate validation

ios SSL Kill Switch Hooking NSURLConnection s constructor #import "HookedNSURLConnectionDelegate.h" %hook NSURLConnection // Hook into NSURLConnection's constructor - (id)initwithrequest:(nsurlrequest *)request delegate:(id <NSURLConnectionDelegate>)delegate { // Create a delegate "proxy" HookedNSURLConnectionDelegate* delegateproxy; delegateproxy = [[HookedNSURLConnectionDelegate alloc] initwithoriginal: delegate]; } return %orig(request, delegateproxy); // Call the "original" constructor %end

ios SSL Kill Switch Forwarding method calls to the original delegate @implementation HookedNSURLConnectionDelegate : NSObject... - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { // Forward the call to the original delegate return [origidelegate connection:connection didreceiveresponse:response]; }

ios SSL Kill Switch Intercepting calls to certificate validation methods @implementation HookedNSURLConnectionDelegate : NSObject... - (void)connection:(nsurlconnection *)connection willsendrequestforauthenticationchallenge:(nsurlauthenticationchallenge *)challenge { // Do not forward... Accept all certificates instead if([challenge.protectionspace.authenticationmethod isequaltostring:nsurlauthenticationmethodservertrust]) } { } NSURLCredential* servercred; servercred = [NSURLCredential credentialfortrust:challenge.protectionspace.servertrust]; [challenge.sender usecredential:servercred forauthenticationchallenge:challenge];

ios SSL Kill Switch DEMO

Outline What is Certificate Pinning? Definition and Background Consequences for Mobile Blackbox Testing ios Certificate Pinning Within an ios App Intercepting the App's Traffic: MobileSubstrate Extension Android Certificate Pinning Within an ios App Intercepting the App's Traffic: Custom JDWP Debugger Conclusion

Certificate Validation on Android Certificate Validation and Pinning on Android Device trust store cannot be modified by user until Android 4.0 (ICS) Certificate pinning can be implemented using an App specific trust store Common methods of certificate pinning outlined on Moxie s blog http://blog.thoughtcrime.org/authenticity- is- broken- in- ssl- but- your- app- ha

Certificate Pinning on Android Sample implementation private InputStream makerequest ( Context context, URL url ) { // Load custom Trust Store from a file AssetManager assetmanager = context.getassets(); InputStream keystoreinputstream = assetmanager.open("yourapp.store"); KeyStore truststore = KeyStore.getInstance("BKS"); truststore.load(keystoreinputstream, "somepass".tochararray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509"); tmf.init(truststore); // Init an sslcontext with the custom Trust Store SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, tmf.gettrustmanagers(), null); // Use this sslcontext for subsequent HTTPS connections HttpsURLConnection urlconnection = (HttpsURLConnection)url.openConnection(); urlconnection.setsslsocketfactory(sslcontext.getsocketfactory()); } return urlconnection.getinputstream();

Bypassing Certificate Pinning Many possible ways to implement a bypass Decompile/Patch/Recompile/Resign/Sideload Custom VM/ROM with hooks built in Native code hooking (Mulliner) or native code debugger (gdb, vtrace) JDWP debugger

Bypassing Certificate Pinning Many possible ways to implement a bypass Decompile/Patch/Recompile/Resign/Sideload Custom VM/ROM with hooks built in Native code hooking (Mulliner) or native code debugger (gdb, vtrace) JDWP debugger

Java Debug Wire Protocol What is the Java Debug Wire Protocol (JDWP)? Standard Java debugging tools Programmatic debugging through Java APIs Java Debug Interface (JDI) Python bindings available through AndBug

Java Debug Wire Protocol What can we do with a JDWP debugger? Normal debugging tasks: set breakpoints, step, etc. Once suspended via a JDI event we can: Get the current thread, frame, frame object, local variables and arguments references Load arbitrary classes, instantiate Objects, invoke methods, get and set local variables and arguments values And more

JDWP - Certificate Pinning Bypass Many possible bypass implementations using JDWP debugger Three ideas explored: 1. Custom ClassLoader which loads modified system classes 2. Use DexMaker to generate proxy classes and replace instances with proxy class instances 3. Breakpoint on set of SSLSocketFactory and replace it with another SSLSocketFactory configured with an all- trusting TrustManager

JDWP - Certificate Pinning Bypass I Method 1: Custom ClassLoader to load hooked system classes Break on anything Set APK ClassLoader to a custom ClassLoader Custom ClassLoader.loadClass() modifies HttpsURLConnection upon loading Continue execution (may need to restart Activity)

JDWP - Certificate Pinning Bypass I Problems with method 1 Might work in Java but not in Dalvik Class loading is different, defineclass() simply not supported User defined class loaders are not currently allowed to modify classes loaded from the $BOOTCLASSPATH Detailed in code comments in /dalvik/vm/oo/class.cpp

JDWP - Certificate Pinning Bypass II Method 2: Object substitution with proxied copy Break after instantiation of HttpsURLConnection Use DexMaker to dynamically generate proxy class for HttpsURLConnection Replace HttpsURLConnection object with one created using the generated proxy class Continue execution

JDWP - Certificate Pinning Bypass III Method 3: TrustManager substitution Break on HttpsURLConnection.setSocketFactory() Replace socket factory local variable with one created using an all- trusting TrustManager Continue execution

Android SSL Bypass Simple implementation for first version Using Method 3 right now Future versions will explore method 2 for further extensibility

Android SSL Bypass DEMO

Outline What is Certificate Pinning? Definition and Background Consequences for Mobile Blackbox Testing ios Certificate Pinning Within an ios App Intercepting the App's Traffic: MobileSubstrate Extension Android Certificate Pinning Within an ios App Intercepting the App's Traffic: Custom JDWP Debugger Conclusion

Summary ios SSL Kill Switch Tested on ios 4.3 and ios 5.1 https://github.com/isecpartners/ios- ssl- kill- switch Android SSL Bypass Tool Tested on Android 2.3.3 and 4.0.3 https://github.com/isecpartners/android- ssl- bypass Comments / Ideas? justine@isecpartners.com alban@isecpartners.com

The End QUESTIONS?

Reference Material Certificate pinning on ios http://blog.securemacprogramming.com/2011/12/on- ssl- pinning- for- cocoa- touch/ MobileSubstrate http://iphonedevwiki.net/index.php/mobilesubstrate Certificate pinning on Android http://blog.thoughtcrime.org/authenticity- is- broken- in- ssl- but- your- app- ha DEXMaker https://code.google.com/p/dexmaker isec Partners on GitHub https://github.com/isecpartners