Abstract

Modern serving accelerates generation with speculative decoding: a small draft model proposes tokens that the large model verifies in parallel, and the speedup depends on how many drafts are accepted. Because acceptance depends on how predictable the text is, the timing of a response becomes content-dependent, and content-dependent timing is a side channel. This article analyzes decoding-timing leakage. It explains the speculative-decoding mechanism, shows why acceptance rate turns predictability into observable latency, frames the leak quantitatively as bits per query, and pairs each mechanism with a masking or isolation defense. The key takeaway is that any optimization whose speedup depends on the content being generated couples that content to timing, so where confidentiality matters, decoding timing must be made content-independent — constant-time-ish serving — at a measured throughput cost.

Speculative decoding is a beautiful optimization: instead of generating one token at a time with the big, slow model, a small draft model guesses several tokens ahead, and the big model checks all the guesses in a single parallel step, keeping the ones it agrees with. When the draft guesses well, many tokens are accepted at once and generation flies; when the draft guesses badly, few are accepted and it crawls. The catch is that how well the draft guesses depends on how predictable the text is — and so the response time now carries a fingerprint of the content's predictability. An observer who times the tokens is reading a low-resolution shadow of what was generated, and that shadow can leak more than a serving team intends.

How speculative decoding couples content to time

In standard autoregressive decoding, each token costs one forward pass of the large model, so timing is roughly constant per token regardless of content. Speculative decoding, introduced by Leviathan and colleagues, breaks that uniformity for speed: a cheap draft model proposes k tokens, the large model verifies them in one pass, and it accepts the longest correct prefix of the draft. The number accepted per verification step — the acceptance rate — determines the speedup, and acceptance is high exactly when the draft and target agree, which is when the text is predictable.

This is the coupling. Predictable content (common phrasing, boilerplate, repetition) yields high acceptance and fast generation; surprising content (unusual names, high-entropy data, unexpected structure) yields low acceptance and slow generation. The per-token or inter-token latency therefore varies with the content's predictability, converting a property of the secret output into an observable timing signal. Nothing is broken; the optimization is behaving exactly as designed, and that design is what leaks.

The defensive consequence is that decoding timing is only safe to expose if it does not depend on content. Where it must not leak, the speedup mechanism must be neutralized for that traffic — constant-time-ish decoding — accepting the loss of the optimization's benefit as the price of confidentiality.

The draft proposes, the target verifies, and acceptance — driven by predictability — sets the speed. Speculative decoding mechanics Draft model proposes k tokens Target verifies one parallel pass Acceptance rate predictability Observable speed content-dependent
The draft proposes, the target verifies, and acceptance — driven by predictability — sets the speed.
🛡️ Countermeasures
  • Recognize that any content-dependent speedup couples the generated content to observable timing.
  • Make decoding timing content-independent for traffic where confidentiality matters.
  • Treat inter-token latency as a secret-dependent signal wherever speculative decoding is enabled.

What the timing reveals

The leak is coarse but real: an observer of inter-token latency learns how predictable the generated text was, segment by segment. Fast bursts indicate predictable content; slow stretches indicate surprising content. This does not hand the attacker the text, but predictability is correlated with content in exploitable ways — a response that slows sharply at a particular position suggests a high-entropy token there (a name, a number, a rare word), which narrows the attacker's uncertainty about what was generated.

The signal strengthens when the attacker has partial control or knowledge. If an attacker can induce the model to generate a template with one secret field, the timing around that field reveals properties of the secret (its length, its predictability, whether it matches a common pattern). Combined with the batching couplings from the shared-serving threat model, decoding timing becomes one more observable that composes with others to reconstruct information about content the platform meant to keep private.

As with all side channels, severity is quantitative. A little content-predictability leaked per token, accumulated over a long response and many queries, can narrow a secret substantially. So the defense is not to dismiss the leak as coarse but to measure its bits-per-query and decide whether that rate, times the allowed query volume, is within an acceptable budget.

⚠️
Predictability is a proxy for content. Timing reveals how predictable each segment was, and predictability correlates with content — a sudden slowdown flags a high-entropy token an attacker can then narrow.
🛡️ Countermeasures
  • Assume inter-token timing reveals per-segment predictability, which correlates with high-entropy secret tokens.
  • Guard templated generations with a secret field, where timing can reveal the field's properties.
  • Measure accumulated bits-per-query rather than dismissing the leak as coarse.

