Manuscript Offprint

arXiv:2609.09865

Keep Evaluation Fair: Detecting Data Leakage in Code Generation Benchmarks via Membership Inference Attacks

Dongdong Zhao, Jian Chen, Guancheng Lin, Jianwen Xiang, Jacky Wai Keung, Xiao Yu

DONGDONG ZHAO, School of Computer Science and Artificial Intelligence, Wuhan University of Technology, China

JIAN CHEN, School of Computer Science and Artificial Intelligence, Wuhan University of Technology, China

GUANCHENG LIN, Department of Computer Science, City University of Hong Kong, China

JIANWEN XIANG, Engineering Research Center of Transportation Information and Safety (ERCTIS), MoE of China, Wuhan University of Technology, China

JACKY WAI KEUNG, Department of Computer Science, City University of Hong Kong, China

XIAO YU ∗^{*}, State Key Laboratory of Blockchain and Data Security, Zhejiang University, China

To systematically evaluate code generation capabilities of Large Language Models (LLMs), numerous benchmarks have been developed. However, a critical concern is the potential leakage of benchmark data into LLM training sets, which can inflate model performance and undermine the validity of evaluations. To the best of our knowledge, DetectLeak is currently the only method specifically designed to detect leakage in code generation benchmarks. It relies solely on perplexity scores, assuming that samples with lower perplexity are more likely leaked. However, perplexity primarily reflects a model's general familiarity with common patterns and performs poorly on complex or rare samples. Moreover, DetectLeak overlooks other important features such as code similarity, functional correctness, and semantic embeddings of generated code, resulting in limited detection accuracy. To address the issues, we propose CGMIA (Code-Generation-specific Membership Inference Attack), a novel approach designed to detect data leakage in code generation benchmarks. CGMIA uses a shadow model fine-tuned on a subset of benchmark samples to mimic the target model's behavior, creating labeled data where fine-tuned samples are members and held-out samples are non-members. For each sample, it collects the input prompt, shadow model's generated code, and the reference solution, extracting both expert features (e.g., CodeBLEU, edit distance, test pass rate, perplexity) and semantic features from CodeBERT embeddings. These features are combined in an integrated learning module to capture surface-level memorization signals and deep behavioral patterns, enabling the classifier to accurately predict whether a sample was in the target model's training set. Extensive experiments on eight widely used code generation benchmarks show that CGMIA significantly outperforms eight existing membership inference methods in most cases, while also effectively detecting known leaked APPS samples in StarCoder-7B's training data.

∗^{*}Corresponding Author: Xiao Yu.

Authors' Contact Information: Dongdong Zhao, zdd@whut.edu.cn, School of Computer Science and Artificial Intelligence, Wuhan University of Technology, Wuhan, Hubei, China; Jian Chen, 321559@whut.edu.cn, School of Computer Science and Artificial Intelligence, Wuhan University of Technology, Wuhan, Hubei, China; Guancheng Lin, guanchlin4-c@my.cityu.edu.hk, Department of Computer Science, City University of Hong Kong, Hong Kong, China; Jianwen Xiang, jwxiang@whut.edu.cn, Engineering Research Center of Transportation Information and Safety (ERCTIS), MoE of China, Wuhan University of Technology, Wuhan, Hubei, China; Jacky Wai Keung, jacky.keung@cityu.edu.hk, Department of Computer Science, City University of Hong Kong, Hong Kong, China; Xiao Yu, xiao.yu@zju.edu.cn, State Key Laboratory of Blockchain and Data Security, Zhejiang University, Hangzhou, Zhejiang, China.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.

© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.

ACM 1557-7392/2026/5-ART1

https://doi.org/XXXXXXX.XXXXXXX

1:2

Dongdong Zhao et al.

CCS Concepts: • Software and its engineering → Empirical software validation.

Additional Key Words and Phrases: Large Language Model, Code Generation Benchmark, Leakage Detection

ACM Reference Format:

Dongdong Zhao, Jian Chen, Guancheng Lin, Jianwen Xiang, Jacky Wai Keung, and Xiao Yu. 2026. Keep Evaluation Fair: Detecting Data Leakage in Code Generation Benchmarks via Membership Inference Attacks. ACM Trans. Softw. Eng. Methodol. 1, 1, Article 1 (May 2026), 32 pages. https://doi.org/XXXXXXX.XXXXXXX

References (23)