Emulator Detection

Emulator detection refers to the techniques used to determine if a mobile app is running within an emulator.

What Is Emulator Detection?

Emulator detection refers to the techniques used to determine whether a mobile app is running within an emulator rather than on a real mobile device.

Emulators and Simulators

An emulator is different from a simulator, although they are often used interchangeably in casual conversations.

Emulator

An emulator replicates the complete hardware and software environment of a mobile device. Emulators aim to provide an accurate representation of the mobile device's behavior by mimicking the device's architecture, operating system, and software stack. They enable running and testing mobile apps on different platforms, such as running Android apps on a Windows computer.

Emulators offer a comprehensive testing environment compared to simulators, as they replicate the complete mobile device ecosystem. They allow developers to test app compatibility, performance, and behavior under different conditions. Emulators often include additional features like simulated hardware inputs, network configurations, and sensor readings.

One popular emulator is Android Emulator, which operates the Android operating system within a virtual machine referred to as an Android Virtual Device (AVD). Android Emulator allows for the emulation of Android devices (the guest systems) on various host systems such as Windows, macOS, or Linux. Android Emulator is included with Android Studio. Since Android is an open-source operating system, third-party vendors can also create Android emulators. BlueStacks, Genymotion and Bliss OS are examples of other popular Android emulators. 

Unlike with Android, there are no official iOS emulators available for general use. That is because iOS is a closed ecosystem developed and controlled by Apple, which has not provided the necessary licensing and support for developers to create iOS emulators. While there are some tools and software that claim to be iOS emulators, they are often limited in functionality and can't fully replicate the complete iOS environment. This is because they lack the necessary access to Apple's closed-source code and hardware architecture.

Simulator

A simulator, on the other hand, typically provides a software-based representation of a mobile device's user interface and behavior. It aims to simulate the appearance and behavior of a mobile device's interface without replicating the underlying hardware or software architecture. Simulators focus on providing a visual representation of the mobile device's user interface, allowing developers to test and interact with the app in a simulated environment.

Simulators often come bundled with development tools or frameworks and provide features like debugging, code inspection, and simulated input events. They offer a convenient way to rapidly test and iterate on mobile app designs and functionality. However, since simulators do not emulate the full hardware and software stack, they may not provide the same level of accuracy and performance as a physical device.

There are no official Android simulators. That’s because Android emulators serve a similar purpose to simulators. 

Apple does provide an official iOS simulator as part of its Xcode development environment. It provides a simulated environment for app testing but does not offer the same level of functionality or performance as a physical iOS device or an emulator.

How Can an Emulator Be Used To Attack a Mobile App?

Using an emulator to compromise a mobile app typically involves attempting to exploit vulnerabilities or weaknesses in the mobile app's code, security mechanisms, or interactions with the mobile device's hardware or operating system. Here are some ways an emulator can be used to compromise a mobile app:

  • Reverse Engineering. Emulators can be used to reverse engineer the mobile app's code to understand its logic and underlying algorithms. Attackers can analyze the decompiled code to find vulnerabilities, extract sensitive information, or modify the app's behavior to suit their malicious intentions.
  • Tampering with App Behavior. Once an app is running on an emulator, attackers can use various tools to manipulate the app's data, requests, and responses. This might involve altering communication with the app's backend servers, bypassing security checks, or modifying in-app purchases or other financial transactions.
  • Dynamic Analysis. Emulators can be used for dynamic analysis of the app's behavior while it runs. Attackers can observe the app's interactions, monitor network traffic, and identify sensitive data being transmitted or stored insecurely.
  • Exploiting Emulator Weaknesses. Emulators themselves may have vulnerabilities that attackers can exploit to gain access to the host system or manipulate the emulator's behavior to affect the app running on it.
  • Injecting Malware. Emulators can be used to test and deploy malware, including viruses, Trojans, and spyware, targeting the mobile app or the entire device on which the emulator runs.
  • Circumventing Security Measures. Some apps implement specific security measures to prevent running in emulated environments or to detect tampering. Attackers may attempt to bypass these security measures using various techniques.
  • Automated Attacks. Emulators can be combined with automation tools to perform large-scale attacks, such as brute-force attacks on login credentials, to find vulnerabilities, or to test the app's resistance to various attacks.

How Can Emulator Detection Be Implemented?

Implementing emulator detection in mobile apps will typically involve a combination of techniques in order to reliably identify if the app is running on an emulator. Here are a few commonly used methods:

  1. Check for Emulator Artifacts. Emulators often leave behind certain artifacts or files that can be used as indicators. The app can check for the presence of these artifacts, such as specific files, system properties, or emulator-specific packages. 
  2. Hardware Characteristics. Emulators may have distinct hardware characteristics that differ from real devices. The app can check for unusual or inconsistent hardware information, such as the device's model, manufacturer, or sensor data. 
  3. Performance Analysis. Emulators may exhibit different performance characteristics compared to real devices. The app can analyze performance metrics, such as CPU speed, memory availability, or graphics capabilities, and compare them against known emulator profiles.
  4. System Calls. Emulators may handle certain system calls differently than real devices. The app can make specific system calls and observe the response or behavior to identify discrepancies that indicate emulation.
  5. Network Detection. Emulators often use network configurations that differ from real devices. The app can analyze network-related information, such as IP addresses, MAC addresses, or network interfaces, to detect emulator-specific patterns.
  6. Debugging/Tracing Detection. Emulators may expose specific debugging or tracing features that real devices do not provide. The app can check for the presence of debugging hooks or monitor the availability of certain tracing tools to detect emulated environments.

For example, the easiest way for the app to get available hardware information is to check on the build values under BuildConfig. Build.MANUFACTURER, Build.MODEL, Build.HARDWARE, Build.FINGERPRINT, Build.BOARD and Build.PRODUCT can all be accessed programmatically and most of the time they contain proof of the presence of an emulator.

It's important to note that emulator detection is not foolproof and can sometimes lead to false positives or negatives. Determined attackers can find ways to bypass detection mechanisms or modify emulators to mimic real devices. Therefore, emulator detection should be used as one layer of defense among other security measures, such as jailbreak and root detection, debug detection, tamper detection, MitM detection, and data protection.

Blue Cedar Provides Emulator Detection

logo_icon_enforce

Blue Cedar Enforce

Blue Cedar Enforce, a component of Blue Cedar Mobile App Security, provides emulator detection. Being able to detect if a mobile app is running in an emulator and then preventing the mobile app from executing is one of many mobile app security features provided by Blue Cedar Mobile App Security.

cedar_cat_no_code

Blue Cedar Enhance

Blue Cedar also provides an easy way to incorporate mobile app security, including emulator detention, into a mobile app. That is via Blue Cedar Enhance, Blue Cedar’s no-code integration service that adds new functionality to mobile apps without requiring a single line of code to be written. Blue Cedar Enhance integrates mobile app security into iOS and Android mobile app binaries, regardless of the libraries and frameworks that underpin these app binaries. 
cedar_orchestrating_2022

The Blue Cedar Platform

Blue Cedar Mobile App Security and Blue Cedar Enhance are delivered by the Blue Cedar Platform, a CI/CD friendly SaaS solution that also provides deployment services, such as app import and code signing, to streamline delivery of secured mobile apps.