[论文解读] Gotcha! This Model Uses My Code! Evaluating Membership Leakage Risks in Code Models
本文提出了 Gotcha,一种专为代码模型设计的新型成员推理攻击,利用替代模型预测给定代码片段是否曾出现在训练数据中。该方法实现了 0.95 的高真正例率和 0.10 的低假正例率,揭示了在敏感代码(包括私有企业代码)上训练的代码模型存在严重的成员信息泄露风险。
Given large-scale source code datasets available in open-source projects and advanced large language models, recent code models have been proposed to address a series of critical software engineering tasks, such as program repair and code completion. The training data of the code models come from various sources, not only the publicly available source code, e.g., open-source projects on GitHub but also the private data such as the confidential source code from companies, which may contain sensitive information (for example, SSH keys and personal information). As a result, the use of these code models may raise new privacy concerns. In this paper, we focus on a critical yet not well-explored question on using code models: what is the risk of membership information leakage in code models? Membership information leakage refers to the risk that an attacker can infer whether a given data point is included in (i.e., a member of) the training data. To answer this question, we propose Gotcha, a novel membership inference attack method specifically for code models. We investigate the membership leakage risk of code models. Our results reveal a worrying fact that the risk of membership leakage is high: although the previous attack methods are close to random guessing, Gotcha can predict the data membership with a high true positive rate of 0.95 and a low false positive rate of 0.10. We also show that the attacker's knowledge of the victim model (e.g., the model architecture and the pre-training data) impacts the success rate of attacks. Further analysis demonstrates that changing the decoding strategy can mitigate the risk of membership leakage. This study calls for more attention to understanding the privacy of code models and developing more effective countermeasures against such attacks.
研究动机与目标
- 调查在公共和私有源代码上训练的代码模型中成员信息泄露的风险。
- 解决关于代码生成模型特定隐私漏洞的理解空白,特别是针对数据成员推理的隐私风险。
- 开发并评估一种针对代码模型的定向成员推理攻击方法,考虑到代码数据和模型行为的独特特性。
- 研究攻击者对目标模型(如架构、预训练数据)的知识程度如何影响成员推理攻击的成功率。
- 探索缓解策略,例如修改解码策略,以降低代码模型中的成员信息泄露风险。
提出的方法
- 该方法训练一个替代模型,以模仿目标代码模型在输入代码片段上的置信度分数。
- 利用替代模型的置信度分数,通过二分类任务区分训练数据与非训练数据。
- 该攻击利用模型预测置信度作为信号——对训练样本的更高置信度表明可能存在成员关系。
- 该方法在 CodeGPT(一种代码补全模型)上进行评估,使用来自公共和私有源的多样化代码片段。
- 在不同级别的攻击者知识条件下测试该攻击,包括对模型架构和预训练数据的完整了解。
- 通过修改解码策略(如温度采样和 top-k 采样)来评估其对降低成员信息泄露的影响。

实验结果
研究问题
- RQ1在混合公共和私有代码上训练的代码模型中,成员信息泄露的程度如何?
- RQ2与随机猜测或现有方法相比,成员推理攻击在代码模型上的有效性如何?
- RQ3攻击者对目标模型架构和预训练数据的了解程度如何影响成员推理攻击的成功率?
- RQ4能否通过修改代码生成模型中的解码策略来降低成员信息泄露风险?
- RQ5成员推理对在工业环境中使用的代码模型隐私有何影响?
主要发现
- Gotcha 实现了 0.95 的真正例率和 0.10 的假正例率,显著优于随机猜测和先前方法。
- 当攻击者对目标模型的架构和预训练数据有详细知识时,攻击的成功率显著提高。
- 即使目标模型是 CodeGPT 这类大规模代码生成模型,成员推理依然可行,表明存在严重的隐私风险。
- 通过修改解码策略(如使用更高的温度或 top-k 采样)可有效减少模型的置信度泄露,从而缓解成员推理风险。
- 本研究揭示,基于私有或敏感代码训练的代码模型易受成员推理攻击,对工业和企业应用构成严重隐私担忧。
- 本工作是首次系统性评估代码模型上的成员推理攻击,凸显了代码生成系统中一个此前被忽视但关键的隐私威胁。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。