# Detect hidden system prompt injection in billed input tokens

> Source: LMSpeed (https://lmspeed.net) — https://lmspeed.net/audit/token-injection. When citing or reusing this content, credit "LMSpeed" and link to https://lmspeed.net/audit/token-injection.

Detect hidden system prompts injected by LLM API relays by comparing billed prompt_tokens with local tiktoken counts on OpenAI-compatible requests.

Canonical URL: https://lmspeed.net/audit/token-injection
Last updated: 2026-12-03T18:58:42.592Z (site data revision; page date not supplied)

Reproduction and quotation must name LMSpeed, link to the canonical HTML URL, and retain individual source citations.

Spot invisible prompt prefixes, role wrappers, and inflated token billing added silently along the proxy hop.

Prompt & Injection SecurityDefault suite@lmspeed/audit v0.3.3 · independent-2026-11-24.1

[Run the All-in-One audit](https://lmspeed.net/audit)[Fingerprint Detection](https://lmspeed.net/audit/model-fingerprint)

## Recent public reports

Redacted audit reports that included this probe.

- [ap***.com

gpt-6.1-sol

Audited at · Dec 2Needs review](https://lmspeed.net/audit/TvSK1gIRNgSoomPm)

- [ap***.ai

claude-opus-5-5

Audited at · Dec 2Needs review](https://lmspeed.net/audit/fBcpDE1iuOzD1eVt)

## Overview & Risk Context

Token injection detection compares local tokenized prompt expectations against usage.prompt_tokens returned by the relay endpoint across controlled prompt sizes.

### What this check measures

Measures systematic excess input tokens above baseline framing overhead that reveal hidden relay system prompts or billing padding.

### Why this risk matters

Hidden relay instructions can hijack model persona, steer tool behavior, waste context capacity, and inflate every billed API call.

### When to run this check

Run on newly onboarded API relays, unexpected billing spikes, or before deploying strict agentic workflows.

Many middleman relays prepend boilerplate jailbreak guards, persona overrides, or hidden routing tags. Even when the model conceals that text, usage accounting often leaves a clean positive offset.

## Detection Methodology, Evidence & Limitations

Pairs deterministic minimal user prompts with local reference token calculation inside @lmspeed/audit.

- **1. Probe**

Compute exact expected prompt token counts locally using baseline OpenAI message framing rules.

- **2. Inspect**

Send controlled low-noise completion requests and extract usage.prompt_tokens from JSON and SSE responses.

- **3. Conclude**

Compare observed vs expected overhead above chat-template margin and report excess token delta.

### How to read the verdict

Small fixed chat-template deltas pass; large unexplained offsets trigger warn/fail with observed vs expected delta metrics.

### Evidence basis & thresholds

Delta between locally estimated input tokens and API-reported prompt_tokens across repeated probe payloads.

### Scope limits & abstention conditions

Cannot measure silent injection if a relay rewrites or strips usage.prompt_tokens to match client-side guesses, or omits usage metadata entirely.

### Verification Sources & Baselines

Implemented in @lmspeed/audit v0.3.3 (ruleset independent-2026-11-22.2); supplementary capability/injection design cross-checked against Veridrop, LLMprobe-engine, and meow-llm-detector specs.

- [lmspeed/audit (v0.3.3)](https://github.com/nexmoe/lmspeed-audit)Open-source LMSpeed probe engine, catalog registry, and calibrated fingerprint protocols.

- [Liu et al., "Your Agent Is Mine" (arXiv:2604.08407)](https://arxiv.org/abs/2604.08407)Research basis for AC-1 tool-call hijacking, AC-2 error leakage, and Web3 injection threats.

## Frequently Asked Questions

### What causes extra prompt tokens on an OpenAI-compatible relay?

Common causes include hidden system prompt injection, default template wrappers, or inflated billing multipliers in proxy gateways.

### Does small overhead (1–15 tokens) always mean prompt injection?

No. ChatML or model-specific message formatting wrappers naturally add small fixed template tokens.

### What if the relay hides usage telemetry completely?

Combine Token Injection with Prompt Extraction and Instruction Conflict checks so silent wrappers can still be caught behaviorally.

### Does this check inspect billed cache-read tokens too?

It tracks total reported prompt_tokens alongside baseline expectations to flag unusual padding regardless of upstream caching.

## All audit checks by category

Explore every single-check audit tool grouped by risk domain, with Fingerprint Detection pinned first for model-authenticity verification.

### Fingerprint Detection

Pinned · Priority Group3

- [Model distribution fingerprint](https://lmspeed.net/audit/model-fingerprint)

- [Numeric fingerprint screening](https://lmspeed.net/audit/numeric-fingerprint)

- [Tokenizer fingerprint](https://lmspeed.net/audit/tokenizer-fingerprint)

### Prompt & Injection Security

6

- Token injection

- [Prompt extraction](https://lmspeed.net/audit/prompt-extraction)

- [Instruction conflict](https://lmspeed.net/audit/instruction-conflict)

- [Jailbreak identity](https://lmspeed.net/audit/jailbreak-identity)

- [Conditional injection](https://lmspeed.net/audit/conditional-injection)

- [Web3 injection](https://lmspeed.net/audit/web3-prompt-injection)

### Response & Stream Integrity

5

- [Stream integrity](https://lmspeed.net/audit/stream-integrity)

- [Stream consistency](https://lmspeed.net/audit/stream-consistency)

- [Tool substitution](https://lmspeed.net/audit/tool-substitution)

- [Error leakage](https://lmspeed.net/audit/error-leakage)

- [Latency variance](https://lmspeed.net/audit/latency-variance)

### Capabilities & Context Limits

7

- [Context window and recall](https://lmspeed.net/audit/context-window)

- [Tool permissions](https://lmspeed.net/audit/tool-calling)

- [Structured JSON output](https://lmspeed.net/audit/structured-output)

- [Image understanding](https://lmspeed.net/audit/image-understanding)

- [PDF understanding](https://lmspeed.net/audit/pdf-understanding)

- [Quality canary](https://lmspeed.net/audit/quality-canary)

- [Quality comparison](https://lmspeed.net/audit/quality-comparison)

### Related LMSpeed benchmarks & methodology

- [Full 25-Check Provider Audit](https://lmspeed.net/audit)

- [3-Stage Fingerprint Pipeline](https://lmspeed.net/audit#fingerprint-detection)

- [LLM API Speed Test](https://lmspeed.net/speed)

- [Provider Directory](https://lmspeed.net/provider)

- [Model Directory & Pricing](https://lmspeed.net/model)

- [Benchmark Methodology](https://lmspeed.net/methodology)

---
Cite as: Detect hidden system prompt injection in billed input tokens — LMSpeed, https://lmspeed.net/audit/token-injection (retrieved 2026-12-04)
