arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.21822cs.PLcs.AIcs.SE
收藏

CNnotator: LLM引导的内存安全注释合成

CNnotator: LLM-Guided Memory Safety Annotation Synthesis

Carnegie Mellon University(卡内基梅隆大学);Galois, Inc.(Galois公司)

Twain Byrnes, Mike Dodds

AI总结:

提出CNnotator工具,利用大语言模型自动生成CN规范来标注C代码的内存使用模式,OpenAI o3模型首次尝试成功率达90%,表明AI辅助注释对实际C代码库可行。

摘要:

内存安全错误在C语言编写的系统安全漏洞中占很大比例;Java和Rust等现代语言因设计上内存安全而能防止此类错误。为了将系统迁移到更安全的语言或识别内存错误,我们必须首先确定遗留代码如何操作内存。这些信息在遗留代码中仅隐式表示。在许多情况下,内存使用模式对人类来说只是繁琐而非真正困难。在这项工作中,我们询问大语言模型(LLMs)是否可以通过让它们合成注释来表示内存使用作为CN(一种混合测试/验证工具)中的规范来执行此任务。我们的工具CNnotator使用LLMs自动生成和测试CN规范。我们发现当前模型能够为中小型C程序生成CN规范,其中OpenAI o3推理模型首次尝试成功率达到90%,总体成功率为97%,而聊天模型GPT-4o正确注释了65%的首次尝试。这些结果表明,AI辅助注释对于实际C代码库正变得实用。

英文摘要:

Memory safety errors account for a large proportion of security bugs in systems written in C; modern languages such as Java and Rust prevent such bugs because they are memory-safe by design. To migrate systems to safer languages or identify memory errors, we must first determine how legacy code manipulates memory. This information is only represented implicitly in such code. In many cases, memory usage patterns are merely tedious for humans to figure out, rather than truly difficult. In this work, we ask if large language models (LLMs) can perform this task by having them synthesize annotations representing memory usage as specifications in CN, a hybrid testing/verification tool. Our tool, CNnotator, uses LLMs to automatically generate and test CN specifications. We find that current models are able to generate CN specifications for small-to-medium C programs, with the OpenAI o3 reasoning model achieving a 90% success rate on first attempts and 97% overall success, while the chat model GPT-4o correctly annotates 65% of first attempts. These results suggest AI-assisted annotation is becoming practical for real-world C codebases.

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

↑