arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2208.07833cs.CR
收藏

您的固件告诉您的不是您应该如何仿真它:固件仿真的规范指导方法(扩展版)

What Your Firmware Tells You Is Not How You Should Emulate It: A Specification-Guided Approach for Firmware Emulation (Extended Version)

Wei Zhou, Lan Zhang, Le Guan, Peng Liu, Yuqing Zhang

摘要:

由于缺乏外围设备模型,模拟微控制器的固件具有挑战性。现有的工作找出如何响应外设读操作,通过分析目标固件。这是有问题的,因为固件有时不包含足够的线索来支持仿真,甚至包含误导信息(例如,有缺陷的固件)。在这项工作中,我们提出了一种新的方法,从外围规格建立外围模型。使用NLP,我们将人类语言中的外围行为(记录在芯片手册中)翻译成一组结构化的条件-动作规则。通过在运行时检查、执行和链接它们,我们可以为每个固件执行动态地合成外围设备模型。提取的条件-动作规则可能不完整,甚至是错误的。因此,我们建议结合象征性的执行,以快速查明根本原因。这有助于我们手动纠正有问题的规则。我们已经实现了我们的想法,五个流行的MCU板跨越三个不同的芯片供应商。使用一种新的基于编辑距离的算法来计算跟踪差异,我们对大型固件语料库的评估证实,与最先进的解决方案相比,我们的原型实现了更高的保真度。受益于准确的仿真,我们的仿真器有效地避免了在现有的模糊工作中观察到的误报。我们还设计了一个新的动态分析方法来执行驱动程序代码符合性检查规范。我们发现了一些不合规的情况,后来证实是由竞争条件引起的bug。

英文摘要:

Emulating firmware of microcontrollers is challenging due to the lack of peripheral models. Existing work finds out how to respond to peripheral read operations by analyzing the target firmware. This is problematic because the firmware sometimes does not contain enough clues to support the emulation or even contains misleading information (e.g. buggy firmware). In this work, we propose a new approach that builds peripheral models from the peripheral specification. Using NLP, we translate peripheral behaviors in human language (documented in chip manuals) into a set of structured condition-action rules. By checking, executing, and chaining them at runtime, we can dynamically synthesize a peripheral model for each firmware execution. The extracted condition-action rules might not be complete or even be wrong. We, therefore, propose incorporating symbolic execution to quickly pinpoint the root cause. This assists us in the manual correction of the problematic rules. We have implemented our idea for five popular MCU boards spanning three different chip vendors. Using a new edit-distance-based algorithm to calculate trace differences, our evaluation against a large firmware corpus confirmed that our prototype achieves much higher fidelity compared with state-of-the-art solutions. Benefiting from the accurate emulation, our emulator effectively avoids false positives observed in existing fuzzing work. We also designed a new dynamic analysis method to perform driver code compliance checks against the specification. We found some non-compliance which we later confirmed to be bugs caused by race conditions.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