Keep Evaluation Fair: Detecting Data Leakage in Code Generation Benchmarks via Membership Inference Attacks
On the map: LLM safety and security → Machine unlearning
Abstract (arXiv)
Code generation benchmarks are widely used to evaluate Large Language Models (LLMs), but benchmark data leakage into training sets can inflate performance and undermine evaluation validity. DetectLeak, a method specifically designed for code generation benchmark leakage detection, relies on perplexity scores to identify likely leaked samples. However, perplexity mainly reflects general familiarity with code patterns and may perform poorly on complex or rare samples. It also overlooks other useful signals, such as code similarity, functional correctness, and semantic representations. To address these limitations, we propose CGMIA (Code-Generation-specific Membership Inference Attack), a method for detecting leakage in code generation benchmarks. CGMIA fine-tunes a shadow model on a subset of benchmark samples to construct labeled member and non-member data. For each sample, it collects the input prompt, generated code, and reference solution, and extracts expert features, including CodeBLEU, edit distance, test pass rate, and perplexity, together with semantic features from CodeBERT embeddings. An integrated learning module combines these features to capture both surface-level memorization signals and deeper behavioral patterns, enabling a classifier to predict whether a sample was included in the target model's training set. Experiments on eight code generation benchmarks show that CGMIA outperforms eight existing membership inference methods in most cases. It also effectively detects known leaked APPS samples in StarCoder-7B's training data.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Machine unlearning, one of 12 directions in LLM safety and security. Builds on 33 of its 64 references that are in the map. First posted on arXiv 9 Sep 2026.
Builds on
33 of 64 references.
References · 33
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2016Membership Inference Attacks against Machine Learning Modelscited by 2,281
- 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineeringcited by 1,737
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2019ROCKET: Exceptionally fast and accurate time series classification using random convolutional kernelscited by 339
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2024Leak, Cheat, Repeat: Data Contamination and Evaluation Malpractices in Closed-Source LLMscited by 229
- 2022Multi-lingual Evaluation of Code Generation Modelscited by 159
- 2024CodeGemma: Open Code Models Based on Gemmacited by 150
- 2024A Comprehensive Survey of Small Language Models in the Era of Large Language Models: Techniques, Enhancements, Applications, Collaboration with LLMs, and Trustworthinesscited by 127
21 more
- 2022Execution-Based Evaluation for Open-Domain Code Generationcited by 91
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?cited by 91
- 2019Membership Inference Attacks on Sequence-to-Sequence Models: Is My Data In Your Machine Translation System?cited by 71
- 2024Quantifying Contamination in Evaluating Code Generation Capabilities of Language Modelscited by 65
- 2024Cheating Automatic LLM Benchmarks: Null Models Achieve High Win Ratescited by 45
- 2018The Impact of Automated Parameter Optimization on Defect Prediction Modelscited by 38
- 2025LessLeak-Bench: A First Investigation of Data Leakage in LLMs Across 83 Software Engineering Benchmarkscited by 37
- 2024EvoCodeBench: An Evolving Code Generation Benchmark with Domain-Specific Evaluationscited by 34
- 2022Execution-based Evaluation for Data Science Code Generation Modelscited by 32
- 2024On Leakage of Code Generation Evaluation Datasetscited by 32
- 2023Data Portraits: Recording Foundation Model Training Datacited by 30
- 2023Traces of Memorisation in Large Language Models for Codecited by 29
- 2024ComplexCodeEval: A Benchmark for Evaluating Large Code Models on More Complex Codecited by 19
- 2023Gotcha! This Model Uses My Code! Evaluating Membership Leakage Risks in Code Modelscited by 15
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 14
- 2024Does Your Neural Code Completion Model Use My Code? A Membership Inference Approachcited by 11
- 2020TransMIA: Membership Inference Attacks Using Transfer Shadow Trainingcited by 9
- 2024Software Vulnerability Prediction in Low-Resource Languages: An Empirical Study of CodeBERT and ChatGPTcited by 9
- 2024Sifting through the Chaff: On Utilizing Execution Feedback for Ranking the Generated Code Candidatescited by 6
- 2025Next Edit Prediction: Learning to Predict Code Edits from Context and Interaction Historycited by 3
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 1
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026SERSEM: Selective Entropy-Weighted Scoring for Membership Inference in Code Language Models
- 2024Benchmarking Benchmark Leakage in Large Language Models
- 2025Dynamic Benchmarking of Reasoning Capabilities in Code Large Language Models Under Data Contamination
- 2023TrojanedCM: A Repository of Trojaned Large Language Models of Code
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs
- 2025Mitigating Sensitive Information Leakage in LLMs4Code through Machine Unlearning
- 2025A Mixture of Linear Corrections Generates Secure Code
- 2026Detecting Functional Memorization in Code Language Models