发现大模型训练数据中隐藏漏洞和版权风险,提出自动净化方法。
Cracks in The Stack: Hidden Vulnerabilities and Licensing Risks in LLM Pre-Training Datasets
- 利用开源项目版本历史自动识别可修复代码片段。
- 17%代码有更新版本,其中2.36%修复已知漏洞CVE。
- 适合关注AI生成代码安全与合规的开发者与研究者。
构建代码生成模型的关键在于在海量源代码和自然语言文本上进行预训练,但这些数据来源往往存疑或质量不佳,可能导致生成代码含缺陷或漏洞。尽管已有代码生成后检测漏洞的方法,更优策略是使用经过筛选、高质量且合规的数据进行预训练或微调。由于所需数据量巨大,需自动化数据清洗以减少人工干预。本文提出一种基于开源项目完整版本历史的自动化代码数据净化技术,通过追踪代码在各项目中的变更情况,识别出包含漏洞修复的代码样本。在The Stack v2数据集上的评估显示,17%的代码版本存在新版本,其中17%为修复版本,含2.36%解决已知CVE漏洞;去重后的Stack v2仍包含6,947个已知漏洞的代码块。此外,58%的代码块自创建后未被修改,可能代表低使用率软件。还存在误标代码来源问题,导致非宽松许可代码混入,带来严重合规风险。该方法有助于避免模型学习到错误代码模式或违反许可证。
原文摘要 · Abstract (English)
A critical part of creating code suggestion systems is the pre-training of Large Language Models on vast amounts of source code and natural language text, often of questionable origin or quality. This may contribute to the presence of bugs and vulnerabilities in code generated by LLMs. While efforts to identify bugs at or after code generation exist, it is preferable to pre-train or fine-tune LLMs on curated, high-quality, and compliant datasets. The need for vast amounts of training data necessitates that such curation be automated, minimizing human intervention. We propose an automated source code autocuration technique that leverages the complete version history of open-source software projects to improve the quality of training data. This approach leverages the version history of all OSS projects to identify training data samples that have been modified or have undergone changes in at least one OSS project, and pinpoint a subset of samples that include fixes for bugs or vulnerabilities. We evaluate this method using The Stack v2 dataset, and find that 17% of the code versions in the dataset have newer versions, with 17% of those representing bug fixes, including 2.36% addressing known CVEs. The deduplicated version of Stack v2 still includes blobs vulnerable to 6,947 known CVEs. Furthermore, 58% of the blobs in the dataset were never modified after creation, suggesting they likely represent software with minimal or no use. Misidentified blob origins present an additional challenge, as they lead to the inclusion of non-permissively licensed code, raising serious compliance concerns. By addressing these issues, the training of new models can avoid perpetuating buggy code patterns or license violations. We expect our results to inspire process improvements for automated data curation, with the potential to enhance the reliability of outputs generated by AI tools.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。