typebraintank dispatch
headlineHow a forged chat marker's reserved token lends planted instructions authority
dekHolding an injected text's bytes fixed and changing only how the server tokenizes its forged markers shows where, on most models tested, a chat-template attack's power lies.
date2026-11-23
sectionAlignment · Prompt injection
datelineBeijing · Peking University
paperSame Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injection
statuspreprint, not peer reviewed
originalhttps://braintank.ai/a/arxiv-2609.35932.html
cite
text

An AI agent that reads web pages, emails or the output of software tools is constantly taking in text written by strangers. Prompt injection exploits this. An attacker hides instructions inside content the agent will read, such as a tool's response, hoping the agent will obey them instead of its user. One especially potent version dresses the planted instruction in the model's own conversational formatting, so that it looks as though a fresh instruction from the system has begun. Chang and colleagues reported in 2026 that this disguise raised attack success on the AgentDojo benchmark from 5.18% to 32.05%.

Why does the disguise work so well? A 2026 preprint on arXiv, not yet peer reviewed, by Yan Zhan of Peking University and colleagues, separates two things that template attacks change together: what a forged marker says, and how it actually reaches the model. On most of the models they tested, the authors find that the second matters a great deal.

The idea

Language models do not read text directly. A tokenizer, the software that converts text into the numerical ids a model processes, first chops the input into pieces. Chat models also rely on a chat template: fixed formatting, with markers such as `<|im_start|>`, that shows where each speaker's turn (system, user, tool or assistant) begins and ends. These markers normally become reserved tokens, vocabulary entries set aside for structure. Each has its own learned input embedding, the list of numbers the model looks up for that id, and during post-training the model meets these tokens only at genuine turn boundaries.

The same marker string can instead be encoded as several ordinary subword tokens, the everyday text fragments a tokenizer uses for words. Either way, the string decodes to exactly the same characters, so the two versions look identical in a log. The authors point out that template attacks alter the visible text and the token ids at once, while tokenizer-level attacks re-segment strings that never had a reserved id. The one study that did test the contrast directly, by Deng and colleagues on the Qwen3-8B model, reported essentially no effect.

The distinction matters to defenders because tokenization happens on the server. The attacker supplies characters; the operator decides how they become ids. Hugging Face tokenizers offer an option that encodes special markers as ordinary subwords, and this is a standard mitigation. The paper asks how much of the attack that option actually removes.

How this paper puts it to work

In the authors' threat model, the attacker controls only the characters of a single tool result, and an attack succeeds if the agent then calls a tool the attacker named. They draw test cases from InjecAgent, a prompt-injection benchmark that checks the tool call an agent makes after reading a poisoned tool response, using 400 cases for each of two attack types: direct harm and data stealing. The forged payload, one fixed string per model family, closes the tool's turn, opens a fake system turn carrying the attacker's instruction and reopens a user turn, using four reserved control tokens.

Each case is then fed to the model under three byte-identical conditions and one plain-text comparison. In Reserved, the forged markers keep their special ids. In Split, they are spelled out as ordinary subwords, as the standard mitigation does. Because splitting adds 7 to 33 tokens, a Matched condition keeps the reserved ids but breaks up other text at the start of the tool response so the token count equals Split's. A Plaintext condition writes the roles as ordinary words, such as 'System:'. The key quantity, which the authors call the identity gap, is Matched minus Split, measured in percentage points (the plain difference between two percentages). It isolates the value of the reserved id itself, with the same characters and the same length.

The models were Qwen3-8B, Llama-3.1-8B-Instruct, GLM-4.5, Seed-OSS-36B-Instruct and, as a scale check, Qwen3-32B. Every case was checked before generation for byte identity, the presence or absence of reserved ids and matched token counts. Each configuration ran three to five times with greedy decoding, and a gap counted only if a paired statistical test was significant in every run.

What it shows, and what it does not

On Llama-3.1, GLM-4.5 and Seed-OSS-36B, removing the reserved ids cut attack success by 39 to 66 percentage points, while Matched stayed within 1.7 points of Reserved, so the extra tokens alone cost the attacker almost nothing. On Llama-3.1's direct-harm cases, success fell from 98.2% with reserved markers to 39.7% when they were split, below the 51.6% achieved by plain words. Qwen3-8B behaved differently: a gap of 8.1 points on direct harm and an insignificant 0.5 on data stealing. There, the authors find, the marker's text carries more of the effect, and the model appears to lean on its reasoning step to recognise the forged turn; suppressing that step widened the gap to 49.8 points. They attribute Deng and colleagues' null result to a ceiling effect, a measure already so close to its maximum that it could not register a drop. In a further experiment, swapping the reserved token's input vector for that of its nearest ordinary token restored the attack in full on Llama-3.1, though this did not hold on Qwen3-8B.

The authors are clear about the limits. InjecAgent scores the tool call the model emits, not whether anything was executed. On AgentDojo, which runs full multi-turn tasks and checks whether the attacker's goal was achieved, the gaps were 10.3 points for Qwen3-8B and 6.8 for Qwen3-32B, and positive in every model and task-suite combination of a second test. The work covers only self-hosted open-weight models; hosted services that accept only text strings are out of scope. Settings differed between families, so the authors caution against ranking them against each other.

Two findings complicate the picture for defenders. Among the 400 most-downloaded chat models on Hugging Face, 33 of 67 distinct tokenizer configurations declare tool-protocol markers such as `<tool_call>` that the standard option does not reach, and forged blocks built from these alone produced gaps of 9.4 to 19.9 points. And an adaptive attacker, one who knows the defence and searches for alternative spellings, recovered to within 1.6 to 12.2 points of the undefended attack, mostly using ordinary tokens whose vectors sit close to the reserved ones. The authors present their fixed-bytes contrast as a measuring tool for defenders rather than an attack, and propose applying it to injection-resistant trained models such as StruQ and SecAlign.