Privacy Risks of Personally Identifiable Information in LLMs4Code
Causal analysis of heterogeneous PII leakage risks in LLMs for Code
Aug 2025 โ Jan 2026 ยท Preprint (Yang et al., 2025)
Large Language Models for Code (LLMs4Code) have significantly enhanced developer productivity in real-world software engineering.
However, their reliance on open-source repositories (e.g., GitHub) introduces severe privacy risks, as these repositories contain abundant Personally Identifiable Information (PII) such as: key, username, email, password, name, and ip address.
Sensitive PII can be memorized during training and later resurfaced during inference, leading to critical privacy breaches. Prior studies have shown that commercial code completion models are indeed capable of reproducing sensitive PII, further exacerbating concerns about the trustworthiness and compliance of LLMs4Code in sensitive industries.
Nonetheless, existing work has largely treated PII as a homogeneous category, overlooking the heterogeneous risks posed by different PII types.
๐ Research Questions
- Do different types of PII exhibit varying degrees of learning difficulty during model training?
- Does the learning difficulty of different PII types affect their likelihood of being leaked during attack?
- What is the causal relationship between the learning dynamics of different PII types and their likelihood of being leaked during inference?
๐ ๏ธ Methodology
Our study follows a four-stage pipeline:
-
Dataset Construction
Building a high-quality dataset of 9,000 real-world code files across 6 PII types.
This combines regex-based filters, LLM-assisted judgments, heuristic rules, and expert verification. -
Model Fine-Tuning
Fine-tuning 6 code LLMs (3Bโ14B) across the Stable Code, CodeLlama, and Qwen2.5-Coder families to capture cross-family patterns. -
Training Dynamics Computation
Measuring model learnability and difficulty on real PII data. -
Causal Inference
Formulating a structural causal model to estimate the causal effect of learning difficulty on leakage, validated with multiple refutation strategies.
๐ Results
- Leakage risks vary significantly across PII types.
- Easy-to-learn instances (e.g., ip address) โ high leakage risks.
- Hard-to-learn instances (e.g., key, password) โ lower leakage frequency.
- Ambiguous types display complex dual effects.
This provides the first causal evidence that leakage risks differ by PII type, offering actionable insights for designing type-aware and learnability-aware defense mechanisms in LLMs4Code.
Tech Stack: LoRA, PyTorch, Hugging Face, DoWhy, Causal Inference, Dataset Cartography