Stealing a Mobile Identity Using Wormholes
Markus Vervier (Security Researcher and Penetration Tester)
BruCON 0x06 · Day 2
Overview
In this BruCON 2014 talk, security researcher and penetration tester Markus Vervier unveils a critical vulnerability in MediaTek-based Android phones that allows for the remote theft and usage of a mobile identity, effectively creating a "wormhole" for SIM card authentication. The presentation, titled "Stealing a Mobile Identity Using Wormholes," meticulously details how an unprivileged Android application can gain direct access to the SIM card, extract cryptographic keys essential for mobile network authentication, and then tunnel these authentication requests and responses over the internet to a remote SIM card. This groundbreaking research exposes a fundamental flaw in the mobile network's security architecture, which, designed in the 1980s, is ill-equipped to handle the complexities and diverse communication channels of modern smartphones.

Key moments
- 0:00 Introduction to mobile identity theft using wormholes
- 2:20 How mobile network authentication and SIM cards work
- 5:30 MediaTek baseband: Modifiability and debug information
- 9:00 Unprivileged SIM card access using AT+CSIM commands
- 11:40 Live demo: Extracting network authentication keys (S.res, Kc)
- 15:40 The "wormhole" concept: Remote SIM card access
- 18:10 Shadow Sim: Patching baseband for virtual SIM functionality
- 28:00 Outdated mobile network security model and non-repudiation
Stealing a Mobile Identity Using Wormholes
Speakers: Markus Vervier, Security Researcher and Penetration Tester, Germany
Conference: BruCON
YouTube: https://www.youtube.com/watch?v=V6_mZyQdEuU
Overview
In this BruCON 2014 talk, security researcher and penetration tester Markus Vervier unveils a critical vulnerability in MediaTek-based Android phones that allows for the remote theft and usage of a mobile identity, effectively creating a "wormhole" for SIM card authentication. The presentation, titled "Stealing a Mobile Identity Using Wormholes," meticulously details how an unprivileged Android application can gain direct access to the SIM card, extract cryptographic keys essential for mobile network authentication, and then tunnel these authentication requests and responses over the internet to a remote SIM card. This groundbreaking research exposes a fundamental flaw in the mobile network's security architecture, which, designed in the 1980s, is ill-equipped to handle the complexities and diverse communication channels of modern smartphones.
Vervier's work highlights how specific MediaTek baseband firmware, prevalent in millions of low-cost Android devices, contains misconfigurations and design oversights that enable this sophisticated attack. By patching the baseband firmware and leveraging shared memory communication, he demonstrates a proof-of-concept dubbed "Shadow SIM" that effectively virtualizes a SIM card, allowing a phone to authenticate to a mobile network using a SIM card located anywhere in the world. This capability has profound implications for mobile network security, user privacy, and even legal non-repudiation, as it fundamentally undermines the assumption that a SIM card must be physically present in a device to grant network access.
The talk serves as a stark reminder that the foundational security models of critical infrastructure often lag behind technological advancements. Vervier's findings not only expose a direct attack vector for identity theft and network abuse but also initiate a broader discussion about the inherent vulnerabilities introduced by complex, proprietary hardware components like basebands within an open, application-rich environment like Android. The "wormhole" concept illustrates how seemingly disparate communication channels can be chained together to bypass established security paradigms, enabling a new class of attacks against mobile identities.
Background
▶ Watch: Introduction to mobile identity theft using wormholes (0:00)
To understand the severity of the "wormhole" attack, it's crucial to first grasp the fundamentals of mobile network authentication and the architecture of a smartphone. When a user signs a contract with a mobile network provider, they receive a Subscriber Identity Module (SIM) card. This SIM card is a tamper-resistant device containing a unique secret key, known as Ki (Key Identifier), which is also stored by the network provider. Authentication to the mobile network is performed via a challenge-response mechanism: the network sends a random challenge (RAND) to the phone, which the SIM card uses along with its Ki to compute a response (SRES) and a session key (Kc). These are sent back to the network, which verifies the SRES and uses Kc for subsequent encrypted communication. Crucially, the user has no direct access to the Ki or the cryptographic operations within the SIM card.
Central to a mobile phone's operation is the baseband processor, also known as the modem. This is a separate, dedicated system within the phone, often with its own CPU and operating system, responsible for all communication with the mobile network (2G, 3G, 4G). The baseband has direct, privileged access to the SIM card. Most baseband firmwares are proprietary and closed-source, making security analysis challenging. Apart from the open-source Osmocom baseband work, the firmware used in commercial devices is closed; the research here targets the widespread MediaTek MT6573 platform found in many inexpensive phones.
Markus Vervier's research specifically targets MediaTek platforms, a prominent Chinese vendor, due to their relative ease of modification. Unlike some other vendors that employ more stringent lockdown mechanisms, MediaTek's approach to baseband security presented several exploitable characteristics. The MediaTek baseband typically runs a Real-Time Nucleus OS and, interestingly, is loaded by the Android application processor (AP) from a file on the Android file system, typically named modem.img. Although the baseband and application processor are logically separate systems, often on the same System-on-Chip (SoC), they share physical resources like RAM. This shared memory becomes a critical communication channel.
Communication between the Android AP and the baseband occurs primarily through two methods: UART (Universal Asynchronous Receiver/Transmitter), which provides a serial connection for AT commands (used for basic modem control and data connections like GPRS), and shared memory, which offers a much faster channel suitable for audio data, low-level debugging, and firmware control (e.g., resetting the baseband firmware or handling exceptions). A significant finding was that MediaTek baseband firmware is often unencrypted and contains a wealth of debugging information, including source code file paths and assertion strings. Running a simple strings command on a modem.img reveals extensive internal details, simplifying reverse engineering and modification efforts.
Normally, direct access to the SIM card from the Android application processor is not intended or required for standard operations. However, a critical vulnerability was identified in how MediaTek devices expose the baseband's AT command interface. On these devices, the /dev/pts/ devices, which serve as pseudo-terminals for serial communication, were found to have lax permissions. This misconfiguration allowed any unprivileged application or process on the Android system to send AT commands to the baseband. Among these commands, the AT+CSIM command stands out. This command, specified in 3GPP standards, allows for generic SIM access, enabling the terminal equipment (TE, i.e., the phone) to send Application Protocol Data Units (APDUs) directly to the SIM card and receive its responses. The 3GPP specification itself warns that "care must be exercised in AT commands that allow the TE to take unintentional control over the SIM AT interface (e.g., +CSIM)," a warning that MediaTek developers, in this instance, appear to have overlooked.
Key Findings
▶ Watch: MediaTek baseband: Modifiability and debug information (5:30)
Markus Vervier's research yielded several critical findings that underpin the feasibility and impact of the "wormhole" attack:
- Unprivileged SIM Card Access on MediaTek Devices: The most significant discovery is that, on many MediaTek-based Android phones (specifically demonstrated on the MTK 6573 platform, found in devices like the Alcatel One Touch 918D), an unprivileged Android application can gain direct, unrestricted access to the SIM card. This is possible because the
/dev/pts/devices, which expose the baseband's AT command interface, are configured with overly permissive access rights. This allows any process to sendAT+CSIMcommands to the SIM card.
- Extraction of Mobile Network Authentication Keys: Leveraging the
AT+CSIMvulnerability, an unprivileged application can send specific Application Protocol Data Units (APDUs) to the SIM card. Crucially, the talk demonstrates sending the00880081APDU, which corresponds to the "Internal Authenticate" command. When provided with a network challenge (RAND), the SIM card responds with the SRES (Signed Response) and Kc (Ciphering Key). These two cryptographic keys are fundamental for mobile network authentication and subsequent encrypted communication. The ability to extract these keys without any special permissions from a local application completely bypasses the SIM card's intended security model.
- Modifiable and Unencrypted Baseband Firmware: The MediaTek baseband firmware (
modem.img) was found to be unencrypted and replete with debugging information, including source code file paths and assertion messages. This wealth of information dramatically simplifies the reverse engineering process, making it feasible to identify critical functions responsible for SIM card access (e.g.,sim_command_all). The unencrypted nature of the firmware also allows for straightforward binary patching.
- The "Wormhole" Concept: Remote SIM Usage: By combining the ability to patch the baseband firmware with the unprivileged SIM access, Vervier developed the "wormhole" concept. This involves modifying the baseband to intercept APDUs intended for the local SIM card and instead forward them to the Android application processor. The Android application then tunnels these APDUs over an alternative communication channel (e.g., TCP/IP via Wi-Fi or cellular data) to a remote server hosting a real SIM card. The remote SIM processes the APDU, sends back the response, which is then tunneled back to the Android app, and finally injected into the baseband, effectively simulating the presence of the remote SIM card. This allows a mobile phone to authenticate to a network using a SIM card located anywhere in the world, bypassing geographical constraints and the need for physical presence.
- Outdated Mobile Network Security Model: The core problem identified is that the mobile network's security model, designed in the 1980s for simpler feature phones, assumes a tightly controlled environment where the SIM card is physically coupled with the baseband and isolated from the application processor. This model fails to account for the complex, multi-channel, and application-rich environment of modern smartphones, where arbitrary applications can run and exploit design flaws in proprietary components. The existence of multiple communication channels (Wi-Fi, Bluetooth, other cellular connections) provides the "wormholes" necessary to circumvent the traditional security perimeter.
These findings collectively demonstrate a severe breakdown in the security chain, transforming the SIM card from a secure, physically bound identity token into a remotely accessible and exploitable resource, with far-reaching implications for mobile identity and privacy.
Technical Deep Dive
▶ Watch: Live demo: Extracting network authentication keys (S.res, Kc) (11:40)
The technical underpinnings of the "wormhole" attack are multifaceted, combining vulnerabilities in baseband design, Android permissions, and clever firmware modification.
At the heart of mobile network security is the SIM card's role in authentication. When a phone attempts to register with a network, the network sends a RAND (Random Challenge). The SIM card, which securely stores the Ki (Key Identifier), uses an algorithm (typically A3/A8 for GSM) to compute two values: SRES (Signed Response) and Kc (Ciphering Key). The phone sends SRES back to the network for verification, and Kc is used to derive session keys for encrypting subsequent voice and data traffic. The critical aspect is that Ki is never exposed, and all cryptographic operations occur securely within the SIM's tamper-resistant environment.
MediaTek basebands, such as the MTK 6573 platform, run a Real-Time Nucleus OS. Unlike many other basebands, the firmware (modem.img) is loaded by the Android application processor (AP) at boot time. This loading process and the fact that the baseband and AP often share physical RAM are crucial. The baseband firmware is typically unencrypted, and a simple strings command on modem.img reveals a treasure trove of debugging information, including source code file paths and assertion messages. This significantly aids in reverse engineering, allowing researchers to understand internal functions and data structures without full source code access.
Communication between the Android AP and the baseband is managed via two primary channels:
- UART: Used for standard AT commands (e.g.,
ATDfor dialing,ATSfor settings). These commands are exposed via pseudo-terminal devices like/dev/pts/Xon Android. - Shared Memory: A high-speed interface used for data-intensive tasks like audio transfer, low-level debugging, and controlling baseband firmware operations (e.g., resets, exception handling).
The core vulnerability enabling SIM access stems from misconfigured permissions on the /dev/pts/ devices on vulnerable MediaTek phones. Instead of restricting access to privileged processes, these devices were accessible by any unprivileged application. This allowed an arbitrary Android app to send AT commands to the baseband. Specifically, the AT+CSIM command was the target. Its syntax is AT+CSIM=<length>,<hex_encoded_command>, where <hex_encoded_command> is an APDU (Application Protocol Data Unit). The response follows a similar format: +CSIM:<response_length>,<hex_encoded_response>.
To perform network authentication, the specific APDU 00880081 (Internal Authenticate) is used. This command's structure includes a class byte (00), an instruction byte (88 for Internal Authenticate), parameters (0081 for algorithm and key reference), a payload length, and the RAND (Random Challenge) from the network as its payload. Interestingly, while standard RANDs are typically 10 bytes long, MediaTek's implementation was observed to expect an 11-byte RAND. The SIM card processes this APDU and returns the SRES and Kc keys in its response. The ability for an unprivileged app to send this APDU and retrieve these critical keys is a severe security lapse.
To create the "wormhole," Markus Vervier developed "Shadow SIM," which involves a patched baseband firmware and a native Android application. The firmware modification focused on identifying the function responsible for encapsulating all SIM card access, named sim_command_all. This function is a central point for all interactions between the baseband and the physical SIM. The modification involved patching this function to:
- Intercept outgoing APDUs: Instead of sending them directly to the physical SIM, the patched function redirects them to the Android application processor.
- Receive incoming APDU responses: The patched function then takes APDU responses from the Android application and feeds them back into the baseband, making the baseband "believe" it's communicating with a local SIM card.
The choice of communication channel between the patched baseband and the Android app was critical. Initial thoughts on using UART proved problematic due to the asynchronous, handler-based implementation within the baseband's real-time OS. A more effective solution was found in leveraging the shared memory architecture already present between the AP and baseband. Vervier implemented a "poor man's IPC" (Inter-Process Communication) mechanism using shared memory: the baseband writes APDUs to a designated shared memory region and signals the Android app, which monitors this region. The Android app then writes the APDU responses back to shared memory, which the baseband reads.
Firmware modification was greatly aided by the unencrypted nature of the MediaTek baseband, the abundance of debug strings, and the reuse of code across different MediaTek devices. By cross-referencing function names and opcodes from other publicly available MediaTek source code or firmware, relevant functions like sim_command_all could be easily located and modified in the target modem.img using disassemblers. The firmware is plain ARM code, simplifying the patching process. The "Shadow SIM" release on GitHub provided a binary patch (difference) rather than the full firmware to avoid legal issues related to intellectual property distribution.
Demo / Proof of Concept
▶ Watch: The "wormhole" concept: Remote SIM card access (15:40)
The practical demonstration of the "wormhole" attack, dubbed "Shadow SIM," vividly illustrated the feasibility and implications of remote SIM card access. The setup involved an Alcatel One Touch 918D phone, running the custom-patched MediaTek baseband firmware (MTK 6573 platform), and a remote Perl script acting as a SIM server.
The core components of the demonstration were:
- Patched Baseband Firmware: The Alcatel phone was flashed with the modified
modem.img. This firmware had thesim_command_allfunction patched to redirect APDUs to and from the Android application processor via shared memory, rather than directly interacting with the physical SIM slot.
- Native Android Application: Running on the phone, this application served as the intermediary. It monitored the shared memory for APDUs sent by the patched baseband. Upon receiving an APDU, it would encapsulate it within a custom protocol and forward it over TCP/IP (using the phone's Wi-Fi connection) to the remote SIM server. Conversely, it received APDU responses from the remote server and wrote them back to the shared memory, where the baseband could retrieve them.
- Remote SIM Server (Perl Script): This script, running on a separate machine, was configured to listen on TCP port 4711. It had access to a real, physical SIM card. When it received an APDU from the Android application via TCP, it would send that APDU to its local SIM card. Once the local SIM card processed the APDU and returned a response, the Perl script would send this response back to the Android application over the same TCP connection.
The demonstration unfolded as follows:
- The Android application was started on the Alcatel phone.
- The phone was connected to a Wi-Fi network.
- Upon booting and attempting to register with the mobile network, the phone's baseband initiated communication with what it believed was a local SIM card.
- However, due to the patched firmware, these APDUs were intercepted by the Android app.
- The Android app then tunneled these APDUs over the Wi-Fi network to the remote Perl SIM server.
- The remote SIM server, with its physical SIM card, processed the APDUs (e.g., responding to the "Internal Authenticate" command with SRES and Kc).
- The responses were then tunneled back over TCP/IP to the Android app, which injected them into the baseband via shared memory.
- Remarkably, the phone successfully registered with the mobile network, believing it was using a local SIM card, while in reality, the authentication was being performed by a SIM card located physically elsewhere.
A significant observation during the demo was the network's tolerance for latency. Markus Vervier explicitly stated that he tested the setup by "sending them around the world," and it "really worked even with a higher latency there was no problem." This highlights a critical weakness: mobile networks are designed to accommodate varying latency due to radio conditions and network congestion, making it difficult for them to detect or prevent remote SIM usage based solely on response times. The phone was observed performing various SIM-related operations, including recreating the phone book and, crucially, completing mobile network authentication. This successful proof of concept definitively established the practicality and impact of the "wormhole" attack.
Defensive Implications
▶ Watch: Outdated mobile network security model and non-repudiation (28:00)
The "wormhole" attack presents a formidable challenge for mobile network operators, device manufacturers, and end-users, fundamentally altering the landscape of mobile identity security. The defensive implications can be categorized into immediate mitigations and broader, more systemic challenges.
Immediate and Device-Specific Defenses:
- Secure Baseband Firmware: The primary vulnerability lies in the unencrypted, easily modifiable nature of the MediaTek baseband firmware and the lax permissions on
/dev/pts/devices. Device manufacturers must ensure that baseband firmware is properly signed, encrypted, and its integrity verified at boot time to prevent unauthorized modifications. Furthermore, access to AT command interfaces, particularly those allowing generic SIM access likeAT+CSIM, must be strictly restricted to privileged system processes. Markus notes that "in the newer version somebody sort of about that it's not as easy anymore without privileges without root on the phone to get to the sim but it's some platforms not impossible." This indicates some progress but highlights that the problem might persist on other platforms or older devices.
- Root Access Prevention: Since the attack relies on modifying firmware or installing a native application that requires access to sensitive device files, preventing root access on Android devices is a crucial first line of defense. However, many low-cost MediaTek phones are often easier to root or come with less secure bootloaders, making this a continuous battle.
Network-Level Defenses for Operators:
- Detect Multiple SIM Usage: Mobile network providers already employ mechanisms to detect if a physical SIM card is being cloned and used simultaneously in multiple locations. However, the "wormhole" attack is not a traditional SIM clone; it's a remote access mechanism. While the network might observe the same SIM credentials authenticating from different base stations, distinguishing this from legitimate roaming or rapid travel is complex. The network could potentially flag concurrent authentications from geographically distant locations.
- Geo-Location Sanity Checks: A more robust defense involves implementing geo-location sanity checks. If a SIM card authenticates from Hong Kong at one moment and then five minutes later from Belgium or the US, this strongly suggests malicious activity. Such rapid, physically impossible location changes should trigger alerts and potentially temporary suspension of service for that SIM. The speaker explicitly mentions this: "if your phone registers in Hong Kong and five minutes later it's in Belgium or in Germany or in the US something smells fishy."
- Limiting Authentication Response Times: The speaker suggests that providers "could maybe try to limit the response time for the authentication requests." If the network expects a response within a very short, specific timeframe, the added latency introduced by tunneling APDUs around the world might cause authentication failures. However, this is a highly challenging defense to implement due to the "zoo of devices out there" and the inherent variability of mobile radio connections (packet loss, signal strength), which can legitimately introduce latency. A strict limit could lead to false positives and service disruption for legitimate users.
Broader Implications and Challenges for Defense:
- Erosion of Non-Repudiation: The most profound defensive implication is the loss of non-repudiation for mobile identities. If a SIM card's credentials can be used remotely, it becomes impossible to definitively prove that a specific individual, by virtue of having their physical SIM card, performed a particular action (e.g., made a call, sent an SMS). As Vervier states, "if you have a sim card in your phone and I don't know maybe you the police suspects you of doing something bad you could say maybe somebody hacked my basements and transferred to the credentials my phone yeah that is a possibility here." This undermines the legal and forensic value of SIM card presence as evidence.
- Facilitating Botnets and Monitoring Evasion: Defenders must contend with the potential for attackers to build botnets using stolen SIM credentials from compromised phones. These botnets could then be used for illicit activities like making free calls, sending spam, or evading monitoring by rapidly switching "personas" or geographical locations. This makes attribution and tracking significantly harder.
- Outdated Security Model: The fundamental challenge is that the mobile network security model, designed for a different era, is ill-suited for the modern smartphone ecosystem. Until this underlying model is re-evaluated and updated to account for application-layer threats and diverse communication channels, these types of "wormhole" vulnerabilities will continue to emerge. Defending against such sophisticated attacks requires a holistic approach, encompassing secure hardware, robust software, vigilant network monitoring, and a re-thinking of mobile identity itself.
Key Takeaways
- Critical Vulnerability in MediaTek Basebands: Many MediaTek-based Android phones were found to have critical vulnerabilities, including lax permissions on
/dev/pts/devices, allowing unprivileged Android applications to sendAT+CSIMcommands for generic SIM access. - Remote Extraction of Authentication Keys: This vulnerability enables the extraction of vital mobile network authentication keys (SRES and Kc) from the SIM card without requiring root privileges, fundamentally compromising the SIM card's intended security.
- Feasibility of "Wormhole" Attacks: By patching baseband firmware and tunneling APDUs over alternative communication channels (e.g., TCP/IP via Wi-Fi), a "wormhole" can be created, allowing a mobile phone to authenticate using a SIM card located anywhere in the world.
- Outdated Mobile Network Security Model: The attack highlights that the mobile network's security architecture, designed in the 1980s, is ill-equipped to handle the complexities, shared resources, and diverse communication channels of modern smartphones.
- Erosion of Non-Repudiation: The ability to remotely use a SIM card's identity fundamentally undermines the concept of non-repudiation, making it impossible to definitively prove that a physical SIM card was present in a device for a given action.
- Challenging Defenses: Defending against such attacks is difficult due to the inherent latency tolerance of mobile networks and the challenge of implementing effective geo-location sanity checks across a diverse "zoo of devices."
About the Speaker(s)
Markus Vervier is a security researcher and penetration tester based in Germany. With a long-standing background in security, his primary interests lie in firmware, network security, and mobile networks. He focuses on identifying vulnerabilities and flaws in security designs, showcasing a deep technical expertise that allows him to uncover complex issues in critical systems like baseband processors.