SIMshield Firewall

Dangers

Proactive SIM

In much of our prior work on the dangers of SIM cards, we explored a feature called "proactive SIM". This is a commonly found feature of many commercial SIM cards and most smartphones and IoT devices.

Proactive SIM operates on the principle of polling, i.e., a SIM will indicate that it created a proactive command, which is followed by the mobile device requesting this command and, later, executing it.

While some commands are rather benign, such as, DISPLAY TEXT for displaying a text message on the screen, other commands carry a significant risk to the mobile device, such as, RUN AT for running an ATtention command on the baseband. In our recent publication "CATana: On the Dangers of SIM-Originating AT Commands" [usenix.org][youtube.com], we demonstrated the dangers of allowing a SIM card to run AT commands on the modem by obtaining a code execution capability on a Quectel modem, among other attacks on other devices.

In our recent talk at TROOPERS 2026, titled "A SIM Hacking Odyssey: Can a SIM hack YOU?" [troopers.de][youtube.com], we also showed how the LAUNCH BROWSER proactive command could be used to bypass the lockscreen of a Pixel smartphone, and we even demonstrated this attack live on stage.

Suffice to say that proactive commands can pose a significant risk to the privacy and security of mobile devices. To the best of our knowledge, there are also no vendors who offer users an ability to control what proactive commands are allowed, if any. This prevents the user from mitigating this risk from, e.g., the level of Android, iOS, etc...

Defense

SIMshield

Our solution to the problem of malicious SIM cards is to attach a thin interposer sticker to the existing SIM card, and allow this interposer to disallow certain messages from flowing, in essence, preventing the proactive commands from ever being issued from the SIM card to the mobile device, no matter what.

Protocol

To understand what needs to be blocked, we need to get a basic idea of what is flowing between the SIM and the mobile device.

Below is a capture of a common exchange in the protocol. Let's walk through it step-by-step.

  1. Everything starts with the terminal (i.e., the mobile device modem) sending a 5 byte header, in this case 0x00 0xA4 0x00 0x04 0x02.
  2. The interposer parses the header and decides it is supported and it gets forwarded to the SIM card.
  3. Soon after receiving the header, the SIM responds with a procedure byte, in this case 0xA4 to indicate that the terminal should send the remaining bytes of the command.
  4. The interposer forwards the procedure byte to the terminal and receives a 2 byte payload in return: 0x3F 0x00.
  5. The data payload is forwarded to the SIM and a 2 byte status word is returned to us by the SIM: 0x61 0x31.
  6. Once we forward the status word to the terminal, the exchange finishes, and another command can be sent by the terminal.
  7. At the end we see that the terminal is sending another command header: 0x00 0xC0 0x00 0x00 0x31.

All proactive commands get exchanged in the same way, first the SIM indicates to the terminal that a proactive command is available, then the terminal uses the FETCH command to obtain the contents of the command. If we block the FETCH command, the SIM will never be able to issue proactive commands to the terminal.

Implementation

We need to edit the caseFetch function inside of ./src/common/tpdu.zig. The original is as follows, and it simply indicates that the command expects a data field in the response:

fn caseFetch(header: *const [5]u8) ?Case {
    _ = header;
    return .response__data_length;
}
                    

If we modify the caseFetch function to always return null, we indicate to the interposer that the command is unsupported, and therefore an according status word is returned and the command is never forwarded to the SIM card:

fn caseFetch(header: *const [5]u8) ?Case {
    _ = header;
    return null;
}
                    

The result of this change can be better seen using a logic analyzer. If we have a look at the behavior with and without the defense, we see the following:

A FETCH command is allowed and forwarded to the SIM, which proceeds to send a SET UP EVENT LIST proactive command in the response.
A FETCH command gets blocked and a 0x6D00 status word, i.e., "Instruction code not supported or invalid", is returned.

Setup

Hardware

The captures were obtained using SIMshield device docked with the SIMshield Dock and a Saleae Logic Pro 16 connected to the LA ports of the SIMshield Dock Controller.

SIMshield Dock Controller plugged into the SIMshield probes.
SIMshield docked inside SIMshield Dock. Pogo pins press onto the SIMshield contacts to connect them to the probing boards, and further down, also the controller.

Acknowledgments

Funding

This project is funded through NGI Mobifree Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

NLnet Foundation logo NGI Mobifree logo