Fuzzing is a popular bug detection technique achieved by testing software executables with random inputs. This technique can also be extended to libraries by constructing executables that call library APIs, known as fuzz drivers. Automated fuzz driver synthesis has been an important research topic in recent years since it can facilitate the library fuzzing process. Nevertheless, existing approaches generally ignore generic APIs or simply treat them as normal APIs. As a result, they cannot generate effective fuzz drivers for generic APIs. This paper studies the automated fuzz driver synthesis problem for Rust libraries with generic APIs. The problem is essential because Rust emphasizes security, and generic APIs are widely employed in Rust crates. Each generic API can have numerous monomorphic versions as long as the type constraints are satisfied. The critical challenge to this problem lies in prioritizing these monomorphic versions and providing valid inputs for them. To address the problem, we extend existing API-dependency graphs to support generic APIs. By solving such dependencies and type constraints, we can generate a collection of candidate monomorphic APIs. Further, we apply a similarity-based filter to prune redundant versions, particularly if multiple monomorphic APIs adopt the identical trait implementation. Experimental results with 29 popular open-source libraries show that our approach can achieve promising generic API coverage with a low rate of invalid fuzz drivers. Besides, we find 23 bugs previously unknown in these libraries, with 18 bugs related to generic APIs.
翻译:模糊测试是一种通过向软件可执行程序输入随机数据来检测漏洞的流行技术。该技术也可扩展至库函数测试:通过构建调用库API的可执行程序(即模糊测试驱动)实现。近年来,自动化模糊测试驱动合成已成为重要研究方向,因其可显著提升库函数模糊测试效率。然而,现有方法通常忽略泛型API,或将其简单视为普通API处理,导致无法为泛型API生成有效的模糊测试驱动。本文针对含泛型API的Rust库提出自动化模糊测试驱动合成方案。该问题具有重要研究价值,因为Rust语言强调安全性且泛型API在Rust crate中广泛使用。每个泛型API在满足类型约束条件下可生成大量单态化版本,关键在于如何对这些版本进行优先级排序并为其提供有效输入。为解决该问题,我们扩展了现有API依赖图以支持泛型API,通过解析依赖关系和类型约束生成候选单态API集合。进一步采用基于相似性的筛选机制,对采用相同trait实现的多个单态API进行冗余版本剪枝。基于29个主流开源库的实验结果表明,本方法在保持低无效模糊测试驱动率的同时,显著提升了泛型API覆盖率。此外,我们在这些库中发现23个未知漏洞,其中18个与泛型API相关。