Skip to content

Physical side-channel attacks against edge LLMs: extracting output tokens and user promptsPhysical Side-Channel Attacks on Edge LLMs: Extracting Output Tokens and User Prompts

Paper Tracker· arXiv:2610.14215· Najeh Alhalawani, Gunes Acar, Zhuoran Liu, Lejla BatinaRadboud University; University of AmsterdamIndexed by this site · 2026-10-20· Originally publishedAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

For LLaMA 3.2 1B on a Raspberry Pi, passive electromagnetic measurements achieve Top-1 of 97.2% in closed-set identification of 50 keywords, and can invert prompt semantics.

Threat modelPhysically passive attacker: a near-field probe collects inference EM traces; the attack phase does not touch software, the operating system, memory or the network, and does not modify hardware. On a reference device, training is done offline with labeled traces and hidden states. The victim system is LLaMA 3.2 1B Instruct running via llama.cpp on a Raspberry Pi 5.

Questions
On-device LLMs often run inference locally for privacy, but computation produces electromagnetic radiation. The authors aim to determine whether passive electromagnetic measurements can recover generated tokens and user prompts without touching the software.
Methods
After tracing llama.cpp, they locate the leakage window at the LM Head. Traces are made into STFT spectrograms, a vision model performs closed-set classification or regresses the hidden state, and decoding then uses the public vocabulary matrix; T5 inverts the prompt from that state.
Experiments and results
50-class closed-set Top-1 is 97.2%. Full-vocabulary recovery of analyzed words has Top-1 of 94.3%. For unseen words under one training objective, Top-100 is 67.0% and median rank is 54. Prompt inversion extracts embedded keywords at a rate of 88.7%, with average cosine similarity of 0.82.
Limitations and future work
The authors note that real deployments would encounter cross-session variation and dynamic CPU frequency, and believe that high clocks and parallelization on GPUs would pose challenges. The experiments evaluate Raspberry Pi CPU inference at a fixed 1500 MHz, and the paper does not report countermeasure experiments or random seed repetitions.
Experimental setupLLaMA-3.2-1B-Instruct · Primary 50-Class Dataset、Context-Independence Dataset (17 Templates) et al. · Top-1 accuracy、Top-5 accuracy et al.
Evaluated models
LLaMA-3.2-1B-Instruct
Benchmarks
Primary 50-Class DatasetContext-Independence Dataset (17 Templates)prompt recovery corpus
Metrics
Top-1 accuracyTop-5 accuracyTop-100 recoverymedian rankcosine similarity
AI summaryThe paper demonstrates an electromagnetic (EM) side-channel attack against LLM inference on edge devices, on LLaMA-3.2-1B-Instruct running on a Raspberry Pi 5, attackers can recover generated tokens and user prompts from EM traces collected during inference. The study proposes three attacks: a profiling attack identifies generated tokens with 97.2% accuracy among 50 healthcare- and privacy-related keywords; a reconstruction attack recovers the model's hidden representations, achieving 94.3% accuracy on profiled classes over the full 128k token vocabulary, with 67% of correct tokens for unseen words falling within the top 100 and a median rank of 54; a hidden-state inversion attack semantically reconstructs user prompts using the recovered hidden states. The authors state that these attacks require only passive EM measurements and a limited number of traces during training, indicating that local execution alone may not guarantee the confidentiality of generated tokens and user inputs.

