一句话:提出用 CFG 过近似程序 API 调用序列并做语言包含检查与精化,验证上下文无关 API 协议使用。
许多实际库(如可重入锁、GUI 框架、序列化库)要求客户端按上下文无关规范调用 API。本文提出验证此类 API 协议正确用法的技术:用上下文无关文法(CFG)过近似程序可行的 API 调用序列,并检查其与规范的语言包含。由于 CFG 抽象可能不精确,作者提出精化方法,从包含查询反例中向文法引入新非终结符和产生式,同时保持过近似。在工具 CFPChecker 中实现,并在 10 个使用至少一个上下文无关 API 的流行 Java 应用上评估。结果显示,它能验证正确客户端的 API 使用、为错误客户端产生反例;与三个基线相比,可验证现有工具无法触及的安全属性。
Several real-world libraries (e.g., reentrant locks, GUI frameworks, serialization libraries) require their clients to use the provided API in a manner that conforms to a context-free specification. Motivated by this observation, this paper describes a new technique for verifying the correct usage of context-free API protocols. The key idea underlying our technique is to over-approximate the program’s feasible API call sequences using a context-free grammar (CFG) and then check language inclusion between this grammar and the specification. However, since this inclusion check may fail due to imprecision in the program’s CFG abstraction, we propose a novel refinement technique to progressively improve the CFG. In particular, our method obtains counterexamples from CFG inclusion queries and uses them to introduce new non-terminals and productions to the grammar while still over-approximating the program’s relevant behavior. We have implemented the proposed algorithm in a tool called CFPChecker and evaluate it on 10 popular Java applications that use at least one API with a context-free specification. Our evaluation shows that CFPChecker is able to verify correct usage of the API in clients that use it correctly and produces counterexamples for those that do not. We also compare our method against three relevant baselines and demonstrate that CFPChecker enables verification of safety properties that are beyond the reach of existing tools.
@article{paperbot1145,
title = {Verifying correct usage of context-free API protocols},
author = {Kostas Ferles and Jon Stephens and Isil Dillig},
journal = {Proceedings of the ACM on Programming Languages},
volume = {5},
number = {POPL},
year = {2021},
doi = {10.1145/3434298}
}