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

  1. Do different types of PII exhibit varying degrees of learning difficulty during model training?
  2. Does the learning difficulty of different PII types affect their likelihood of being leaked during attack?
  3. 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:

  1. 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.

  2. 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.

  3. Training Dynamics Computation
    Measuring model learnability and difficulty on real PII data.

  4. 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.


Left: Structural causal model illustrating relationships between training dynamics and PII leakage risks. Right: Representative examples of heterogeneous PII types in real-world repositories.

Tech Stack: LoRA, PyTorch, Hugging Face, DoWhy, Causal Inference, Dataset Cartography

References

2025

  1. Understanding Privacy Risks in Code Models Through Training Dynamics: A Causal Approach
    Hua Yang, Alejandro Velasco, Sen Fang, and 2 more authors
    arXiv preprint arXiv:2512.07814, 2025