Working draft. See About ‘WIP’. A survey drawn from three of my repositories: badusb (USB mass-storage TOCTOU, 2019), lightning_strike (Lightning USB captures and a WebUSB proof of concept, 2019 and 2021) and lightning_dfu (accessory-ID DFU signaling, 2021). The connector-specific parts are from 2021; the storage work is from 2019. It builds on the posts PlugNPwn: Connect to Jailbreak and ACE Controller Secrets.
Resumen
El conector físico es la parte del límite de confianza de un teléfono sobre la que el usuario tiene menos capacidad de razonamiento. Un cable o una base parecen inertes, y una pestaña del navegador parece aislada, sin embargo ambos pueden alcanzar interfaces del dispositivo que el firmware trata como confiables. Esta encuesta recopila tres pequeños estudios de esa superficie. Primero, un arnés FUSE que se sitúa bajo el almacenamiento masivo USB, registra cada lectura y escritura con hashes de contenido, y sirve bytes diferentes en una lectura posterior a los que sirvió en la primera, proporcionando a cualquier consumidor de tipo verificar‑luego‑usar una división de tiempo de comprobación/tiempo de uso (TOCTOU). Segundo, una página WebUSB que abre un dispositivo Apple por ID de vendedor y selecciona una configuración USB no predeterminada desde un navegador ordinario, sin controlador y con un solo clic como puerta de entrada. Tercero, un microcontrolador que maneja la línea accessory‑ID de Lightning para forzar al dispositivo a entrar en DFU. Juntos argumentan que “estaba firmado” y “solo es una página web” son garantías más débiles de lo que parecen en el conector.
1. El almacenamiento masivo es una promesa, no un hecho
Un consumidor que lee datos de un almacenamiento extraíble, los verifica y luego los vuelve a leer para usarlos ha asumido que el almacenamiento devuelve los mismos bytes en ambas ocasiones. El almacenamiento extraíble es libre de mentir.
The harness. badusb is a FUSE filesystem that passes reads and writes through to a backing image while instrumenting them. Every read and write is recorded to SQLite with its path, offset, length and a SHA-256 of the buffer, and read counts are kept per region. This alone is a useful forensic lens on exactly what a restore or verification process touches and in what order.
The attack. On top of the log sits an injector. A modifier watches for a trigger, such as “the STATE partition has now been read N times”, and from that point rewrites the bytes served for a region, sourcing the replacement from a file, another partition, or a copy-on-write overlay. A PartitionReplaceInject tracks the GPT it has seen, locates the targeted partition, counts reads of its first byte, and swaps in a prepared bad image once the count passes a threshold. A verifier that reads a partition once to hash it and later reads it again to use it sees clean data at check time and attacker data at use time.
Why it matters. Restore and update flows read images from storage, check a signature or hash, and then consume them. If the check and the use are two separate reads of mutable storage, the signature was never a guarantee about the bytes that were used, only about the bytes that were checked. The defense is to verify the exact buffer that is consumed, from a single read into memory, rather than trusting that a second read matches the first.
2. Un navegador puede alcanzar el dispositivo
The proof of concept. lightning_strike’s bad_web_usb.html is a plain page. On a click, it calls navigator.usb.requestDevice filtered to an Apple vendor ID (0x05ac) and a specific product, opens the device, enumerates its configurations and interfaces, and calls selectConfiguration to switch it to a configuration that is not the default (configuration 5 in the code), then claims an interface.
Why it matters. WebUSB’s gate is a single user gesture and the browser’s device picker. Past that, a web page is talking to a physical USB device at the configuration and interface level, with no installed driver and no native code. Apple devices expose several USB configurations and alternate interfaces, some of them diagnostic; reaching one of those from a web page collapses the distance between “visited a link” and “spoke to a privileged device interface”. The USB captures in the same repository (Total Phase traces of DFU entry, backup, personal hotspot and ordinary connection) are the raw material for working out which configurations and interfaces appear in which states.
3. El accesorio puede comandar el puerto
The sketch. lightning_dfu is an early Tiva-C (TM4C123) microcontroller prototype aimed at triggering DFU or a reset through the Lightning accessory-identification path, the ACC_ID line, rather than the usual button chord.
Por qué importa. DFU es un estado poderoso: es donde operan herramientas y exploits a nivel de bootrom como checkm8 y PlugNPwn. Si un cable o dock, que el usuario considera pasivo, puede llevar el dispositivo a DFU por sí mismo mediante señalización de accesorio, entonces entrar en ese estado ya no es algo que solo el propietario del dispositivo pueda hacer con una secuencia deliberada de botones. Esta es la contrapartida de hardware del trabajo de PlugNPwn: el conector no es solo una vía de datos, es una vía de control.
4. El hilo común
Cada estudio elimina una suposición de la que el conector depende silenciosamente:
- Se asume que el almacenamiento masivo es estable entre lecturas; el arnés FUSE muestra que no tiene que serlo.
- Se asume que una pestaña del navegador está lejos del hardware; WebUSB muestra que está a un clic de una configuración de dispositivo.
- Se asume que un cable es pasivo; la señalización de accesorio muestra que puede llevar el puerto a DFU.
Ninguno de estos es un exploit por sí solo. Son las precondiciones de las que se vale una cadena de exploits, y la razón por la que el conector merece el mismo escrutinio que la pila de red.
5. Limitaciones y trabajo abierto
- El arnés TOCTOU demuestra la primitiva contra una imagen de respaldo; enlazarlo a un flujo de restauración firmado específico, y mostrar un verificador que lea dos veces, es el siguiente paso.
- Se muestra que el interruptor de configuración WebUSB funciona; mapear cada configuración USB de Apple y la interfaz alterna al estado del dispositivo que la expone, a partir de las capturas, está sin terminar.
- El trabajo DFU‑over‑accessory es un boceto temprano de microcontrolador, no un disparador fiable, y la señalización exacta ACC_ID necesita definirse y probarse en varios dispositivos.
Referencias
- badusb, lightning_strike, lightning_dfu.
- PlugNPwn: Connect to Jailbreak and ACE Controller Secrets.
- Especificación WebUSB, W3C. (por añadir)
- checkm8 y la superficie de ataque SecureROM DFU. (por añadir)