TL;DR
NightVision is a novel black-box attack that can steal the "blueprints" of a Large Language Model (LLM)—specifically its hidden dimension, depth, and parameter count—using only the most restrictive API access available today. By combining a clever "common-set prompting" technique to exploit the softmax bottleneck with a timing-based analysis of the prefill stage, the researchers demonstrate that even "single-logit" APIs (which hide top-k results and logit bias) are not enough to protect a model's intellectual property.
What Problem Does This Paper Address?
LLM providers like OpenAI and Anthropic treat their model architectures as closely guarded secrets. Previous research showed that if an API allowed users to "bias" certain tokens or see the top-k most likely next tokens, an attacker could mathematically recover the model's hidden dimension by finding the "softmax bottleneck"—the point where the high-dimensional internal representations are squeezed into a lower-rank output layer.
In response, many providers restricted their APIs to only return the log-probability of a single, sampled token. The authors of this paper asked: Is architectural secrecy still possible under these "minimalist" APIs? Their answer is a resounding "no."
Methods
The authors introduce NightVision, a two-pronged attack illustrated in the overview below:
1. Common-Set Prompting (Inferring Hidden Dimension $d$)
Without the ability to force the model to give probabilities for specific tokens (logit bias), the attacker must rely on sampling.
- High-Entropy Prompts: The attack uses "nonsense" prompts (e.g., random Unicode characters) to force the model into a state of high uncertainty, spreading probability mass across many tokens.
- The Common Set: By sampling many tokens for each prompt, the attacker identifies a "common set" of tokens that appear at least once across a large group of prompts.
- Spectral Analysis: They build a matrix of the log-probabilities for these common tokens and perform an eigendecomposition. The "numerical rank" of this matrix—identified via a custom change-point detector—reveals the hidden dimension $d$.
2. Timing Attack (Inferring Depth $L$ and Parameters $P$)
Once the hidden dimension $d$ is known, the attack uses a side channel: Time to First Token (TTFT).
- Prefill Dominance: In modern transformers, the time taken to process the initial prompt (prefill) scales predictably with the sequence length squared ($\ell^2$), the depth ($L$), and the hidden dimension ($d$).
- Scaling Laws: By measuring TTFT across different prompt lengths and comparing them to known "reference" models, the authors can solve for the unknown depth $L$.
- Parameter Estimation: Finally, they plug $d$ and $L$ into an analytical formula to estimate the total parameter count $P$.
Datasets
The researchers evaluated NightVision on 32 open-source LLMs (plus 7 used for initial development), spanning:
- Families: Qwen, IBM Granite, Llama (3.1/3.2), OLMo, and SmolLM.
- Sizes: From tiny 135M parameter models to 30B parameter giants.
- Architectures: Both standard "dense" transformers and Mixture-of-Experts (MoE) models.
Key Insights and Ideas
- The Bottleneck is Persistent: The fundamental linear algebraic structure of transformers (the softmax bottleneck) is an inherent vulnerability. Even if you can only see one pixel of the image at a time, if you look at enough pixels, the underlying low-rank structure emerges.
- MoE Models are More Vulnerable: Surprisingly, Mixture-of-Experts models converge much faster in the spectral analysis. The authors hypothesize that because each token only routes through a few "experts," the eigenspace saturates more quickly, making the hidden dimension easier to spot.
- Timing is a High-Fidelity Signal: For models larger than 3B parameters, the computational cost of the "prefill" stage is so dominant and predictable that it acts as a very clean proxy for model depth, even across different hardware platforms.
Key Results
NightVision successfully recovered architectural details across a wide range of models:
- Hidden Dimension ($d$): Recovered within 23% average relative error across all models. For MoE models, this error dropped to just 9%.
- Depth ($L$) and Parameters ($P$): For models larger than 3B parameters, these were estimated within ~53% relative error.
- Cost vs. Access: As shown in the comparison below, NightVision works where previous attacks fail, though it requires significantly more tokens (a higher "budget") to achieve high accuracy.
As the token budget increases, the error rates for all three parameters drop significantly, as seen in Figure 3:
Limitations and Future Work
- Token Budget: The attack is expensive. While a "logit-bias" attack might take millions of tokens, NightVision requires hundreds of billions of tokens for high-precision recovery.
- Architecture Generalization: The timing model assumes a standard LLaMA-style transformer. It's unclear how well this would work on newer architectures like Mamba (state-space models) or hybrid models.
- Timing Noise: The timing attack assumes the attacker can measure TTFT accurately without significant network jitter or provider-side "noise injection" designed to thwart such attacks. Future work could explore how to defend against these timing side channels.
Summary updated