Quantifying bits-per-query

To manage the leak, measure it. Model the attacker's observable — the sequence of inter-token latencies — as a signal and estimate the mutual information between it and the secret content. For speculative decoding, a useful proxy is how much the acceptance-rate profile varies with content: if two very different secrets produce indistinguishable timing, the leak is small; if they produce reliably different timing, the leak is large. The bits-per-query figure then bounds how fast an attacker can narrow a secret and therefore whether rate limits can contain them.

The relationship below captures the accounting: the number of queries an attacker needs scales inversely with the per-query leak. Speculative decoding's leak per query depends on how content-dependent acceptance is for the traffic in question — boilerplate-heavy outputs leak little, high-entropy outputs leak more. This lets a defender target mitigation where it matters instead of paying constant-time costs everywhere.

The mitigations reduce the per-query leak toward zero and cap total queries. To reduce per-query leak, make timing content-independent: pad each token's emission to a fixed interval, or disable speculative decoding for sensitive traffic so every token costs the same constant time. To cap total leak, apply per-tenant rate limits. The combination keeps residual-leak times query-rate under a chosen budget, the same discipline as every other serving side channel.

Content-dependent acceptance means high-entropy outputs leak more timing information per query. Leakage by content type Boilerplate high acceptance Mixed text variable High-entropy low acceptance Secret field leaks position
Content-dependent acceptance means high-entropy outputs leak more timing information per query.
\[\text{queries} \approx \frac{H(\text{secret})}{I(\text{latency profile};\,\text{content})}, \quad I \downarrow \text{ as timing} \to \text{content-independent}\]
🛡️ Countermeasures
  • Estimate bits-per-query from how much the acceptance/latency profile varies with content.
  • Target constant-time mitigation at high-entropy or secret-bearing traffic rather than everywhere.
  • Combine timing masking with per-tenant rate limits to hold residual-leak times query-rate under budget.

Making timing content-independent

The core defense is constant-time-ish decoding: ensure the observable emission cadence does not depend on the content. The cleanest form is token-pacing — buffer generated tokens and emit them to the client at a fixed interval regardless of how fast they were actually produced, so the client sees a uniform stream whether the internal acceptance was high or low. This masks the speculative-decoding leak entirely for the emission channel at the cost of not passing the speedup through to latency.

A blunter option is to disable speculative decoding for sensitive traffic, making every token cost the same standard forward pass so there is no acceptance-driven variation to leak. This sacrifices the throughput benefit for those requests but restores the uniform timing of standard decoding. Which to choose depends on whether the platform can afford to buffer-and-pace (preserving internal speedup for cost while masking external timing) or must simply turn the optimization off.

Neither is free, which is why they should be applied by sensitivity rather than globally. Non-sensitive, public-output traffic can enjoy the full speculative speedup with exposed timing; sensitive traffic gets paced or non-speculative decoding. Making this an explicit per-traffic policy, rather than exposing speculative timing to everyone by default, is what prevents the leak from being universal.

Pacing or disabling speculation masks the content-dependent timing at a throughput cost. Exposed versus paced timing exposed (fast) paced (safe) Exposed timing full speedup Leaks predictability content-dependent Paced timing fixed interval No timing leak throughput cost vs
Pacing or disabling speculation masks the content-dependent timing at a throughput cost.
🛡️ Countermeasures
  • Pace token emission at a fixed interval so the client sees uniform timing regardless of acceptance.
  • Disable speculative decoding for sensitive traffic where pacing is not feasible.
  • Apply pacing or non-speculative decoding by sensitivity, not globally, to preserve speedup where safe.

Why this matters and how to deploy it

Any service that streams tokens to clients over a shared or observable channel is exposed, and the exposure matters most when outputs carry secrets — generated credentials, private data, or responses whose content a competitor would pay to infer. Agent backends that stream long, structured outputs are particularly affected, because a long response gives the attacker many tokens of timing signal and structured outputs often contain a few high-entropy secret fields whose timing stands out.

The synthesis is that speculative decoding, and any content-dependent optimization, trades confidentiality for speed through the timing channel, so the deployment rule is to expose speculative timing only for non-sensitive traffic and to pace or disable it for sensitive traffic, choosing the throughput cost against a measured bits-per-query budget. Leviathan and colleagues' speedup is real and worth having; the discipline is simply to remember that a speedup which depends on content is a signal about content, and to mask that signal wherever content must stay private.

