An Attack to Break Permutation-Based Private Third-Party Inference Schemes for LLMs

Rahul Krishna Thomas, Louai Zahran, Erica Choi, Akilesh Potti, Micah Goldblum, Arka PalarXiv 2025 · DOI

Researchers from Ritual, Stanford, and Columbia have recently exposed a critical vulnerability in the field of privacy-preserving machine learning. Their work demonstrates that several prominent schemes designed to protect user prompts during third-party Large Language Model (LLM) inference—specifically PermLLM, STIP, and Centaur—are fundamentally insecure. By exploiting the unique statistical signatures of LLM hidden states and the unidirectional nature of transformer attention, the researchers developed an attack capable of reconstructing original user prompts with nearly 100% accuracy.

The Privacy Gap in LLM Inference

As LLMs grow in complexity and size, users increasingly depend on third-party providers for inference. This dependency introduces significant privacy risks, particularly in sensitive sectors like healthcare and finance. While traditional cryptographic solutions such as Secure Multi-Party Computation (SMPC) offer mathematical guarantees of privacy, they are often computationally prohibitive, running thousands of times slower than standard inference.

To address this, a new class of "efficient" privacy schemes emerged. These methods, including PermLLM, STIP, and Centaur, replace heavy cryptography with statistical obfuscation, primarily by permuting (shuffling) the hidden states of the model. The underlying assumption was that the astronomical number of possible permutations would make reversing the process computationally infeasible. This research proves that this assumption is incorrect.

The Vocabulary-Matching Attack

The core of the researchers' approach is a "vocabulary-matching" attack that reconstructs the user's prompt token-by-token. The attack proceeds through several sophisticated stages:

  1. Base Attack Strategy: For an unpermuted hidden state, the attacker iterates through the model's vocabulary, performs a forward pass for each candidate token, and identifies the one that produces a hidden state matching the observed data.
  2. Overcoming Permutations:
    • Sequence-Dimension: Decoder-only LLMs utilize unidirectional (left-to-right) attention. This means the first token's hidden state depends only on itself. The attacker identifies the "first" token among the shuffled states and then uses it as context to find the second, and so on.
  3. Hidden-Dimension: To counter shuffling within the embedding vector itself, the authors employ a sorted L1-distance. By sorting both the candidate and observed vectors before comparison, the specific permutation becomes irrelevant.
  4. Efficiency Optimizations: To make the attack practical, the researchers use the LLM itself as a "proposal model" to rank the most likely next tokens. This reduces the search space from approximately 256,000 tokens to about 100 per step. They also implement custom KV-caching to eliminate redundant computations.
  5. Handling Noise: Since floating-point operations can be non-deterministic across different hardware, the attack uses a distance threshold (ε) rather than requiring exact matches.
Overview of the vocabulary-matching attack process, showing how hidden states are used to iteratively recover user text.

Experimental Results

The attack was evaluated using datasets like FineWeb-Edu and LiveBench across various model architectures. The results were stark:

  • Near-Perfect Recovery: The attack achieved 100% decoding accuracy on Gemma-2-2B-IT and over 99% on Llama-3.1-8B-Instruct across multiple layers and permutation types.
  • High Efficiency: With optimizations, a 50-token prompt can be decoded in approximately 2 minutes.
  • Scalability and Robustness: The attack remains effective as models scale (tested up to 27B parameters) and is not significantly hindered by model quantization (e.g., 4-bit or 8-bit precision).
Decoding accuracy across different layers for Gemma and Llama models, showing near-perfect recovery rates.

Why These Schemes Fail

The success of this attack stems from several key insights into LLM behavior:

  • Non-Colliding Hidden States: Hidden states are remarkably unique. It is extremely rare for different token sequences to produce hidden states that are close in vector space, even after sorting or minor noise addition.
  • Unidirectional Attention Vulnerability: The "left-to-right" nature of modern LLMs allows an attacker to "unravel" the sequence linearly. Once the start is found, the subsequent search space remains manageable.
  • Theoretical Misconceptions: Previous schemes relied on "Distance Correlation" theory for security proofs. The authors provide a mathematical proof showing that low distance correlation does not prevent reconstruction.

Limitations and Future Directions

While highly effective, the attack has some limitations. It currently targets permutations along specific dimensions (sequence or hidden) rather than "unrestricted" permutations where every value in the hidden state matrix is shuffled. Additionally, rare formatting characters or word repetitions can occasionally confuse the proposal model.

For future defense, the researchers found that combining permutations with a specific level of Gaussian noise (σ = 0.01) might create a "sweet spot" where the attack fails while the model maintains benchmark performance. This represents a promising path for developing more robust privacy-preserving inference methods.

Summary updated

BibTeX
@misc{thomas2025attack,
  author = {Rahul Krishna Thomas and Louai Zahran and Erica Choi and Akilesh Potti and Micah Goldblum and Arka Pal},
  title = {{An Attack to Break Permutation-Based Private Third-Party Inference Schemes for LLMs}},
  year = {2025},
  eprint = {2505.18332},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.18332},
}
Figure