arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2409.09288cs.CRcs.SE
收藏

使用LLM生成API参数安全规则以检测API误用

Generating API Parameter Security Rules with LLM for API Misuse Detection

Jinghua Liu, Yi Yang, Kai Chen, Miaoqian Lin

AI总结:

提出GPTAid框架,利用LLM分析API源码自动生成参数安全规则,通过执行反馈和差分分析过滤验证,在200个API数据集上精确率达92.3%,并发现210个未知安全漏洞。

摘要:

在本文中,我们提出了一种名为GPTAid的新框架,通过使用LLM分析API源代码来自动生成APSRs,并检测由不正确的参数使用引起的API误用。为了验证LLM生成的APSRs的正确性,我们提出了一种基于执行反馈的检查方法,该方法的观察依据是:安全关键的API误用通常由APSRs违反引起,且其中大多数会导致运行时错误。具体来说,GPTAid首先使用LLM生成原始的APSRs和正确的调用代码,然后通过使用LLM修改正确的调用代码来为每个原始APSR生成违反代码。随后,GPTAid对每段违反代码进行动态执行,并根据运行时错误进一步过滤掉不正确的APSRs。为了进一步生成具体的APSRs,GPTAid采用代码差分分析来细化过滤后的APSRs。特别是,由于编程语言比自然语言更精确,GPTAid通过差分分析识别违反代码中的关键操作,然后基于上述操作生成相应的具体APSR。这些具体的APSRs可以被精确地解释为可应用的检测代码,并已被证明在API误用检测中是有效的。在包含从八个流行库中随机选择的200个API的数据集上实现时,GPTAid达到了92.3%的精确率。此外,在先前报告的漏洞和APSRs的比较数据集上,它生成的APSRs数量是最先进的检测器的6倍。我们进一步在47个应用程序上评估了GPTAid,发现了210个未知的安全漏洞,这些漏洞可能导致严重的安全问题(例如系统崩溃),其中150个在我们报告后已被开发者确认。

英文摘要:

In this paper, we present a new framework, named GPTAid, for automatic APSRs generation by analyzing API source code with LLM and detecting API misuse caused by incorrect parameter use. To validate the correctness of the LLM-generated APSRs, we propose an execution feedback-checking approach based on the observation that security-critical API misuse is often caused by APSRs violations, and most of them result in runtime errors. Specifically, GPTAid first uses LLM to generate raw APSRs and the Right calling code, and then generates Violation code for each raw APSR by modifying the Right calling code using LLM. Subsequently, GPTAid performs dynamic execution on each piece of Violation code and further filters out the incorrect APSRs based on runtime errors. To further generate concrete APSRs, GPTAid employs a code differential analysis to refine the filtered ones. Particularly, as the programming language is more precise than natural language, GPTAid identifies the key operations within Violation code by differential analysis, and then generates the corresponding concrete APSR based on the aforementioned operations. These concrete APSRs could be precisely interpreted into applicable detection code, which proven to be effective in API misuse detection. Implementing on the dataset containing 200 randomly selected APIs from eight popular libraries, GPTAid achieves a precision of 92.3%. Moreover, it generates 6 times more APSRs than state-of-the-art detectors on a comparison dataset of previously reported bugs and APSRs. We further evaluated GPTAid on 47 applications, 210 unknown security bugs were found potentially resulting in severe security issues (e.g., system crashes), 150 of which have been confirmed by developers after our reports.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