Try   HackMD

CinfoFuzz: Fuzzing Method Based on Web Service Correlation Information of Embedded Devices

Abstract

  • 嵌入式設備的 Web 服務容易受攻擊
    • 現有的 Fuzzing 無法有效分析
  • 提出 Wsci-ed 這個方法,去針對嵌入式設備 Web 做Fuzzing
    • 工具名為 CinfoFuzz
  • 與 Boofuzz 和 Peach 比較有更好效率

Introduction

  • Fuzzing 是最廣泛使用的漏洞挖掘技術
  • 物聯網設備的安全性越來越重要,尤其是 Web 服務的漏洞很多
  • 因為牽扯到前端與後端,現有的工具無法有效分析漏洞
  • 現有的 Fuzzing 和模擬雖然提供後端狀態,但因為只涵蓋程序狀態的一小部分,導致誤報
    • Fuzzing (IoTFuzzer, SRFuzzer)
    • 模擬 (Firmadyne, Firmae, Avatar, FirmAFL)
  • 靜態分析的方式依賴前端與後端的關鍵字,也可能包含誤報
    • KARONTE
    • SaTC
  • 本文提出 Web 服務的 Fuzzing 方式 -- Wsci-ed
    • 包含前後端數據流關鍵字(DFK, Data Flow Keywords)
    • 關鍵字對應的後段敏感函數路徑(SFCP, Sensitive Function Call Path)
    • 基於關鍵字分析與路徑生成,實現了 CinfoFuzz

Problem Description

  • Fuzzer 在生成 test case 時需要考慮模型完整性
    • Web 的就必須符合相關格式等等
  • 一般的 Fuzzer 很難直接生成出物聯網設備的 payload
  • 此外,跨 binary 的崩潰也無法被偵測到
  • 總結來說,現在嵌入式的 Web Fuzzer 有兩個問題
    • test case 生成的不夠好
    • 缺乏有效的監控機制

Fuzzing Method Based on Web Service Correlation Information of Embedded Devices

  • 基於 SaTC 的分析提出了新方法 Wsci-ed
  • 預先對設備的韌體做動態與靜態分析
  • CinfoFuzz 使用 Wsci-ed 的 DFK 生成 test case
  • CinfoFuzz 使用 Wsci-ed 的 SFCP 定位崩潰點並實施有效監控
  • CinfoFuzz 分為三個部分
    • DFK-A
    • SFCP-G
    • Fuzzing 引擎

Data Flow Keyword Analysis

  • 該部分的主要目的是取得 DFK
  • 先透過靜態分析取得所有前端關鍵字
  • 在後端對關鍵字與可打印的字串做匹配
  • 依照匹配數量做排序,且服務於前端交互文件(Inter-bin) 的關鍵字排最前面
  • 最後動態模擬整理出 DFK

  • 前端的關鍵字在後端有兩種用途
    • 參數關鍵字,如 deviceName
    • API 關鍵字,如 goform/setUsbUnload
  • 動態模擬時會將靜態的結果先根據文件做分類
    • HTML
    • XML
    • JS
  • 然後透過正規表達式與語法樹提取關鍵字,並過濾特定關鍵字
    • 過濾特殊字元,如 "$" "@" "!" 等
    • 過濾隱藏的屬性
    • 過濾 tag,如 <title> <head> 等
  • 因為可能無法明確分別關鍵字屬於參數還是 API,需要利用動態去執行
    • QEMU 進行全系統模擬
    • Selenium 模擬使用者與 Web 互動
    • Mitmproxy 攔截訊息

Sensitive Function Call Path Generation

  • 該部分的主要目的是輸入 DFK,取得 SFCP
  • 使用動態汙點分析
    • 不從程式的入口點,而是請求 API 開始分析
    • 減少路徑
  • API 入口點分為兩種
    • 直接引用,就是直接引用關鍵字
    • 跨程式引用,透過 NVRAM 傳遞,需要注意 NVRAM 或 ENV 相關 function
  • 使用 Ghidra 的 P-Code 去實現

Fuzzing Engine

  • 經過前面的元件,得到 Wsci-ed 後,要利用這些東西去變異與反饋 Fuzzer
  • 監控程式崩潰的部分使用敏感函數插樁法 (Sensitive Function Instrumentation Method, SFIM)
  • 變異的部分繼承 BooFuzz 原來的變異方法
    • 把封包拆成不同的部分去變異
  • 檢測時使用 gdb + gdbserver,其中 gdb-multiarch 可支援多架構
    • gdb 中的 follow-fork-mode 可以監控多 Processes
    • 設定規則後,如果 gdb 發現程式執行狀態都符合就是提供訊號給 fuzzer
  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
    • 在 target device 上執行 gdbserver,並將 inter-bin attach 上去
    • 在 host 執行 gdb 並將插樁腳本執行,連線到 gdbserver 上面遠端測試
    • 執行中的程式觸發到腳本設定的條件後,gdb 會將程式 hang 並將執行狀態回傳
    • crash 時 gdbserver 會退出 attach 狀態,gdb 會將當下的狀態 dump 成文件

Design and Implementation

  • 基於上述方法,設計了 CinfoFuzz (Correlation information Fuzz)
  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 關鍵字分析模組會將韌體解包並做靜態與動態分析
    • 靜態提取 DFK,動態分類 DFK
  • 路徑生成模組輸入 DFK,利用 Ghidra 輸出 SFCP
  • 執行引擎模組又分為兩塊
    • Test case 生成模組從前面得到關鍵字並變異
    • Feedback 模組會對 SFCP 做動態檢測,發生碰撞或崩潰時回引導 Fuzzer

Evaluate

  • 實驗環境
    • Kali 2020.4 64-bit OS
    • Intel® Core i59600KF CPU @ 3.70GHz
    • memory size 24GB
  • 比較對象
    • Peach
      • 第一個開源的模糊測試工具
    • Boofuzz
      • CinfoFuzz 繼承他的 test case 生成方式,可以比較兩者性能
  • 資料集包含 4 家廠商的 4 種韌體
    • Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →

Coverage Evaluation

  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 因為 Peach 和 Boofuzz 原本都沒辦法在嵌入式設備中執行,因此都加上了對敏感函數觸發的支援
  • 本個程式跑兩小時
    • 不包含前面分析的時間
  • 只看敏感函數的路徑,平均而言
    • 覆蓋率上,CinfoFuzz 比 Boofuzz 高 25.7%,比 Peach 高 29.6%
    • 覆蓋速度(?)上,CinfoFuzz 比 Boofuzz 快 28.4%,比 Peach 快 33.7%
  • 前面分析越久,Fuzzing 時的效率會提升越多

Vulnerability Mining Application

  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 都只有找到已知漏洞,但他數量最多
  • 能找到較多漏洞的兩個主要原因
    • DFK 可以生成更豐富的 test case
      • 例如在不插入 USB 設備時,無法交互出 deviceName 的數據,但 DFK 直接包含該字串
    • SFCP 支援跨 processes 的漏洞
      • 但其實僅限同個一 process fork 出來的
  • Fuzzing
    • Boofuzz
    • Fw-fuzz
    • PS-Fuzz
  • 靜態分析
    • KARONTE
    • SaTC

Conclusion

  • 提出基於 Wsci-ed 的 Fuzzing 方式
    • 提供豐富的 test case
    • 有效的監控機制
  • 實作 CinfoFuzz
    • 與現有工具相比效率更好,找到的漏洞更多
tags: paper