arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.24837cs.CR
收藏

连接代码属性图与语言模型用于程序分析

Bridging Code Property Graphs and Language Models for Program Analysis

Qatar Computing Research Institute(卡塔尔计算机研究所)

Ahmed Lekssays

AI总结:

本文提出codebadger,结合Joern的代码属性图引擎与LLM,解决代码分析中的挑战,通过高级工具实现程序切片、污点追踪等,提升大规模代码库的分析能力。

摘要:

大型语言模型(LLM)在分析现实世界代码库中的安全漏洞时面临关键挑战:令牌限制阻止加载整个仓库,代码嵌入无法捕捉跨过程的数据流,且LLM难以生成复杂的静态分析查询。这些限制迫使现有方法仅能处理孤立代码片段,遗漏跨越多个函数和文件的漏洞。我们引入codebadger,一个开源的模型上下文协议(MCP)服务器,整合Joern的代码属性图(CPG)引擎与LLM。而非要求LLM生成复杂的CPG查询,codebadger提供高级工具用于程序切片、污点追踪、数据流分析和语义代码导航,使无需详尽文件阅读即可有针对性地探索大规模代码库。我们通过三个用例展示其有效性:(1)导航包含8000个方法的代码库以审计内存安全模式,(2)发现并利用此前未报告的libtiff缓冲区溢出漏洞,(3)生成正确补丁以修复libxml2中的整数溢出漏洞(CVE-2025-6021)。codebadger使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.

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

↑