arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.08165cs.SEcs.AI
收藏

数秒内找到你!利用大语言模型进行代码作者归属识别

I Can Find You in Seconds! Leveraging Large Language Models for Code Authorship Attribution

University of Central Florida(中佛罗里达大学);Nanyang Technological University(南洋理工大学);Technical University of Munich(慕尼黑工业大学);Propulsion and Space Research Center, Technology Innovation Institute(技术创新研究所推进与空间研究中心)

Soohyeon Choi, Yong Kiam Tan, Mark Huasong Meng, Mohamed Ragab, Soumik Mondal, David Mohaisen, Khin Mi Mi Aung

AI总结:

针对传统代码作者归属方法泛化性差、大规模场景扩展性不足的问题,本文探索大语言模型在代码作者归属中的应用,提出锦标赛式大规模识别方法,在跨语言场景下取得有效结果,为相关领域应用提供新思路。

摘要:

源代码作者归属识别在软件取证、剽窃检测和软件补丁完整性保护中具有重要作用。现有技术通常依赖有监督机器学习,由于需要大量标注数据集,这类方法在跨不同编程语言和编码风格的泛化能力上存在不足。受近期基于大语言模型(LLM)的自然语言作者归属分析研究进展的启发——此类研究无需针对特定任务微调即可展现出优异性能,本文探索了将LLM应用于源代码作者归属识别的可行性。\n 我们开展了一项全面研究,证明当前最先进的LLM能够成功实现跨语言的源代码作者归属识别。LLM可通过零样本提示判断两段代码是否由同一作者编写,马修斯相关系数(MCC)达到0.78;还可通过小样本学习,从少量参考代码片段中识别代码作者,MCC达到0.77。此外,LLM对错误归属攻击表现出一定的对抗鲁棒性。\n 尽管具备上述能力,我们发现由于输入token限制,直接对LLM进行简单提示的方法在作者数量较多时扩展性不佳。为解决这一问题,我们提出了一种面向大规模归属识别的锦标赛式方法。在来自GitHub的C++(500名作者,26355个样本)和Java(686名作者,55267个样本)代码数据集上评估该方法,在每位作者仅提供1个参考样本的情况下,C++分类准确率最高达65%,Java最高达68.7%。这些结果为将LLM应用于网络安全和软件工程领域的代码作者归属识别开辟了新的可能。

英文摘要:

Source code authorship attribution is important in software forensics, plagiarism detection, and protecting software patch integrity. Existing techniques often rely on supervised machine learning, which struggles with generalization across different programming languages and coding styles due to the need for large labeled datasets. Inspired by recent advances in natural language authorship analysis using large language models (LLMs), which have shown exceptional performance without task-specific tuning, this paper explores the use of LLMs for source code authorship attribution. We present a comprehensive study demonstrating that state-of-the-art LLMs can successfully attribute source code authorship across different languages. LLMs can determine whether two code snippets are written by the same author with zero-shot prompting, achieving a Matthews Correlation Coefficient (MCC) of 0.78, and can attribute code authorship from a small set of reference code snippets via few-shot learning, achieving MCC of 0.77. Additionally, LLMs show some adversarial robustness against misattribution attacks. Despite these capabilities, we found that naive prompting of LLMs does not scale well with a large number of authors due to input token limitations. To address this, we propose a tournament-style approach for large-scale attribution. Evaluating this approach on datasets of C++ (500 authors, 26,355 samples) and Java (686 authors, 55,267 samples) code from GitHub, we achieve classification accuracy of up to 65% for C++ and 68.7% for Java using only one reference per author. These results open new possibilities for applying LLMs to code authorship attribution in cybersecurity and software engineering.

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

↑