Recent public reports

Redacted audit reports that included this probe.

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. 1. Probe

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

  2. 2. Inspect

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

  3. 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.

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.