Depth Gives a False Sense of Privacy: LLM Internal States Inversion

Tian Dong, Yan Meng, Shaofeng Li, Guoxing Chen, Zhen Liu, Haojin ZhuarXiv 2025

TL;DR

This paper shatters the assumption that the deep internal states of Large Language Models (LLMs) are safe from privacy leaks due to abstraction and information loss. The authors introduce four novel inversion attacks capable of reconstructing exact user prompts—including a 4,112-token medical prompt with 86.88% token matching—from intermediate model layers. Furthermore, they demonstrate that standard defenses like quantization, dropout, and differential privacy fail to mitigate this risk without severely degrading model utility.

What Problem Does This Paper Address?

As LLMs grow massive, running them entirely on local devices becomes impractical. To protect data privacy, researchers have proposed collaborative inference, where shallow layers run locally on a user's device, and the resulting intermediate representations—called Internal States (ISs)—are sent to the cloud to finish processing. Because deep layers handle highly abstract concepts, it was widely assumed that these internal states were mathematically irreversible "black boxes" that safely hid the original input text.

This paper challenges that assumption. The authors investigate whether an adversary (like a curious cloud server or a third-party safety auditor) can invert these internal states to fully reconstruct sensitive user queries, exposing severe privacy vulnerabilities in distributed LLM architectures.

Methods

The authors propose a framework spanning both white-box (known weights) and black-box (unknown weights) settings, utilizing optimization-based and generation-based techniques.

Figure 2: Overview procedure of our attacks. Depending on the model access, the adversary can adopt our optimization- based or generation-based attacks to achieve attack goals.

1. White-box Optimization Attacks

Instead of searching the massive token dictionary directly, the authors use a two-phase approach: first reconstructing continuous embeddings, then mapping them back to tokens.

  • Embedding Recovery (ER): Designed for shallow layers, ER directly optimizes a dummy embedding by minimizing the distance between its generated internal states and the target internal states.
  • Token Basis Selection (TBS): In deep layers, ER fails due to exploding gradients. TBS stabilizes the optimization by decomposing the input embedding space using Singular Value Decomposition (SVD) or an unbiased basis. Instead of optimizing the entire embedding space, it optimizes weights across a dramatically smaller set of basis vectors, bypassing local minima.
Figure 4: Intuition behind our TBS inversion attack. Instead of directly selecting candidate tokens from a large dictionary, our TBS attack optimizes weights among much fewer singular basis vectors (e.g., vi, vj and vk) to restore the candidate input embeddings (e.g.,⃗v).

2. Black-box Attacks

  • Model Type Identification & Replication: Since many production LLMs are fine-tuned or merged variants of open-source models, the authors train an ensemble of autoencoders to identify the target model's base architecture from its internal states. Once identified, they replicate the target model via distillation and apply their white-box attacks.
  • Generation-based Inversion: If the model is entirely closed-source, they treat inversion as a machine translation task. They train an encoder-decoder model (T5) paired with a custom projection module that aligns the target model's internal states with the encoder's embedding space.

Datasets

The attacks were evaluated across short and long contexts using six prominent LLMs (including Llama-2, Llama-3, and Qwen2.5) on the following datasets:

  • Instruction-2M & NoRobots: General instruction-following datasets used for short-context testing and black-box surrogate training.
  • Aimedical & Mentalhealth: Privacy-sensitive healthcare consulting datasets containing long-context dialogues.
  • Evolcode & CodeparrotApps: Coding assistance datasets used to test structured, long-context prompts.

Key Insights and Ideas

  • Uniform Layer Width is a Vulnerability: Unlike traditional classification networks where layer width shrinks with depth (creating an information bottleneck), modern Transformer architectures maintain a uniform layer width. This architectural choice accidentally preserves enough information in deep layers to allow successful inversion.
  • Attention Bias Amplifies Risk: The authors discovered that models utilizing QKV bias (like Qwen2.5) are significantly easier to invert than those without it (like Llama-3). The bias term appears to amplify feature representations within the internal states, inadvertently aiding the attacker.
  • Gradient Stabilization is Key: Directly optimizing embeddings in deep layers causes gradient explosion. By switching the optimization target to the coefficients of an orthogonal basis (TBS), the gradient norms remain stable across deep layers, making deep-layer inversion mathematically viable.
Figure 6: Distribution of gradient norm ∥bw∥2 and ∥bz∥2 for ER and TBS attacks, respectively.

Key Results

  • Long-Context Reconstructions: From the middle layer (L=16) of Llama-3-8B-Instruct, the TBS attack successfully inverted a 4,112-token medical prompt, achieving a 97.88% F1 token matching score and a 95.19% semantic similarity score.
  • Domain-Specific Vulnerability: Qwen2.5-Coder proved highly vulnerable; the TBS attack achieved an Exact Match (EM) rate of 64% on long coding prompts.
  • Defense Failures: The authors tested four common defenses applied to internal states: quantization (4-bit/8-bit), dropout, noisy input embeddings, and Laplacian Differential Privacy (DP). None provided adequate protection; adding enough noise or DP obfuscation to stop the attack simultaneously destroyed the LLM's utility, reducing its benchmark performance to random guesswork.

Limitations and Future Work

  • Hyperparameter Sensitivity: The optimization-based attacks (TBS) are highly sensitive to learning rates and initialization strategies. Bad hyperparameter tuning can cause the optimization to diverge or get stuck in local minima.
  • Time Complexity: The optimization process scales linearly with the number of steps, leading to high computational overhead and longer attack times for massive models (e.g., 70B parameters).
  • Future Directions: The authors suggest exploring advanced denoising techniques to bypass DP-based defenses and investigating architecture-based mitigations, such as designing LLMs with varying layer widths to enforce true information loss in deeper layers.

Summary updated

BibTeX
@misc{dong2025depth,
  author = {Tian Dong and Yan Meng and Shaofeng Li and Guoxing Chen and Zhen Liu and Haojin Zhu},
  title = {{Depth Gives a False Sense of Privacy: LLM Internal States Inversion}},
  year = {2025},
  eprint = {2507.16372},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.16372},
}
Figure