面向正则表达式引擎系统性测试的探索
Towards the Systematic Testing of Regular Expression Engines
AI总结:
ReTest框架通过语法感知模糊测试和元测试方法系统性测试正则表达式引擎,提升覆盖率并发现新缺陷。
摘要:
软件工程师在各种领域和任务中广泛使用正则表达式(regexes)。为了支持regexes,软件项目必须集成了一个regex引擎,无论是由语言运行时原生提供(如Python的re)还是作为外部依赖包含(如PCRE)。然而,这些引擎可能包含bug并引入漏洞。测试regex引擎的常见策略是差分测试——比较不同实现的输出。然而,这种方法令人担忧,因为regex语法和语义在不同方言(如POSIX与PCRE)之间差异显著。模糊测试也被用于简化测试功能丰富的regex实现以暴露缺陷,但朴素的字节级变异生成语法无效的输入,只测试解析逻辑,而不是匹配内部。在本工作中,我们描述了我们朝着ReTest框架的进展,该框架通过结合语法感知的模糊测试以实现高代码覆盖率和元测试来生成方言无关的测试 oracle 系统性测试正则表达式引擎。迄今为止,我们已调查了22个正则表达式引擎的测试实践,分析了1,007个正则表达式引擎bug和156个CVE,以表征失败模式,并整理了16个从Kleene代数导出的正则表达式的元测试关系。我们的初步评估显示,ReTest在PCRE上实现了比现有模糊测试方法高3倍的边缘覆盖率,并已识别出三个新的内存安全缺陷。最后,我们描述了我们的下一步,朝着我们的最终目标:帮助正则表达式引擎开发人员识别bug而不需要依赖一致的跨实现标准。
英文摘要:
Software engineers use regular expressions (regexes) across a wide range of domains and tasks. To support regexes, software projects must integrate a regex engine, whether provided natively by the language runtime (e.g., Python's re) or included as an external dependency (e.g., PCRE). However, these engines may contain bugs and introduce vulnerabilities. A common strategy for testing regex engines involves differential testing -- comparing outputs across different implementations. However, this approach is concerning because regex syntax and semantics vary significantly between dialects (e.g., POSIX vs. PCRE). Fuzzing is also utilized to ease testing of feature-rich regex implementations to expose defects, but naive byte-level mutations generate syntactically invalid inputs that exercise only parsing logic, not matching internals. In this work, we describe our progress towards ReTest, a framework that systematically tests regular expression engines by combining grammar-aware fuzzing for high code coverage with metamorphic testing to generate dialect-independent test oracles. So far, we have surveyed testing practices across 22 regex engines, analyzed 1,007 regex engine bugs and 156 CVEs to characterize failure modes, and curated 16 metamorphic relations for regexes derived from Kleene algebra. Our preliminary evaluation on PCRE shows that ReTest achieves 3x higher edge coverage than existing fuzzing approaches and has identified three new memory safety defects. We conclude by describing our next steps toward our ultimate goal: helping regex engine developers identify bugs without depending on a consistent cross-implementation standard.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。