Prompt Inference Attack on Distributed Large Language Model Inference Frameworks

Xinjian Luo, Ting Yu, Xiaokui Xiao · DOI

The Privacy Risks of Distributed LLM Inference

As Large Language Models (LLMs) grow in size, running them on consumer-grade hardware becomes increasingly difficult. Distributed inference frameworks, such as Petals, address this by splitting the model across multiple devices. In a typical setup, a client device processes the initial layers and sends intermediate sequence embeddings to a more powerful remote server to complete the inference.

Overview of the distributed LLM inference framework and the adversarial reconstruction attack.

However, this collaborative approach introduces a significant privacy risk. This research demonstrates that a malicious server can intercept these intermediate embeddings and reconstruct the user's original, private prompt token-by-token with up to 90% accuracy. This vulnerability exposes sensitive user data to any untrusted node in a decentralized AI network.

Attack Methodology

The researchers developed three distinct prompt inference attacks ($\mathcal{A}_1$, $\mathcal{A}_2$, $\mathcal{A}_3$) to evaluate vulnerability under different threat models, progressively tightening the attacker's resources:

  • $\mathcal{A}_1$ (Unlimited Queries, In-Distribution Data): Assuming the attacker has access to similar auxiliary data and can query the model freely, they train a simple 6-layer Multi-Layer Perceptron (MLP) to map embeddings back to tokens.
  • $\mathcal{A}_2$ (Unlimited Queries, Out-of-Distribution Data): To handle cases where auxiliary data differs from the target prompt's domain, a synthetic embedding generation technique is used to bridge the domain gap by randomizing preceding context.
  • $\mathcal{A}_3$ (Limited Queries, No Auxiliary Data): In the most restrictive scenario, a semi-supervised framework is employed. It uses nearest-neighbor search for high-confidence labels, an MLP for harder cases, and a shadow LLM (like GPT-2) with beam search to semantically fill in gaps.

Why Reconstruction Works: Token Dominance and Clustering

A key discovery of this work is the "Ending Token" dominance. In LLMs, the intermediate embedding at a specific position is primarily determined by the token at that position, with preceding context causing only minor shifts. This allows for efficient token-by-token reconstruction rather than complex sequence-to-sequence modeling.

Visualization of token embeddings in early layers showing distinct clusters for different tokens.

Furthermore, in the early layers of a network, token embeddings form tight, distinct clusters. As shown in the visualization above, different tokens occupy separable regions in the embedding space. While these clusters begin to overlap in deeper layers as the model integrates more semantic context, the initial separation is sufficient for high-fidelity reconstruction. This context-independent nature means errors in one token do not cascade, making the attack highly robust.

Experimental Results

The attacks were evaluated on models like Llama-3.2, Phi-3.5, and GPT-2 across various datasets, including WikiText-2, SQuAD 2.0, and Midjourney prompts.

  • High Accuracy: Both $\mathcal{A}_1$ and $\mathcal{A}_2$ achieved over 90% Token Reconstruction Accuracy (RA) across all tested layers for most models.
  • PII Extraction: The attacks successfully recovered exact Personally Identifiable Information (PII), such as names and dates, from sensitive prompt datasets, outperforming baseline semantic reconstruction methods.
  • Resilience: Even the highly constrained $\mathcal{A}_3$ attack maintained over 50% RA in early layers, proving that even minimal attacker resources can lead to significant data leakage.

Conclusion and the Search for Defenses

The findings highlight a critical vulnerability in current distributed AI systems. While defenses like Differential Privacy can stop the attacks, they often degrade model performance to unusable levels. Similarly, full pipeline encryption provides security but at a massive computational cost (up to 840x slower). Developing practical, efficient privacy-preserving mechanisms for distributed LLM inference remains an urgent challenge for the AI research community.

Summary updated

BibTeX
@inproceedings{luo2025prompt,
  author = {Xinjian Luo and Ting Yu and Xiaokui Xiao},
  title = {{Prompt Inference Attack on Distributed Large Language Model Inference Frameworks}},
  booktitle = {CCS},
  year = {2025},
  doi = {10.1145/3719027.3744820},
}
Figure