Lune

USENIX Security2023Top-tier venue

Detecting API Post-Handling Bugs Using Code and Description in Patches

Miaoqian Lin, Kai Chen, Yang Xiao

Abstract

Program APIs must be used in accordance with their specifications. API post-handling (APH) is a common type of specification that deals with APIs' return checks, resource releases, etc. Violation of APH specifications (aka, APH bug) could cause serious security problems, including memory corruption, resource leaks, etc. API documents, as a good source of APH specifications, are often analyzed to extract specifications for APH bug detection. However, documents are not always complete, which makes many bugs fail to be detected. In this paper, we find that patches could be another good source of APH specifications. In addition to the code differences introduced by patches, patches also contain descriptions, which help to accurately extract APH specifications. In order to make bug detection accurate and efficient, we design API specification-based graph for reducing the number of paths to be analyzed and perform partial path-sensitive analysis. We implement a prototype named APHP (API Post-Handling bugs detector using Patches) for static detection of APH bugs. We evaluate APHP on four popular open-source programs, including the Linux kernel, QEMU, Git and Redis, and detect 410 new bugs, outperforming existing state-of-the-art work. 216 of the bugs have been confirmed by the maintainers, and 2 CVEs have been assigned. Some bugs have existed for more than 12 years. Till now, many submitted patches have been backported to long-term stable versions of the Linux kernel.

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.

7 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • KNighter: Transforming Static Analysis with LLM-Synthesized Checkers cites Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences
  • 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 Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis
  • 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 Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis
  • BugAuditor: Detecting Bugs via Inconsistent Defensive Code Auditing cites VUDDY: A Scalable Approach for Vulnerable Code Clone Discovery
  • BugAuditor: Detecting Bugs via Inconsistent Defensive Code Auditing cites Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences
  • Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis cites APISan: Sanitizing API Usages through Semantic Cross-Checking
  • Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis cites Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences
  • Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation Analysis cites Automatically Detecting Error Handling Bugs Using Error Specifications
  • Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences cites SemFuzz: Semantics-based Automatic Generation of Proof-of-Concept Exploits
  • Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints Inferences cites Automatically Detecting Error Handling Bugs Using Error Specifications
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers7

  1. One Bug, Hundreds Behind: LLMs for Large-Scale Bug DiscoveryQiushi Wu, Yue Xiao, Dhilung Kirat, Kevin Eykholt et al.ICML 2026 · 5 citations
  2. KNighter: Transforming Static Analysis with LLM-Synthesized CheckersChenyuan Yang, Zijie Zhao, Zichen Xie, Haoyu Li et al.SOSP 2025 · 1 citation
  3. VulInstruct: Teaching LLMs Root-Cause Reasoning for Vulnerability Detection via Security SpecificationsHao Zhu, Jia Li, Cuiyun Gao, Jiaru Qian et al.FSE 2026
  4. BugAuditor: Detecting Bugs via Inconsistent Defensive Code AuditingMiaoqian Lin, Kai Chen, Hao ChenUSENIX Security 2026
  5. Uncovering the iceberg from the tip: Generating API Specifications for Bug Detection via Specification Propagation AnalysisMiaoqian Lin, Kai Chen, Yi Yang, Jinghua LiuNDSS 2025

Builds on18

  1. VUDDY: A Scalable Approach for Vulnerable Code Clone DiscoverySeulbae Kim, Seunghoon Woo, Heejo Lee, Hakjoo OhS&P 2017 · 388 citations
  2. SemFuzz: Semantics-based Automatic Generation of Proof-of-Concept ExploitsWei You, Peiyuan Zong, Kai Chen, XiaoFeng Wang et al.CCS 2017 · 148 citations
  3. APISan: Sanitizing API Usages through Semantic Cross-CheckingInsu Yun, Changwoo Min, Xujie Si, Yeongjin Jang et al.USENIX Security 2016 · 107 citations
  4. Detecting Missing-Check Bugs via Semantic- and Context-Aware Criticalness and Constraints InferencesKangjie Lu, Aditya Pakki, Qiushi WuUSENIX Security 2019 · 97 citations
  5. Automatically Detecting Error Handling Bugs Using Error SpecificationsSuman Jana, Yuan Jochen Kang, Samuel Roth, Baishakhi RayUSENIX Security 2016 · 79 citations

Related papers

  1. APICAD: Augmenting API Misuse Detection through Specifications from Code and DocumentsXiaoke Wang, Lei ZhaoICSE 2023 · 7 citations
  2. Detecting Missed Security Operations Through Differential Checking of Object-based Similar PathsDinghao Liu, Qiushi Wu, Shouling Ji, Kangjie Lu et al.CCS 2021 · 11 citations
  3. AURC: Detecting Errors in Program Code and DocumentationPeiwei Hu, Ruigang Liang, Ying Cao, Kai Chen et al.USENIX Security 2023
  4. Non-Distinguishable Inconsistencies as a Deterministic Oracle for Detecting Security BugsQingyang Zhou, Qiushi Wu, Dinghao Liu, Shouling Ji et al.CCS 2022 · 2 citations
  5. Inference of Error Specifications and Bug Detection Using Structural SimilaritiesNora Dossche, Bart CoppensUSENIX Security 2024 · 2 citations
Dusk over the sea between two cliffs drawn in fine vertical lines