RTFM! Automatic Assumption Discovery and Verification Derivation from Library Document for API Misuse Detection
Authors:
Open Access
- 30 October 2020
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 1837-1852
Abstract
To use library APIs, a developer is supposed to follow guidance and respect some constraints, which we call integration assumptions (IAs). Violations of these assumptions can have serious consequences, introducing security-critical flaws such as use-after-free, NULL-dereference, and authentication errors. Analyzing a program for compliance with IAs involves significant effort and needs to be automated. A promising direction is to automatically recover IAs from a library document using Natural Language Processing (NLP) and then verify their consistency with the ways APIs are used in a program through code analysis. However, a practical solution along this line needs to overcome several key challenges, particularly the discovery of IAs from loosely formatted documents and interpretation of their informal descriptions to identify complicated constraints (e.g., data-/control-flow relations between different APIs). In this paper, we present a new technique for automated assumption discovery and verification derivation from library documents. Our approach, called Advance, utilizes a suite of innovations to address those challenges. More specifically, we leverage the observation that IAs tend to express a strong sentiment in emphasizing the importance of a constraint, particularly those security-critical, and utilize a new sentiment analysis model to accurately recover them from loosely formatted documents. These IAs are further processed to identify hidden references to APIs and parameters, through an embedding model, to identify the information-flow relations expected to be followed. Then our approach runs frequent subtree mining to discover the grammatical units in IA sentences that tend to indicate some categories of constraints that could have security implications. These components are mapped to verification code snippets organized in line with the IA sentence's grammatical structure, and can be assembled into verification code executed through CodeQL to discover misuses inside a program. We implemented this design and evaluated it on 5 popular libraries (OpenSSL, SQLite, libpcap, libdbus and libxml2) and 39 real-world applications. Our analysis discovered 193 API misuses, including 139 flaws never reported before.Keywords
This publication has 20 references indexed in Scilit:
- Automated Analysis of Privacy Requirements for Mobile Apps2017
- Automatic generation of oracles for exceptional behaviors2016
- Hierarchical Attention Networks for Document Classification2016
- AutoCog2014
- Inferring method specifications from natural language API descriptions2012
- @tComment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies2012
- Mining API Error-Handling Specifications from Source Code2009
- /*icomment2007
- PR-Miner2005
- Shallow parsing with conditional random fields2003