Riassunto analitico
Il firmware rappresenta uno specifico componente software progettato e installato direttamente dal produttore nel dispositivo embedded per cui è stato scritto, ad esempio router, telecamere IP, gateway ecc. Negli ultimi anni questi dispositivi hanno guadagnato una grande diffusione, determinando la conseguente crescita dell'attenzione dei ricercatori per la sicurezza degli apparati. L'emulazione del sistema e il re-hosting del firmware sono diventate tecniche popolari per rispondere a varie misure di sicurezza e a vincoli prestazionali. In questo lavoro, vengono analizzati alcuni dei principali framework per l'emulazione e il re-hosting del firmware descrivendone nel dettaglio le componenti, le loro funzionalità ed i limiti tecnici riscontrati durante la fase di testing sul case study di riferimento, il firmware della IP camera Tenda CP3. Vengono messe in evidenza le cause principali che ostacolano l'emulazione e, laddove possibile, i potenziali percorsi risolutivi per ovviare ai problemi individuati. I tools che sono stati analizzati e testati possono essere suddivisi in tre grandi categorie: full-system emulation, user-level emulation e kernel-level emulation. Nella prima categoria rientrano FirmAE e Surgeon. FirmAE, basato su Firmadyne, adotta una tecnica denominata "emulazione arbitraria" per cui, invece di seguire rigorosamente il comportamento di esecuzione del firmware, segue un approccio a metà tra il contesto originale e l'iniezione di interventi appropriati, creando così non un ambiente identico al dispositivo ma un ambiente favorevole all'analisi dinamica. Surgeon rappresenta invece il primo tool di re-hosting general-purpose per firmware MCU. Il focus di questo framework consiste nell'utilizzo della tecnica di transplantation, una nuova tecnica di re-hosting in cui si va ad eseguire il firmware alla velocità nativa della CPU dell'host. Nella seconda categoria rientra Greenhouse, in questo caso il focus è spostato sull'emulazione che circonda un singolo servizio del firmware, garantendo così i vantaggi di un'elevata fedeltà di esecuzione senza una costosa emulazione dell'intero sistema. Nella terza categoria, infine, rientrano FirmSolo, FirmGuide ed Ecmo. FirmSolo rappresenta un sistema scalabile ed automatizzato che si concentra sull'analisi del codice kernel-level. L'obiettivo è quello di applicare una forma di reverse-engineering alla configurazione del kernel cosicchè può essere caricato correttamente e successivamente analizzato. FirmGuide, al contrario, si basa su una tecnica detta "esecuzione del kernel guidata dal modello", combina cioè le astrazioni periferiche nel kernel Linux e le interazioni kernel-periferica per generare in modo semiautomatico modelli periferici che vengono poi utilizzati per sintetizzare nuove macchine QEMU per avviare l'analisi dinamica. Ecmo, analogamente a Surgeon, prevede la transplantation delle periferiche, processo indipendente dai dispositivi e funzionante verso il kernel Linux senza la necessità di utilizzare il codice sorgente. In questo modo, invece di aggiungere manualmente il supporto all'emulazione di varie periferiche in QEMU, è possibile trapiantare i driver delle periferiche designate nel kernel. Il testing e l'analisi dei vari tools ha designato FirmAE come il framework su cui verticalizzare essendo completo, ben strutturato e ricco di references ed issues. Nonostante i numerosi vantaggi, l'emulazione del firmware risulta essere estremamente impegnativa a causa delle incongruenze tra ambiente reale ed emulato. L'assenza di un giusto focus sulle richieste alle periferiche durante l'emulazione potrebbe causare diversi problemi nel kernel e nelle applicazioni all'interno del firmware emulato e, di conseguenza, nessuna emulazione ulteriore nè l'analisi dinamica può procedere correttamente.
|
Abstract
Firmware is a specific software component designed and installed directly by the manufacturer in the embedded device for which it was written, such as routers, IP cameras, gateways, etc.
In recent years, these devices have gained widespread popularity, resulting in a growing attention from researchers for device security.
System emulation and firmware re-hosting have become popular techniques to address various security measures and performance constraints.
In this work, some of the main frameworks for firmware emulation and re-hosting are analyzed, describing in detail their components, their functionalities and the technical limitations encountered during the testing phase on the reference case study, the firmware of the Tenda CP3 IP camera.
The main causes that hinder emulation are highlighted and, where possible, the potential resolution paths to overcome the identified problems.
The tools that have been analyzed and tested can be divided into three main categories: full system emulation, user-level emulation and kernel-level emulation.
The first category includes FirmAE and Surgeon.
FirmAE, based on Firmadyne, adopts a technique called "arbitrary emulation" whereby, instead of strictly following the execution behavior of the firmware, it follows an approach halfway between the original context and the injection of appropriate interventions, thus creating not an environment identical to the device but in an environment favorable to dynamic analysis.
Surgeon represents the first general-purpose re-hosting tool for MCU firmware.
The focus of this framework is on the use of the transplant technique, a new re-hosting technique in which the firmware is executed at the native speed of the host CPU.
The second category includes Greenhouse, in this case the focus is shifted to the emulation that surrounds a single firmware service, thus ensuring the benefits of high execution fidelity without expensive emulation of the entire system.
Finally, the third category includes FirmSolo, FirmGuide and Ecmo.
FirmSolo represents a scalable and automated system that focuses on code analysis at the kernel level.
The goal is to apply a form of reverse-engineering to the kernel configuration so that it can be loaded correctly and subsequently analyzed.
FirmGuide, on the other hand, is based on a technique called "model-driven kernel execution", that is, it combines peripheral abstractions in the Linux kernel and kernel-peripheral interactions to semi-automatically generate peripheral models that are then used to synthesize new QEMU machines to begin dynamic analysis.
Ecmo, similarly to Surgeon, provides for peripheral transplantation, a device-independent process that runs on the Linux kernel without the need for source code.
In this way, instead of manually adding emulation support for various peripherals in QEMU, it is possible to transplant the drivers for the designated peripherals into the kernel.
Testing and analysis of the various tools has designated FirmAE as the framework on which to build, since it is complete, well-structured and rich in references and issues.
Despite the many advantages, firmware emulation is extremely challenging due to the inconsistencies between the real and emulated environments.
The lack of proper focus on the requests to peripherals during emulation could cause several problems in the kernel and applications within the emulated firmware and, as a result, no further emulation nor dynamic analysis can proceed properly.
|