FirmCure: Toward Autonomous Adaptive Rehosting of Linux FirmwareFirmCure:Towards Autonomous and Adaptive Rehosting of Linux-Based Firmware
The authors propose FirmCure, an LLM-driven firmware rehosting framework, achieving a 100% port openness rate and a 90.5% service interaction rate on 21 IoT firmware samples, which the authors state outperforms existing baselines.
- Full-system rehosting of Linux firmware is critical for security analysis, but the specialized architectures and hardware-dependent configurations of custom devices cause initialization and runtime obstacles, and existing methods rely on manual intervention and have low rehosting efficiency.
- The authors propose FirmCure, an LLM-driven three-stage closed-loop framework: Adaptive Perception Inference statically extracts firmware dependencies, Reflective Synthesis iteratively repairs boot configurations, and Autonomous Runtime Intervention uses multiple agents to repair runtime failures in real time.
- On 21 firmware images (10 vendors, 5 architectures), FirmCure achieves a 100% port-open rate and a 90.5% service interaction rate; the baselines FirmAE, Greenhouse, and Firmwell have interaction rates of 9.5%, 9.5%, and 19.0%, respectively; it reproduces 10 known CVEs and discovers 5 unknown vulnerabilities.
- The authors point out: the kernel replacement strategy cannot analyze vulnerabilities that depend on the original kernel or dedicated hardware; the LLM may hallucinate or fall into repetitive reasoning, and XIAOMI AX9000 and Netgear XR500 did not reach full interaction within 45 minutes; the evaluation covers only 21 firmware images, and the cost experiment uses only GLM-5.1.
- Benchmarks
- 21 个 IoT 固件镜像(10 家厂商、5 种架构)
- Metrics
- Kernel BootNetwork ConnectivityService Port AvailabilityService Interactivitytoken 消耗与时间成本
FirmCure is an LLM-driven full-system rehosting framework for Linux firmware, and the authors call it the first autonomous adaptive rehosting framework. It uses adaptive perception reasoning to extract structural dependencies, reflective synthesis to optimize configurations, and autonomous runtime intervention to fix errors; on 21 IoT firmware images from 10 vendors and 5 architectures, it achieves a 100% port-open rate and 90.5% service interactivity, surpassing SOTA baselines, and it reproduces known vulnerabilities and discovers new defects.
Paper analysis
What problem does this paper attempt to solve?
Addresses the problem that initialization and runtime obstacles in full-system rehosting of Linux firmware rely on manual effort and are inefficient.
Core problem: full-system rehosting of Linux firmware, when faced with customized devices, produces numerous initialization and runtime obstacles due to dedicated architectures and hardware-dependent configurations; existing methods struggle to handle these automatically, rely on expert intervention, and rehosting is inefficient.
- Scenario and importance: firmware rehosting is the foundation of dynamic analysis platforms; full-system rehosting preserves kernel interactions and runtime context and is suitable for system-level vulnerability analysis. The authors cite data stating that IoT devices are expected to exceed 50 billion by 2035, of which Linux firmware accounts for 58%.
- Shortcomings of existing methods: the authors consider the core obstacle to be the highly case-specific and scenario-dependent nature of the problem. First, complete initialization is difficult to achieve; existing methods execute init routines blindly as a black box, and the failure of any unrelated process can deadlock the entire initialization. Second, fault repair relies on manual effort or preset rules; FirmAE's fixed heuristic strategies and Greenhouse's predefined interventions cover only failures the designers have seen. Third, existing LLM methods (such as FlexEmu) are used only for static knowledge extraction (such as peripheral modeling) and lack runtime tool collaboration.
- Core observation: the authors' analysis of more than 100 firmware images states that rehosting failures are highly heterogeneous and cascade throughout the boot lifecycle, manifesting as staged obstacles (Table I gives 6 representative cases, covering four stages: kernel boot, root filesystem mount, user-mode initialization, and service runtime).
- What the paper proposes: the authors propose FirmCure, which they state is the first LLM-driven full-system rehosting framework, comprising three sequential modules — Adaptive Perception Inference, Reflective Synthesis, and Autonomous Runtime Intervention — forming a closed-loop pipeline.
- Problem scope: targets Linux embedded firmware on common IoT architectures, via QEMU full-system rehosting; the goal is to ensure network services (such as httpd, sshd) are interactive to support downstream security tasks; success is defined as the service starting, listening on the expected port, and responding to requests (Section IV-A).
What related research exists?
Related work falls into three groups: hardware-dependent layer replacement, peripheral modeling, and LLM-assisted firmware analysis; the baselines are FirmAE, Greenhouse, and Firmwell.
Hardware-dependent layer replacement
- Firmadyne [10] — introduced a custom kernel with NVRAM emulation for Linux firmware and is the pioneer of the kernel replacement strategy.
- FirmAE [11] — improves the boot rate through arbitrated emulation, distilling five predefined arbitration strategies from 437 firmware images; the paper notes that this static rule-based approach cannot adapt to unseen crashes or cascading dependencies.
- HALucinator [43] — replaces HAL calls for RTOS firmware; the paper notes that such methods work when hardware interfaces are library-based but fail for direct register-level interactions.
Peripheral modeling
- Hardware-in-the-loop methods [44]–[47] forward peripheral accesses to real devices; symbolic execution methods [48]–[52] symbolize peripheral values to infer constraints; specification-driven methods [53] use NLP to extract rules from datasheets; fuzzing methods [54], [55] mutate MMIO without an explicit model; behavior-equivalence models [56], [57] abstract peripherals into generic categories.
- FlexEmu [21] — uses an LLM to synthesize MCU peripheral models from driver source code; the paper notes that it shows LLMs can reduce manual effort, but existing LLM work remains confined to specific stages such as peripheral modeling.
LLM-assisted firmware analysis
- The paper cites progress in LLM code understanding [25]–[27], tool use [28]–[30], external knowledge bases [31], and autonomous agents [32], [33], as well as reasoning paradigms such as ReAct [22], Reflexion [23], and CoT [24], as the basis for FirmCure's agent design.
- Housefuzz [34] — service-aware greybox fuzzing for Linux firmware; the paper states that the deep reverse-engineering step of the A.P.I module on tightly coupled binaries (such as system_manager and ncc) was inspired by it.
Baselines and benchmark: the experiments compare three baselines — FirmAE (full-system rehosting), Greenhouse, and Firmwell (user-mode rehosting); the evaluation set is 21 IoT firmware images built by the authors (10 vendors, 5 architectures).
The authors position FirmCure as a complement to, rather than a replacement for, existing rehosting methods such as Firmadyne, FirmAE, Greenhouse, and Firmwell, targeting complex scenarios that static heuristics are insufficient to handle (Section VII).
How does the paper address this problem?
FirmCure uses three LLM agent modules to form a closed-loop pipeline: perception extracts dependencies, reflection synthesizes a bootable environment, and multi-agent runtime intervention.
Overall approach: FirmCure organizes rehosting as an LLM-guided closed-loop pipeline, in which three sequential modules share a cross-stage semantic context (Structured System Context Object), and all operations converge on a centralized QEMU instance for execution and verification (Figure 1).
Adaptive Perception Inference (A.P.I)
- The input is the extracted firmware rootfs, and the Firmware Analyst Agent produces a Structured System Context Object containing the CPU architecture, web service entry points, the initialization dependency graph, and a verified boot configuration.
- Three-stage pipeline: first reverse engineering and basic profiling (ELF headers, filesystem layout, strings, to determine architecture, endianness, and libc variant, and to locate httpd and its compile-time parameters); then init sequence analysis and hardware dependency decoupling (parsing rcS, inittab, profile, and reconstructing the full boot chain); finally context synthesis, generating a minimal boot script with zero hardware probing.
- Hardware dependency classification uses two mechanisms: prompt constraints encoding domain knowledge (flagging processes such as watchdog and wireless-related processes that easily deadlock in QEMU) and programmatic binary analysis (symbol tables, syscall patterns, log string matching).
- For binaries such as system_manager and ncc that are tightly coupled with services and also carry hardware probing, an additional deep reverse engineering step is added, producing a semantic dependency summary (what it provides, how it starts, minimal substitute logic), and a suppression list is kept for regression insertion in the A.R.I stage.
Reflective Synthesis (R.S)
- The Boot Repair Engineer Agent turns the context object into a bootable QEMU instance: rather than enumerating configurations from scratch, it synthesizes the initial boot command directly from the context object, and then takes a stable user-space shell prompt appearing on the serial port as the sole success signal.
- Before boot, filesystem preprocessing is performed: injecting missing configurations (such as /etc/passwd), deploying an NVRAM virtualization library, rebuilding broken symbolic links, fixing permissions, and packaging the hardware-decoupled boot script; for the problem that LD_PRELOAD is unreliable on stripped uClibc/musl, a dual-path library intervention is used (LD_PRELOAD or injecting DT_NEEDED via an ELF DYNAMIC segment patch).
- Two design constraints for iterative refinement: each round proposes only one targeted modification (QEMU parameters or filesystem patches, not both at once), making effects attributable and preventing over-correction; the agent does not reason from thin air but forms hypotheses using a knowledge base mapping failure features to root causes, and verifies with tools before modifying. The loop is capped at 5 iterations.
- Handling is split into two types by when the failure occurs: failures before the kernel reaches user space are handled by QEMU parameter correction (e.g., adding -cpu 74Kf for WAVLINK NU516U1); failures after the kernel handoff are handled by filesystem repair (adding shared libraries, fixing symbolic links, changing permission masks). Each step is recorded in a persistent repair history to avoid loops.
Autonomous Runtime Intervention (A.R.I)
- Layered multi-agent architecture: the Manager Agent only observes and routes and does not perform repairs (a misdiagnosis will not damage the running instance); failures are routed to expert agents by system layer and category; those that cannot be classified go to the Diagnosis Agent for deeper disambiguation.
- Four experts: CrashExpert uses GDB breakpoint chains to bypass hardware presence checks at runtime (without binary patching); FileExpert fixes missing files, symbolic links, and permissions; WebExpert diagnoses in order the web root directory permissions, the CGI interpreter path, and httpd hardcoded paths; GenericExpert serves as a fallback for unseen cross-domain failures and records new patterns after success.
- Sequential failure handoff: fix one failure at a time and re-evaluate system state after each step, decomposing compound failures into a sequence of single-domain repairs (the paper gives an example: httpd first bypasses a crash via CrashExpert, then has its configuration added via FileExpert, and finally has its compile-time path fixed via WebExpert).
- Cross-firmware knowledge reuse: verified repair traces are indexed into a library by failure category and architectural context; subsequent firmware first queries for matches by a similarity threshold, and on a hit, reuses the repair directly after lightweight verification.
Implementation
- The prototype is about 16,000 lines of Python, using CrewAI's Flow module to orchestrate the three-stage pipeline as an event-driven state machine; domain knowledge is injected via JSON-structured knowledge files through CrewAI's StringKnowledgeSource.
- It provides 7 types of specialized tools (radare2 static analysis, GDB remote debugging, debugfs disk image operations, QEMU lifecycle management, filesystem operations, network testing, multi-layer verification), with the tool set filtered for each expert via EXPERT_TOOL_MAP; LLMs are accessed through the LiteLLM gateway, and QEMU emulation currently supports ARM and MIPS variants. Appendices C and D give the role and task prompts for each agent.
What experiments did the paper conduct?
Comparing three baselines on 21 firmware images, FirmCure achieves a 100% port-open rate and a 90.5% interaction rate, and reproduces 10 CVEs and discovers 5 new vulnerabilities.
Experimental setup
- Dataset: 21 representative IoT firmware images from 10 major vendors, covering 5 architectures, with device types including routers and cameras; all images were publicly obtained from vendor websites.
- Baselines: FirmAE (full-system rehosting), Greenhouse, and Firmwell (user-mode rehosting).
- Metrics: four progressive metrics — Kernel Boot (kernel boots and mounts the root filesystem), Network Connectivity (network stack is available and obtains a valid IP), Service Port Availability (the web service binds to the expected listening port), Service Interactivity (can handle stateful HTTP requests, such as authentication, configuration reads, and CGI execution).
- Cross-paradigm handling: Greenhouse and Firmwell bypass kernel initialization, so their first two stages are merged into the Execute metric (user-mode service startup and runtime binding); each baseline is evaluated only on the stages natively supported by its architecture.
- Environment: a server cluster with Intel Xeon Gold 6248R @ 3.00GHz and 320GB RAM; the maximum execution time per firmware sample is 45 minutes.
- Cost experiment: token and time costs were measured on 6 representative samples using GLM-5.1, priced at $1.4 per million input tokens and $0.26 per million output tokens.
Main results
According to Table II (21 firmware images; FirmAE reports Ker./Net./Port/Inter., Greenhouse and Firmwell report Exe./Port/Inter.):
Swipe horizontally to read the table
Tool Stage 1 Stage 2 Port Inter. FirmAE Ker. 76.2% Net. 71.4% 14.3% 9.5% Greenhouse Exe. 66.7% — 9.5% 9.5% Firmwell Exe. 61.9% — 19.0% 19.0% FirmCure Ker. 100.0% Net. 100.0% 100.0% 90.5% - The authors state that FirmCure is the only tool that systematically advances beyond the early execution stages on all architectures, with all 21 samples reaching the listening port.
- Two samples did not reach full interaction: XIAOMI AX9000 (segmentation fault during HTTP request handling, depending on multiple proprietary daemons, with the root cause not locatable within the iteration budget) and Netgear XR500 (ubusd startup failure prevented CGI from communicating with the backend, and this remained unresolved in subsequent experiments).
- Per sample (Table II): FirmAE failed kernel boot on DGL-5500, DIR823X, NU516U1, Vigor3900, and AX9000; FirmCure stopped at the Port stage only on XR500 and AX9000.
Tiered analysis of intervention strategies (RQ2)
- What was measured: the boot process of all 21 firmware images was analyzed and divided into three levels by resolution stage (Table III gives representative cases; Appendix Table VI gives all 21).
- Results: Level 1 (A.P.I semantic decoupling) — 6 of the 21 samples booted directly to full interaction after the perception stage; Level 2 (R.S boot-time configuration and filesystem repair) — 3 samples required intervention at this stage; Level 3 (A.R.I expert agents) — 12 samples required it, with 26 targeted repairs in total, of which CrashExpert handled 4 cases, FileExpert 18 cases, WebExpert handled web-layer failures, and GenericExpert handled 2 unclassified failures.
- Authors' interpretation: the three levels form a progressive intervention spectrum, and removing any stage would leave its corresponding failure category unresolved; the authors state this validates the staged architecture.
Vulnerability reproduction and discovery (RQ3)
- What was measured: targeted PoC validation and semi-automated fuzzing on a set of router firmware images.
- Results: 10 known CVEs reproduced and 5 previously unknown vulnerabilities discovered (Table IV lists 15 entries). Tenda AC15 and WAVLINK NU516U1 could not be emulated by the three baselines; after FirmCure restored them to an interactive state, 7 CVEs were reproduced; on Totolink NR1800X, 3 CVEs were reproduced. All 5 new vulnerabilities are in Totolink N150RT: 2 buffer overflows (CVE-2025-3992/3993) and 3 stored XSS (CVE-2025-3994/3995/3996).
- Authors' interpretation: the authors state the results show that the closed-loop pipeline does not merely boot firmware but turns it into a reliable dynamic vulnerability discovery platform.
Efficiency and resource consumption (RQ4)
- Token cost (Table V, GLM-5.1): the A.P.I stage is a fixed baseline (input 557K–1,084K, output 18K–29K tokens); R.S and A.R.I are activated on demand. Wavlink WN531P3 has zero tokens in the latter two stages and costs $1.19; TRENDnet TEW-711BR and D-Link DGL5500 reach 1.09M–1.9M A.R.I input tokens, with total costs of $2.32–$3.74; the average across the 6 samples is about $2.18 per firmware.
- Time cost (Figure 2, GLM-5.1): the A.P.I stage takes about 520–850 seconds; R.S takes 21–88 seconds as a baseline when no intervention is needed and 156–370 seconds with active repair; A.R.I contributes 467–720 seconds when activated. Total duration ranges from about 13 minutes for Wavlink WN531P3 to about 27 minutes for D-Link DGL5500, and the authors state no firmware exceeded 30 minutes.
Other ablations and analyses
- The paper does not report an independent module ablation experiment (such as a comparison removing the knowledge base or the single-modification constraint); the three-level statistics in RQ2 (6/3/12 samples) are the only analysis of architectural contribution.
- Negative results: the ubus startup failure of XR500 persisted in subsequent experiments; the segmentation fault of AX9000 could not be root-caused within the limited intervention cycle (Section VI-B).
What are some points that can be further explored?
The authors point out two types of limitations, kernel replacement and LLM reliability; the evaluation covers 21 firmware images, and the cost experiment uses only GLM-5.1.
Limitations and future directions noted by the authors
- Analysis blind spots of kernel replacement (Section VIII Discussion): the framework automatically selects an approximately matching kernel to replace the original kernel, and cannot analyze vulnerabilities that strictly depend on the original kernel or on dedicated hardware (such as hardware cryptographic functions); the authors state this can be addressed by combining peripheral emulation techniques to reproduce dedicated hardware behavior.
- LLM reliability (Section VIII Discussion): the LLM may hallucinate or fall into repetitive reasoning loops, especially for complex or unfamiliar firmware logic; in the experiments, XIAOMI AX9000 and Netgear XR500 failed to reach full service interaction within the 45-minute time limit, and post-hoc analysis showed the agent spent much of its time in loops of ineffective fixes; for highly customized targets beyond the model's knowledge scope, rehosting ultimately fails. The authors state this can be mitigated with a knowledge base of firmware-specific solutions.
- Firmware unpacking (Section VIII Discussion): although not a core contribution, the authors integrated an iterative unpacking module combining ubireader, ubidump, and recursive binwalk extraction to handle complex formats such as UBI/UBIFS.
- Scalability (Section VIII Discussion): the evaluation focuses on home routers, IP cameras, and Linux IoT firmware; the authors state that the architecture-agnostic rehosting engine and modular peripheral abstraction can be adapted to other device categories such as smart home hubs, industrial control systems, and in-vehicle infotainment units, and can be integrated into vendor CI/CD, vulnerability discovery platforms, and compliance testing workflows.
- Diagnostic boundaries for complex firmware (Section VI-B): the authors state that the most complex modern firmware requires diagnostic cycles longer than the current time budget or deeper architectural knowledge, and note this as a direction for future improvement.
Experimental coverage
- The subjects under test are 21 IoT firmware images (10 vendors, 5 architectures), and the comparison baselines are FirmAE, Greenhouse, and Firmwell, 3 in total (Section VI-A, Table II).
- The cost and time experiments cover only 6 representative firmware samples and use only one model, GLM-5.1 (Section VI-E); the paper does not report which LLM was used in the other stages (RQ1–RQ3).
- The maximum execution time per firmware sample is 45 minutes; the paper does not report the number of repeated runs per sample.
- The vulnerability evaluation reproduces 10 known CVEs and discovers 5 new vulnerabilities, involving four devices: Tenda AC15, WAVLINK NU516U1, Totolink NR1800X, and Totolink N150RT (Table IV).
- The implementation currently supports QEMU emulation of ARM and MIPS variants (Section V).
Summarize the main content of the paper
FirmCure is an LLM-driven three-stage firmware rehosting framework, achieving a 100% port-open rate and a 90.5% interaction rate on 21 firmware images, which the authors state outperforms the baselines.
A systems paper in the direction of firmware security analysis, addressing the problem that initialization and runtime obstacles in full-system rehosting of Linux firmware rely on manual effort and are difficult to scale.
- Problem: the dedicated architectures and hardware-dependent configurations of customized devices prevent existing methods (FirmAE's fixed heuristics, Greenhouse's predefined interventions, Firmwell's reactive repair) from automatically handling unseen failures; the authors' analysis of more than 100 firmware images states that failures are highly heterogeneous and cascade across boot stages.
- Method: FirmCure forms a closed loop with three LLM agent modules — A.P.I statically parses firmware and decouples hardware dependencies to generate a minimal boot context; R.S repairs boot configurations through an iterative loop with a single modification per round and knowledge-base constraints (capped at 5 rounds); A.R.I uses a Manager plus four expert agents, Crash/File/Web/Generic, for runtime failure routing and repair, and reuses repair knowledge across firmware.
- Main results: on 21 firmware images (10 vendors, 5 architectures), FirmCure achieves 100% in all three stages Kernel/Network/Port and a 90.5% service interaction rate; the baselines FirmAE, Greenhouse, and Firmwell have interaction rates of 9.5%, 9.5%, and 19.0%, respectively (Table II).
- Security value: reproduces 10 known CVEs (including 7 on Tenda AC15 and WAVLINK NU516U1, which none of the three baselines could emulate) and discovers 5 previously unknown vulnerabilities on Totolink N150RT (2 buffer overflows, 3 stored XSS).
- Cost: on 6 samples with GLM-5.1, the average cost is about $2.18 per firmware, and end-to-end time is about 13–27 minutes; the authors state no sample exceeded 30 minutes.
- Authors' conclusions and limitations: the authors state that LLM agents open a new direction for adaptive autonomous dynamic analysis of embedded systems; they also acknowledge that kernel replacement cannot analyze vulnerabilities that depend on the original kernel or dedicated hardware, and that LLM hallucination and repetitive reasoning caused XIAOMI AX9000 and Netgear XR500 to fail to reach full interaction within 45 minutes.