Leveraging Semantic Relations in Code and Data to Enhance Taint Analysis of Embedded Systems

Jiaxu Zhao, Yuekang Li, Yanyan Zou, Zhaohui Liang, Yang Xiao, Yeting Li, Bingwei Peng, Nanyu Zhong, Xinyi Wang, Wei Wang, Wei HuoUSENIX Security 2024

TL;DR

This paper introduces LARA, a novel static taint analysis technique that significantly improves vulnerability detection in embedded IoT systems. By leveraging semantic relationships between code and data, specifically by categorizing user inputs as URIs or keys, LARA systematically identifies more vulnerabilities with fewer false positives than existing methods.

What Problem Does This Paper Address?

The proliferation of Internet of Things (IoT) devices has led to a surge in embedded system vulnerabilities, posing significant security risks. While static taint analysis is a promising technique for detecting these vulnerabilities, it struggles with comprehensively and accurately identifying "sources" – the entry points of user input. Existing methods often miss hidden or complex input handling mechanisms, leading to both missed vulnerabilities (false negatives) and incorrect alerts (false positives). This paper tackles the challenge of systematically and accurately identifying these sources in embedded systems, particularly those with web services.

Methods

LARA employs a novel approach that combines pattern-based static analysis with Large Language Model (LLM)-aided analysis. The core idea is inspired by the observation that user inputs in embedded systems can be categorized into URIs (Uniform Resource Identifiers) and keys (data parameters).

  • URI and Key Categorization: LARA first extracts URIs and keys from the frontend (web interface) of embedded devices. It then analyzes the backend code to identify how these URIs and keys are handled.
  • Pattern-based Analysis: This component simulates human expertise by using predefined rules and pattern matching to identify URI and key handling functions.
  • LLM-aided Analysis: This novel aspect leverages LLMs to understand the semantics of code, helping to identify functions that might be missed by pattern-based analysis alone. LLMs are particularly useful for understanding code context and inferring the purpose of functions, which can reduce false positives.
  • Combined Approach: LARA combines the results from both pattern-based and LLM-aided analyses. By taking the intersection of their findings, it can eliminate false positives from each method and achieve more accurate source identification.
  • Sink Extraction: LARA also includes a sophisticated sink extraction mechanism that identifies dangerous functions and their "wrapper functions" (functions that indirectly call dangerous functions), even if they reside in shared libraries.
  • Taint Analysis: Finally, LARA performs key-sensitive taint analysis using the identified sources and sinks to detect vulnerabilities.

Datasets

The evaluation was conducted on a dataset comprising 203 firmware samples from 21 vendors. This dataset was collected from various sources, including existing benchmarks like SATC, KARONTE, and FIRMAE, as well as real-world IoT devices. The dataset was chosen to cover a diverse range of device types and known vulnerabilities, with a specific focus on buffer overflow and command injection vulnerabilities. The authors also manually determined the URI binding code type and identified hidden data sources for a subset of the vulnerabilities.

Key Insights and Ideas

  • URIs and Keys as Semantic Units: The fundamental insight is that treating user inputs as distinct URIs and keys, and understanding their relationships, is crucial for systematic source identification. This goes beyond simply looking for common keywords.
  • LLMs for Code Semantics: LLMs are powerful tools for understanding the nuanced semantics of code, which traditional static analysis often misses. This capability is key to reducing false positives and identifying complex input handling.
  • Complementary Strengths of Pattern and LLM Analysis: Pattern-based analysis excels at identifying known code structures, while LLM-aided analysis can uncover less obvious patterns and understand context. Their combination effectively mitigates the weaknesses of each individual approach.
  • Importance of Wrapper Functions: Many vulnerabilities are hidden behind indirect calls through wrapper functions, often in shared libraries. Ignoring these wrappers leads to missed vulnerabilities, and LARA's approach to identifying them is a significant contribution.
  • Hidden Data is a Major Source of Vulnerabilities: A substantial portion of vulnerabilities (84 out of 645 in their dataset) were attributable to hidden data, highlighting the need for techniques that can uncover such inputs.

Key Results

  • Improved Vulnerability Detection: LARA detected 556 more known vulnerabilities than SATC and 602 more than KARONTE.
  • Reduced False Positives: LARA reduced false positives by 57.0% compared to SATC and 54.3% compared to KARONTE.
  • Enhanced EMTAINT: When used to provide sources and sinks, LARA enabled EMTAINT to detect 245 more vulnerabilities.
  • 0-Day Discoveries: LARA discovered 245 previously unknown (0-day) vulnerabilities in 57 devices, all of which were confirmed or fixed, with 162 CVE IDs assigned.
  • Source Extraction Efficiency: LARA extracted significantly more URIs (27,781) and keys (102,905) than SATC, with higher precision.
  • Sink Extraction Effectiveness: LARA identified 158 sink functions in 8 firmware samples with a precision of 93.7%.
  • Time Efficiency: LARA's analysis time was significantly lower than SATC and KARONTE, reducing overhead by 65.5% and 63.1%, respectively.

Limitations and Future Work

  • Disassembly Engine Dependency: The precision of LARA's analysis is dependent on the accuracy of the disassembly engine, which can sometimes struggle with complex programs or specific architectures.
  • Manual Ground Truth: The validation of vulnerabilities relies on manually confirmed ground truth, which can introduce potential errors.
  • Focus on HTTP: The current evaluation primarily focuses on vulnerabilities caused by the HTTP protocol, though the authors mention its adaptability to other key-value pair protocols.
  • Future Work: The authors suggest exploring adaptation to other protocols and further refining the taint analysis with more sophisticated checks for user input legitimacy. They also highlight the potential for LLMs in other areas of program analysis.

Summary updated

BibTeX
@inproceedings{zhao2024leveraging,
  author = {Jiaxu Zhao and Yuekang Li and Yanyan Zou and Zhaohui Liang and Yang Xiao and Yeting Li and Bingwei Peng and Nanyu Zhong and Xinyi Wang and Wei Wang and Wei Huo},
  title = {{Leveraging Semantic Relations in Code and Data to Enhance Taint Analysis of Embedded Systems}},
  booktitle = {USENIX Security},
  year = {2024},
  url = {https://openreview.net/forum?id=EQFn4OC0xD},
}
Figure