Probing Privacy Leaks in LLM-based Code Generation via Test Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Ge, Yifei, Chen, Zhenpeng, Sun, Weisong, Chen, Yuchen, Fang, Chunrong, Zhai, Juan, Zhang, Xiaofang, Feng, Xia, Liu, Yang, Chen, Zhenyu
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917496846548992
author Ge, Yifei
Chen, Zhenpeng
Sun, Weisong
Chen, Yuchen
Fang, Chunrong
Zhai, Juan
Zhang, Xiaofang
Feng, Xia
Liu, Yang
Chen, Zhenyu
author_facet Ge, Yifei
Chen, Zhenpeng
Sun, Weisong
Chen, Yuchen
Fang, Chunrong
Zhai, Juan
Zhang, Xiaofang
Feng, Xia
Liu, Yang
Chen, Zhenyu
contents The widespread availability of large-scale code datasets has fueled the rapid development of large language models (LLMs) for code-related tasks. These datasets may include sensitive personally identifiable information (PII), which can lead to privacy leakage when LLMs memorize and reproduce it. However, existing privacy-leakage detection methods rely on ad-hoc prompt construction (manually or automatically designed). Therefore, they do not adequately approximate the real-world contexts in which PII appears in code corpora, making it difficult to extract realistic privacy leakage. In this paper, we propose a pipeline that simulates practical privacy-related code generation scenarios and adopts a test-driven strategy to elicit the memorized information from the generated test cases. We further introduce an automatically constructed privacy feature library that replaces manual prompt engineering by providing realistic templates and examples to guide test case generation. Large-scale experiments on 5 widely used LLMs show that our pipeline exposes more confirmed privacy leakage, achieving a 2.56 times increase in detected leakage compared to existing baselines.
format Preprint
id arxiv_https___arxiv_org_abs_2605_15248
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Probing Privacy Leaks in LLM-based Code Generation via Test Generation
Ge, Yifei
Chen, Zhenpeng
Sun, Weisong
Chen, Yuchen
Fang, Chunrong
Zhai, Juan
Zhang, Xiaofang
Feng, Xia
Liu, Yang
Chen, Zhenyu
Software Engineering
Cryptography and Security
The widespread availability of large-scale code datasets has fueled the rapid development of large language models (LLMs) for code-related tasks. These datasets may include sensitive personally identifiable information (PII), which can lead to privacy leakage when LLMs memorize and reproduce it. However, existing privacy-leakage detection methods rely on ad-hoc prompt construction (manually or automatically designed). Therefore, they do not adequately approximate the real-world contexts in which PII appears in code corpora, making it difficult to extract realistic privacy leakage. In this paper, we propose a pipeline that simulates practical privacy-related code generation scenarios and adopts a test-driven strategy to elicit the memorized information from the generated test cases. We further introduce an automatically constructed privacy feature library that replaces manual prompt engineering by providing realistic templates and examples to guide test case generation. Large-scale experiments on 5 widely used LLMs show that our pipeline exposes more confirmed privacy leakage, achieving a 2.56 times increase in detected leakage compared to existing baselines.
title Probing Privacy Leaks in LLM-based Code Generation via Test Generation
topic Software Engineering
Cryptography and Security
url https://arxiv.org/abs/2605.15248