The paper demonstrates an electromagnetic (EM) side-channel attack against LLM inference on edge devices, on LLaMA-3.2-1B-Instruct running on a Raspberry Pi 5, attackers can recover generated tokens and user prompts from EM traces collected during inference. The study proposes three attacks: a profiling attack identifies generated tokens with 97.2% accuracy among 50 healthcare- and privacy-related keywords; a reconstruction attack recovers the model's hidden representations, achieving 94.3% accuracy on profiled classes over the full 128k token vocabulary, with 67% of correct tokens for unseen words falling within the top 100 and a median rank of 54; a hidden-state inversion attack semantically reconstructs user prompts using the recovered hidden states. The authors state that these attacks require only passive EM measurements and a limited number of traces during training, indicating that local execution alone may not guarantee the confidentiality of generated tokens and user inputs.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Local inference on edge devices may still leak generated tokens and user prompts through electromagnetic side channels.

    On-device LLM local inference may still leak generated tokens and user prompts via electromagnetic (EM) side channels.

    • Scenario: The authors state that privacy, latency, and intellectual property are driving LLMs onto end devices; applications such as healthcare, law, and mental health expect data to stay on the device. Local execution does not eliminate physical leakage from power consumption or electromagnetic radiation.
    • Existing gaps: The authors state that existing physical side channels mainly recover model structure, weights, or inputs, and do not target information produced during generative model inference; cache and network side channels require shared hardware or observing traffic, and are not applicable to offline devices with only passive physical proximity.
    • Core observation: The authors believe the LM Head uses the final hidden state to compute scores for the next token, and that this state is derived from the preceding context, so the radiation may carry both output token and prompt information.
    • This paper proposes: For LLaMA 3.2 1B Instruct on a Raspberry Pi 5, using passive EM traces for closed-set token identification, full-vocabulary prediction after hidden state reconstruction, and prompt semantic inversion.
    • Threat model:
      • Goal: Recover generated tokens and infer the semantics of user prompts.
      • Knowledge: Profiling is performed on a reference device to obtain labeled traces and final hidden states and train offline; model weights are public. The attack phase does not access the victim's software, operating system, memory, or network.
      • Capability: A near-field electromagnetic probe passively collects while the device runs normally; no hardware modification and no software exploitation. In the full-vocabulary setting, the token being recovered need not be analyzed in advance.
      • Victim system: LLaMA 3.2 1B Instruct run by llama.cpp on a Raspberry Pi 5 (Cortex-A76), quantized to Q4_K_M.
  2. What related research exists?

    The authors place this paper between physical side channels and representation inversion, and state that no prior work has recovered on-device LLM tokens from raw electromagnetic radiation.

    The paper divides related work into physical side channels of machine learning, side channels in LLM deployment, and inverting text from internal representations.

    Physical side channels of machine learning models

    • Structure recovery: CSI NN by Batina et al. (2019) reverse-engineers neural network structure from EM and power traces of an ARM Cortex-M. The survey by Horváth et al. (2024) summarizes structure extraction, parameter extraction and input recovery on microcontrollers, CPUs, FPGAs and GPUs.
    • Weight extraction: BarraCUDA by Horvath et al. (2025) uses correlation EM analysis to recover convolutional network weights on an NVIDIA Jetson Nano; Kraken (2026) brings higher-order EM correlation attacks to Tensor Cores.
    • Input and architecture: ScaAR by Liu et al. (2025) uses EM to extract user input of an edge neural network, targeting input privacy rather than model intellectual property. Wang et al. (2024) discuss leakage of layer type and structure from fixed weight access patterns in RRAM in-memory computing.

    The authors state that these works show physical side channels can leak structure, parameters or input, but do not target information produced during generative model inference.

    Side channels in LLM deployment

    • Cache: Gao et al. (2025) use CPU cache access patterns during token embedding to infer generated tokens. Adiletta and Sunar (2025) use Flush+Reload to monitor a cache shared with the victim; the paper writes that their recovery of English text reaches up to 40%.
    • Network: Whisper Leak (McDonald and Bar Or, 2025) infers the prompt topic from packet sizes and timing of encrypted streaming LLM traffic.
    • The paper's comparison: the authors state that these approaches rely on shared hardware resources or on observing network traffic, and do not apply to offline edge devices with only passive physical proximity.

    Recovering text from model internal representations

    • Embedding and distribution inversion: Morris et al. (2023) use a sequence-to-sequence model to invert sentence vectors into text; follow-up work in the same direction reconstructs prompts from next-token probability distributions.
    • The paper's comparison: the authors state that these methods assume internal representations or outputs can be obtained directly through a software interface, whereas this paper must first estimate the target representation from a side channel.

    The authors position this paper as recovery targeting the LM Head projection using only raw physical electromagnetic radiation, and state that to their knowledge no prior work recovers tokens generated by an edge LLM in this way. The experimental comparisons are input representation, backbone and training objective, not rerunning the above attacks as baselines.

  3. How does the paper address this problem?

    Localize the electromagnetic window of the LM Head, use spectrograms to classify tokens or regress the hidden state, then invert the prompt.

    The overall approach is to trace llama.cpp's decode, turn the EM trace into STFT spectrograms, then perform closed-set classification or hidden-state regression, and decode using the public vocabulary matrix; separately, an inversion model is trained to recover the prompt semantics.

    Problem setting and leakage window

    • Two-stage inference: prefill processes the entire prompt at once, builds the KV cache and computes the first token; decode generates step by step. Each forward step ends with the final hidden state.
    • LM Head: the paper writes the next-step score as zt = W ht, which is then turned into a vocabulary distribution and sampled. For LLaMA 3.2 1B, this layer maps a 2048-dimensional representation to 128 256 tokens.
    • Two forms: the closed set maps the trace to C pre-analyzed classes, with C=50 in the paper's example. Representation recovery is written as xEM → ĥt → Wĥt → ŷt, i.e., first estimate the 2048-dimensional state, then obtain full-vocabulary logits via the public matrix W.
    • Reasons for the choice: the authors give three: it is the large matrix-vector multiply that dominates the end of decode; it executes deterministically at each step; and it performs quantized integer operations on a fixed memory layout, forming a relatively long and data-dependent window. A near-field probe collects the time-domain trace above the processor package.

    Acquisition, corpus and representation

    • Platform: Cortex-A76 on a Raspberry Pi 5, with frequency fixed at 1500 MHz. The model runs via llama.cpp with Q4_K_M; the LM Head uses Q6_K weights and Q8_K activations, going through ARM NEON dot products. A self-written program inserts a hardware trigger via llama.h, used only for experimental alignment; the attack phase does not assume the attacker has a GPIO trigger.
    • Measurement: a passive near-field H-field loop probe is placed on the back of the PCB, above the BCM2712 die. The oscilloscope is a LeCroy WaveRunner 8404M-MS, with channel C2 at 28 mV/div, 50 Ω. At this frequency, the LM Head matrix-vector multiply takes about 22.5 ms.
    • Main set: 50 health- and privacy-related keywords, 120 750 traces, 2 415 per class. The prompt makes the reply exactly two tokens, and the keyword is always the second generated token. The LM Head window is cut out according to the trigger, with a length of about 11.25×10^6 samples; the 70/15/15 split gives 84 524, 18 113, 18 113.
    • Context set and features: 17 templates change the instruction wording and the guiding words, with the keyword position unchanged. After a pilot, STFT spectrograms are used, scaled to 256×256, with a single channel replicated into three channels, without a colormap.

    Classifier and full-vocabulary recovery

    • Closed-set training: ImageNet-pretrained ResNet-18 is used throughout. The loss is cross-entropy, label smoothing 0.1, Adam, weight decay 10^{-3}, cosine learning rate, at most 40 epochs, with early stopping based on the lowest validation loss.
    • Regression: pretrained EfficientNet-B0 predicts the 2048-dimensional state after RMSNorm. In the pilot, cosine similarity gave a higher Top-1 than InfoNCE and mean squared error, and the final generative model uses only the cosine loss. At decoding time, ranking is over all 128 256 tokens.
    • Two-step adjustment for unseen words: the raw states of different words have a large common component, so instead the residual r=h−μ is predicted, and the mean is added back before decoding. The training objective is then changed to full-vocabulary cross-entropy, with a hardest-negative margin added, so that optimization is consistent with full-vocabulary ranking.
    • Profiling budget: both attacks scan the amount of data from 100 to 2 000 traces per word.

    Semantic inversion and evaluation

    • Inversion structure: a two-layer feedforward network projects the 2048-dimensional state to 48×dmodel, rearranges it into 48 pseudo-tokens, and feeds it as input to a pretrained T5-base encoder; the decoder generates the prompt token by token via cross-entropy.
    • Corpus: the weights are public, so 2 688 674 prompt–state pairs are generated offline from public instructions, question-answering, dialogue and domain text; the paper states that about 95% are used for training, and Table IX writes the number of training pairs as 2 551 308. All 17 acquisition templates are excluded.
    • Evaluation: the closed set looks at Top-1 and Top-5. The full vocabulary looks at whether the true token ranks first, whether it enters the top 100, and the median rank. Prompt recovery looks at the cosine similarity with the original prompt, and whether the embedded keyword is exactly extracted. Only states predicted from EM are used in evaluation.
  4. What experiments did the paper conduct?

    Top-1 for the 50-class closed set is 97.2%; Top-100 for unseen words is 67.0%, and prompt keyword extraction is 88.7%.

    Experimental setup

    • Victim model and collection: LLaMA 3.2 1B Instruct, Q4_K_M, llama.cpp, Cortex-A76 on a Raspberry Pi 5, CPU frequency fixed at 1500 MHz. A near-field H-field probe is on the back of the PCB, above the BCM2712; LeCroy WaveRunner 8404M-MS, C2 at 28 mV/div, 50 Ω.
    • Dataset: The 50-class main set has 120 750 traces, 2 415 per class, with train/validation/test of 84 524 / 18 113 / 18 113. The context set consists of 17 templates and 849 hidden states (50×17 minus 1 refused generation). The inversion corpus is given in Table IX; collection templates are not used in training.
    • Attack models: The closed set uses an ImageNet-pretrained ResNet-18; full-vocabulary generation uses EfficientNet-B0; inversion uses T5-base. The pilot also compared ResNet-50, CLIP RN-50, CLIP ViT-B/32, MAE ViT-B/16, as well as networks trained from scratch and several raw 1D networks.
    • Metrics: Closed-set Top-1 and Top-5; chance for 50 classes is 2%, and 3.3% for the 30-class pilot. The full vocabulary also has Top-100 and median rank, with chance at 7.8×10^{-6}. Prompts use cosine similarity and exact keyword extraction rate.
    • Determination: Based on whether the generated token matches, its rank in the 128 256-token vocabulary, and vector cosine. The paper does not use an LLM judge and does not report human annotation.
    • Alignment: The GPIO trigger is used only for collection alignment. The paper does not report the number of random seed repetitions. Unless stated otherwise, results come from the above 50-class split and the preprocessing in Section V.

    Main results

    Swipe horizontally to read the table

    SettingMetricValueSource
    50-class closed set, STFT 256² + pretrained ResNet-18, test setTop-1 / Top-597.20% / 99.95%Table II
    Generative, analyzed words, 2 000 traces per word, full vocabularyTop-194.3%Table III
    Full-vocabulary decoding with the same configurationTop-5; median rank95.8%; 1Section VI-B
    Unseen words, cosine loss before centeringTop-100; median rank11.8%; 1 327Table VI
    Unseen words, full-vocabulary cross-entropy + hardest-negative marginTop-100; median rank67.0%; 54Table VII
    EM-predicted state inversion, 1 024 promptsExact extraction of embedded keywords88.7%Section VI-C
    • The authors state that the same configuration achieved Top-1 of 98.3% on the 30-class pilot; the 50-class training reached its lowest validation loss at epoch 39, and the difference between training and validation accuracy was less than two percentage points.
    • The authors state that the closed set has no mechanism for rejecting out-of-vocabulary inputs. The Figure 11 note says the classifier still has confidence for out-of-vocabulary words, highest for in-domain medical words; the authors suggest that even when the specific word cannot be recognized, high confidence may still reveal that the topic under discussion is medical.
    • The authors state that representation recovery removes the fixed-category bottleneck. For unseen words, Top-1 in Table VI and Table VII is 0% or 0.0%, and ranking changes appear in median rank and Top-100 rather than in exact hits.

    Whether leakage is detectable and where it is located

    • TVLA: For class 16 (disability) relative to the remaining classes, Welch's t-statistic is computed point by point over the LM Head window. The paper treats |t| above 4.5 as detectable leakage. The authors state that the measurement consistently exceeds this threshold (Figure 6).
    • Masking: A 6×6 grid masks one block at a time. The authors state that the top row at 200–250 MHz carries little information; leakage is concentrated in the middle third of the window time and at 0–150 MHz, and masking one of these blocks brings accuracy down to near zero (Figure 9). The Grad-CAM in Figure 10 marks the same middle segment and mid-to-low frequency region.
    • The authors' interpretation of the source: The early part of the window corresponds to scheduling overhead and loading weights, the middle part to the LM Head dot product, and the later part to dequantization, with less token-specific information (Section VII).

    Context independence and unseen words

    • Word or template: Over 849 states, the average cosine is 0.822 for the same word with different templates, 0.712 for the same template with different words, and 0.596 when both differ (Table IV). The Figure 12 note gives a mean of 0.82 for the same word and 0.60 for different words. The Figure 13 note says clusters separate when colored by word but not when colored by template. The authors state that the word is the dominant factor shaping the hidden state.
    • Centering: In Table V, the between-class cosine of the raw states is +0.602, and that of the centered residuals is −0.011. The authors state that without centering, the network mainly learns a shared direction. After centering, the true token ranks first for 92.9% of the analyzed states; for unseen words, Top-100 goes from 11.8% to 28.7% and the median rank from 1 327 to 443, with Top-1 still 0% (Table VI). The authors state that predictions shift from high-frequency words to the semantic neighborhood of the true word.
    • Training objective: In Table VII, with only the hardest-negative margin added, unseen-word Top-100 is 28.2% and the median rank is 365, with Top-100 not higher than the 28.7% of the cosine loss. Switching to full-vocabulary cross-entropy gives a median rank of 55 and Top-100 of 63.8%; the angular-margin variant gives 53 and 63.5%.

    Semantic prompt recovery

    • Setup: Inversion uses only the EM-predicted hidden state, and the 17 collection templates do not participate in training. Table VIII gives recovery examples; some extract the embedded word, while others truncate it or replace it with another word.
    • Results: Over 1 024 prompts, the average cosine similarity between the recovered text and the original prompt is 0.82. In the remaining 11.3%, the keyword is not extracted exactly; the authors state that the target word is often truncated.
    • The authors' interpretation: The model has not seen the wording of the collection templates and recovers the instruction in its own words. The authors state that truncation errors lie close to the correct answer in semantic space, indicating that the state captures semantics but is not sufficient to distinguish the exact word.

    Other ablations and analyses

    • Closed-set Top-1 by number of traces per word: 66.1% for 100, 89.0% for 250, 93.8% for 500, 96.4% for 1 000, and 97.2% for 2 000 (Table III).
    • Generative full-vocabulary Top-1: 0.0% for both 100 and 250 traces, 64.6% for 500, 89.9% for 1 000, and 94.3% for 2 000 (Table III).
    • 30-class pilot: 256² STFT + pretrained ResNet-18 gives 98.28% / 99.97%; ResNet-18 on 224² STFT gives 98.14%, and the scalogram at the same size gives 53.70% (Table I).
    • Training from scratch reaches at most 23.86%; CLIP ViT-B/32 and MAE ViT-B/16 give 7.34% and 7.31% (Table I). The authors state that raw 1D stays at 5–7% across capacities; in Table II, a 1.16B-parameter MLP gives 5.26%, and chance is 2%.
    • Regression pilot (1 000 traces per class): the pretrained CNN has a median rank of 1; training from scratch and transformer architectures are close to chance. Cosine loss gives Top-1 of 89.9%, higher than InfoNCE and MSE (Section VI-B).
    • ResNet-50 gives 75.77% on colormap input and 67.58% on 256×256 replicated-channel input; ResNet-18 and EfficientNet-B0 do not show this drop (Table I).
  5. What are some points that can be further explored?

    The authors point out that cross-session variation, dynamic CPU frequency and GPU deployment still need to be addressed.

    Limitations and future directions noted by the authors

    • Cross-session and CPU frequency: In real deployments, attackers will encounter cross-session variation and dynamically changing CPU frequency; the authors state that these limitations can be addressed (Section VII Limitations).
    • Collection under multiple conditions: The authors state that cross-session differences can be mitigated by collecting profiling traces across multiple sessions and operating conditions (Section VII).
    • No hardware trigger: The authors state that cross-correlation detection with known trace templates can be used to align consecutive decode phases, thereby not relying on a hardware trigger (Section VII).
    • Measurement equipment: The authors state that CPU frequency changes can be addressed with more specialized measurement equipment (Section VII).
    • GPU: The study focuses on CPU inference. The authors suggest that many real on-device deployments use GPUs, and that higher clocks and parallelization may pose challenges for attackers; future work could study adapting to GPUs, for example by exploiting GPU-specific execution and radiation patterns (Section VII).
    • Defense directions: The authors expect that developing low-overhead defenses for side-channel leakage in on-device LLM inference will be a direction for future research; the text mentions shielding, randomizing dot-product order and algorithmic masking (Section VII).

    Scope of the experiments

    • The generation model under test is LLaMA 3.2 1B Instruct, quantized with Q4_K_M and run via llama.cpp on a Raspberry Pi 5 (Cortex-A76, CPU frequency fixed at 1500 MHz); the LM Head uses Q6_K weights and Q8_K activations (Section V).
    • The closed set and state recovery use 50 keywords and 120 750 traces, split into 84 524 / 18 113 / 18 113; the context set consists of 17 templates and 849 states (Section V-A, VI-B).
    • The attacks include 50-class classification, hidden-state decoding over a 128 256-token vocabulary, and T5-base prompt inversion. The inversion corpus contains 2 688 674 pairs, of which 2 551 308 pairs are used for training, with the 17 collection templates excluded (Table IX, Section V-C, VI-C).
    • Inputs compared raw 1D, STFT and Morlet scalogram; backbones include ResNet-18/50, EfficientNet-B0, CLIP and MAE; leakage analysis includes TVLA, 6×6 time-frequency masking and Grad-CAM (Table I, Table II, Section VI).
    • Success is determined by token ranking and cosine similarity. The paper does not report LLM judging, human agreement or the number of random seed repetitions. Section VII discusses shielding, execution randomization and algorithmic masking; the paper does not report experimental results for these countermeasures.
  6. Summarize the main content of the paper

    Passive electromagnetic measurements can recover analyzed tokens from LLaMA 3.2 1B on a Raspberry Pi, and partially recover unseen words and prompt semantics.

    This work uses passive electromagnetic measurements to examine whether edge LLM inference leaks generated tokens and user prompts.

    • Problem: local inference is often used to avoid sending sensitive prompts to the cloud. The authors run LLaMA 3.2 1B Instruct on a Raspberry Pi 5 to see whether CPU radiation can expose outputs and internal representations.
    • Method: in llama.cpp, the window is localized to the LM Head, and traces are converted into 256×256 STFT spectrograms. The closed set uses a pretrained ResNet-18 to distinguish 50 pre-analyzed words; the open vocabulary uses EfficientNet-B0 to regress the 2048-dimensional hidden state, then multiplies by the public vocabulary matrix; prompt inversion uses T5-base to generate text from that state. Profiling is done on a reference device, and the attack phase relies only on physical proximity.
    • Pre-analyzed words: Top-1 on the 50-class test set is 97.2%, written as 97.20% in Table II, and Top-5 is 99.95%. For the full-vocabulary generative model at 2 000 traces per word, Top-1 for pre-analyzed words is 94.3%, Top-5 is 95.8%, and the median rank is 1.
    • Unseen words: with full-vocabulary cross-entropy plus hardest-negative margin, the proportion of correct tokens entering the top 100 is 67.0%, and the median rank is 54 (Table VII); Top-1 for that row is 0%. Before centering, Top-100 is 11.8% and the median rank is 1 327 (Table VI).
    • Prompts: on 1 024, the average cosine similarity between the recovered text and the original prompt is 0.82, the proportion of embedded keywords exactly extracted is 88.7%, and the remaining 11.3% are often truncated (Section VI-C). The acquisition templates were not used for inversion training.
    • Authors' conclusion: the authors state that keeping inference local alone cannot guarantee the confidentiality of generated tokens and user input, and argue that as deployments increase, more attention should be paid to inference side channels and defenses such as shielding, LM Head masking and execution randomization.
Read originalarxiv.org