桥接代码属性图与语言模型以进行程序分析 Bridging Code Property Graphs and Language Models for Program Analysis 预印本

⚠️ 本文为 预印本(arXiv 公开版本),尚未经过正式同行评审。作者自发公开,结论未经期刊审稿验证,阅读时请知悉。
发布时间:2026-03-25
👁️ 预览文献
💡 AI 中文简介
该研究针对大语言模型在分析真实代码库安全漏洞时面临的令牌限制、代码嵌入无法捕捉跨过程数据流以及难以生成复杂静态分析查询等挑战,提出了codebadger——一个开源模型上下文协议服务器,将Joern的代码属性图引擎与LLM集成。它提供程序切片、污点跟踪、数据流分析和语义代码导航等高级工具,无需LLM生成复杂查询。通过三个用例验证:审计8000方法代码库的内存安全模式、发现并利用libtiff中未报告的缓冲区溢出、首次尝试即为libxml2整数溢出漏洞生成正确补丁。
领域软件安全与程序分析
适合谁读需要一定专业背景(软件安全、程序分析或LLM应用开发者)
核心贡献1. 提出codebadger,将代码属性图引擎与LLM集成,通过高级工具实现跨过程分析,避免LLM生成复杂查询。2. 在真实代码库中验证了漏洞发现与补丁生成的有效性,包括发现未报告的libtiff缓冲区溢出和首次尝试修复libxml2整数溢出。
关键数据1. 成功审计8000个方法的代码库;2. 发现libtiff中未报告的缓冲区溢出;3. 首次尝试即为libxml2的CVE-2025-6021生成正确补丁。
推荐理由如果你关注LLM在真实代码安全分析中的落地,这篇工作展示了如何用代码属性图弥补LLM的不足,并在实际漏洞挖掘和修复中取得了硬核成果,值得一读。
关键词["代码属性图", "大语言模型", "程序分析", "漏洞检测", "模型上下文协议", "静态分析"]

原文摘要

查看英文原文摘要

Large Language Models (LLMs) face critical challenges when analyzing security vulnerabilities in real world codebases: token limits prevent loading entire repositories, code embeddings fail to capture inter procedural data flows, and LLMs struggle to generate complex static analysis queries. These limitations force existing approaches to operate on isolated code snippets, missing vulnerabilities that span multiple functions and files. We introduce codebadger, an open source Model Context Protocol (MCP) server that integrates Joern's Code Property Graph (CPG) engine with LLMs. Rather than requiring LLMs to generate complex CPG queries, codebadger provides high level tools for program slicing, taint tracking, data flow analysis, and semantic code navigation, enabling targeted exploration of large codebases without exhaustive file reading. We demonstrate its effectiveness through three use cases: (1) navigating an 8,000 method codebase to audit memory safety patterns, (2) discovering and exploiting a previously unreported buffer overflow in libtiff, and (3) generating a correct patch for an integer overflow vulnerability (CVE-2025-6021) in libxml2 on the first attempt. codebadger enables LLMs to reason about code semantically across entire repositories, supporting vulnerability discovery, patching, and program comprehension at scale.