🛡️ Countermeasures
  • Expose speculative timing only for non-sensitive traffic; pace or disable it for streams that may carry secrets.
  • Buffer and pace long structured agent outputs so high-entropy secret fields do not stand out in timing.

Key takeaways

  • Speculative decoding's speedup comes from draft-acceptance, which is high for predictable text and low for surprising text.
  • This couples content to inter-token timing: response speed encodes how predictable each segment of the output was.
  • Timing does not reveal the text directly but flags high-entropy segments, narrowing an attacker's uncertainty about secret tokens.
  • Severity is quantitative — measure bits-per-query from how much the latency profile varies with content and set a budget.
  • The defense is constant-time-ish decoding: pace token emission at a fixed interval or disable speculation for sensitive traffic.
  • Apply masking by sensitivity, not globally, so non-sensitive traffic keeps the speedup while secret-bearing streams do not leak timing.

Practitioner Toolkit

Copy-paste, strictly defensive artifacts you can use today. Nothing here attacks a real system.

Decoding-timing safety reviewchecklist

Run before streaming tokens from a speculative-decoding service.

  • Traffic that may carry secrets is paced or served with non-speculative decoding.
  • Token emission for sensitive streams is at a fixed interval independent of acceptance.
  • Speculative timing is exposed only for explicitly non-sensitive traffic.
  • A measured bits-per-query figure exists for the decoding path.
  • Per-tenant rate limits cap total timing observations.
  • Structured outputs with secret fields are paced so those fields do not stand out.
🧪Timing-content correlation probeharness

Sanitized skeleton to measure whether your decoding timing varies with content (defensive).

# DEFENSIVE PROBE — does decoding timing leak predictability?
function timing_leak(service, prompts):
    rows = []
    for p in prompts:
        toks, lat = service.generate_timed(p)
        rows.append((segment_entropy(toks), inter_token_latency(lat)))
    r = correlation([e for e,_ in rows], [l for _,l in rows])
    if abs(r) > LEAK_THRESHOLD:
        flag("timing correlates with content entropy", r)
    # Strong correlation == exploitable decoding-timing channel; pace it.
Mock probe — correlates content entropy with inter-token latency on your own service.
🔒Decoding-timing policypolicy

Illustrative per-traffic timing policy.

decoding_timing_policy:
  speculative_decoding:
    sensitive_traffic: disabled_or_paced
    public_traffic: enabled
  emission:
    pacing: fixed_interval_for_sensitive
  metering:
    per_tenant_rate_limit: enforced
    leakage_budget_bits: defined
  classification:
    secret_field_outputs: always_paced
Example policy snippet — adapt to your serving stack.
🚀Minimum viable decoding-timing defensequickstart

Do these first if you stream tokens for many tenants.

  • Pace token emission at a fixed interval for any stream that may carry secrets.
  • Disable speculative decoding where pacing is not feasible for sensitive traffic.
  • Keep speculative speedup only for explicitly non-sensitive outputs.
  • Rate-limit per tenant to cap total timing observations.

Glossary

Speculative decoding
Generating faster by having a small draft model propose tokens the large model verifies in parallel.
Draft model
A small, fast model that proposes candidate tokens for the large target model to verify.
Acceptance rate
The fraction of drafted tokens the target model accepts, which drives the speedup and depends on predictability.
Inter-token latency
The time between successive emitted tokens, made content-dependent by speculative decoding.
Constant-time-ish serving
Making observable timing independent of content, typically by pacing token emission at a fixed interval.
Token pacing
Buffering generated tokens and emitting them at a fixed interval to mask internal timing variation.
Bits-per-query
The information a single query's timing profile reveals about the secret content.
Entropy
A measure of unpredictability; high-entropy tokens accept poorly and generate slowly, standing out in timing.

References

  1. Leviathan et al., Fast Inference from Transformers via Speculative Decoding (arXiv 2211.17192)
  2. Kocher, Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems (CRYPTO 1996)
  3. Kwon et al., Efficient Memory Management for LLM Serving with PagedAttention (arXiv 2309.06180)
  4. Shumailov et al., Sponge Examples: Energy-Latency Attacks on Neural Networks (arXiv 2006.03463)
  5. NIST AI 100-2 e2023, Adversarial Machine Learning: A Taxonomy and Terminology