Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis
Miaoqian Lin, Kai Chen, Yi Yang, Jinghua Liu
Abstract
Modern software often provides diverse APIs to facilitate development. Certain APIs, when used, can affect variables and require post-handling, such as error checks and resource releases. Developers should adhere to their usage specifications when using these APIs. Failure to do so can cause serious security threats, such as memory corruption and system crashes. Detecting such misuse depends on comprehensive API specifications, as violations of these specifications indicate API misuse. Previous studies have proposed extracting API specifications from various artifacts, including API documentation, usage patterns, and bug patches. However, these artifacts are frequently incomplete or unavailable for many APIs. As a result, the lack of specifications for uncovered APIs causes many false negatives in bug detection. In this paper, we introduce the idea of API Specification Propagation, which suggests that API specifications propagate through hierarchical API call chains. In particular, modern software often adopts a hierarchical API design, where highlevel APIs build on low-level ones. When high-level APIs wrap low-level ones, they may inherit the corresponding specifications. Based on this idea, we present APISpecGen, which uses known specifications as seeds and performs bidirectional propagation analysis to generate specifications for new APIs. Specifically, given the seed specifications, APISpecGen infers which APIs the specifications might propagate to or originate from. To further generate specifications for the inferred APIs, APISpecGen combines API usage and validates them using data-flow analysis based on the seed specifications. Besides, APISpecGen iteratively uses the generated specifications as new seeds to cover more APIs. For efficient and accurate analysis, APISpecGen focuses only on code relevant to the specifications, ignoring irrelevant semantics. We implemented APISpecGen and evaluated it for specification generation and API misuse detection. With 6 specifications as seeds, APISpecGen generated 7332 specifications. Most of the generated specifications could not be covered by state-of-the-art work due to the quality of their sources. With the generated specifications, APISpecGen detected 186 new bugs in the Linux kernel, 113 of them have been confirmed by the developers, with 8 CVEs assigned.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
2 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- One Bug, Hundreds Behind: LLMs for Large-Scale Bug Discovery cites APISan: Sanitizing API Usages through Semantic Cross-Checking
- One Bug, Hundreds Behind: LLMs for Large-Scale Bug Discovery cites Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences
- BugAuditor: Detecting Bugs via Inconsistent Defensive Code Auditing cites One Bug, Hundreds Behind: LLMs for Large-Scale Bug Discovery
- BugAuditor: Detecting Bugs via Inconsistent Defensive Code Auditing cites APISan: Sanitizing API Usages through Semantic Cross-Checking
- BugAuditor: Detecting Bugs via Inconsistent Defensive Code Auditing cites Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences
- Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences cites Automatically Detecting Error Handling Bugs Using Error Specifications
Cited by top-tier papers2
Builds on22
- APISan: Sanitizing API Usages through Semantic Cross-CheckingInsu Yun, Changwoo Min, Xujie Si, Yeongjin Jang et al.USENIX Security 2016 · 107 citations
- An empirical study on the effectiveness of static C code analyzers for vulnerability detectionStephan Lipp, Sebastian Banescu, Alexander PretschnerISSTA 2022 · 99 citations
- Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints InferencesKangjie Lu, Aditya Pakki, Qiushi WuUSENIX Security 2019 · 97 citations
- Automatically Detecting Error Handling Bugs Using Error SpecificationsSuman Jana, Yuan Jochen Kang, Samuel Roth, Baishakhi RayUSENIX Security 2016 · 79 citations
- API-Misuse Detection Driven by Fine-Grained API-Constraint Knowledge GraphXiaoxue Ren, Xinyuan Ye, Zhenchang Xing, Xin Xia et al.ASE 2020 · 62 citations
Related papers
- APICAD: Augmenting API Misuse Detection through Specifications from Code and DocumentsXiaoke Wang, Lei ZhaoICSE 2023 · 7 citations
- Detecting API Post-Handling Bugs Using Code and Description in PatchesMiaoqian Lin, Kai Chen, Yang XiaoUSENIX Security 2023
- Patch-Guided Vulnerability Detection: Extracting Java API Security Rules via Attack–Defense Cross-AnalysisBofei Chen, Shuang Liao, Lei Zhang, Chibin Zhang et al.USENIX Security 2026
- Inference of Error Specifications and Bug Detection Using Structural SimilaritiesNora Dossche, Bart CoppensUSENIX Security 2024 · 2 citations
- ARBITRAR: User-Guided API Misuse DetectionZiyang Li, Aravind Machiry, Binghong Chen, Mayur Naik et al.S&P 2021 · 30 citations
