Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injection
Yan Zhan, Yunze Song, Mengkai Hou, Wanting Zhang, Shaobo Liu, Zhijun Gao
Peking University · National University of Singapore · BYD Company Limited · Shenzhen University
Published September 28, 2026 · on the feed September 30, 2026 · ▲ 7 · arXiv 2609.35932
The abstract
Prompt injection against LLM agents becomes much stronger when the injected instruction is wrapped in the model's own chat template. A forged template marker such as <|im_start|> can reach the model either as a single reserved control token or as a sequence of ordinary subword tokens. The two decode to exactly the same text, and because tokenization runs on the server, the defender rather than the attacker decides which one the model receives. We use this to measure how much of the injected instruction's authority comes from the reserved token's learned representation. Encoding the forged markers as subwords, with the text held fixed and a control for the extra tokens this adds, lowers attack success on the InjecAgent benchmark by 39 to 66 percentage points on three of four open-weight families, and the gap carries over to multi-turn agent tasks in AgentDojo. On Qwen3-8B the gap is 8 points, because without reserved ids the model still recognises the forged turn from its text by reasoning; suppressing the reasoning block widens the gap to 50. The authority sits in the single learned vector at the marker position: the mean of the marker's subword vectors does not reproduce it, the vector of the nearest ordinary token restores the attack on Llama-3.1, and an adaptive attacker who searches for non-reserved markers finds such embedding neighbours on three of four families. In every base and instruction-tuned pair we test, instruction tuning strengthens the model's preference for reserved markers. The standard mitigation, a tokenizer option that encodes special tokens as ordinary subwords, applies only to tokens a configuration declares special, so in 33 of 67 distinct tokenizer configurations, covering 255 of the 400 most-downloaded chat models on Hugging Face, it leaves intact the tool-protocol tokens through which agents read untrusted tool output, and the gap persists on that channel.
The Brief
3:05A short podcast summary of the paper. Written and voiced by AI.
Transcript
Same Bytes, Different Authority. Reserved-Token Representations in Chat-Template Prompt Injection. By Yan Zhan and five others, from Peking University, the National University of Singapore, and two other institutions. Published on the twenty-eighth of September. Its code repository is public and real: sixteen source files.
Prompt injection against LLM agents gets much stronger when the injected instruction is wrapped in the model's own chat template, complete with forged markers like the one that opens a new turn. Such a marker can reach the model in two ways: as a single reserved control token, or as a run of ordinary subword tokens. Both decode to exactly the same text. The claim here is that much of the injected instruction's authority does not come from that text at all. It sits in the learned representation of the reserved token, in a single vector at the marker's position.
The experiment exploits a simple fact about deployment. Tokenization happens on the server, so it is the defender, not the attacker, who decides which form the model receives. The authors hold the text fixed, encode the forged markers as subwords, and control for the extra tokens this adds. On the InjecAgent benchmark that lowers attack success by thirty-nine to sixty-six percentage points on three of four open-weight families, and the gap carries over to multi-turn agent tasks in AgentDojo.
The fourth family is the instructive exception. On Qwen3-8B the gap is only eight points, because even without reserved ids the model still recognises the forged turn from its text, by reasoning about it. Suppress the reasoning block and the gap widens to fifty.
Several probes pin the authority to the vector itself. Averaging the marker's subword vectors does not reproduce it. Substituting the vector of the nearest ordinary token restores the attack on Llama-3.1. And an adaptive attacker who searches for markers that are not reserved finds such embedding neighbours on three of four families. In every base and instruction-tuned pair tested, instruction tuning strengthens the model's preference for reserved markers.
That leads to the standard mitigation, a tokenizer option that encodes special tokens as ordinary subwords. It only applies to tokens a configuration declares special. In thirty-three of sixty-seven distinct tokenizer configurations, covering two hundred and fifty-five of the four hundred most downloaded chat models on Hugging Face, it leaves the tool-protocol tokens untouched. Those are the tokens through which agents read untrusted tool output, and on that channel the gap persists.
The measurements cover four open-weight families, with InjecAgent for single attacks and AgentDojo for multi-turn tasks. The effect is not uniform: one family shows a small gap because its reasoning recovers the forged turn from text alone, and the large gaps belong to the other three. The finding about instruction tuning holds in every pair tested, and the mitigation audit concerns the configurations of the most downloaded chat models on one hub.
Two strings that look identical on the page can carry very different weight inside a model, depending on which token ids spell them. That makes tokenization a defensive lever, and it also exposes a hole in the usual fix: the tokens agents use to read tool output often fall outside what the fix protects.
Paper Quest · 7 chapters · about 40 min
Play this paper
Learn it by doing: make the calls the authors made, guess the result before you see it, and defend it in a viva graded on your own words. Chapter 1 is right here.
Chapter 1 🧩 · The problem
Same text, different tokens. The quest starts with a question about where an attack's power lives.
You study attacks on LLM agents. An injected instruction hidden in a tool result works far better when it is wrapped in the model's own chat-template markers, forging what looks like a new user turn.
The road ahead
- 1 · The problem ~6 min A forged chat marker carries both its text and its token id, and past experiments rarely pulled the two apart cleanly to see which one gives the attack its power.
- 2 · What came before ~3 min
- 3 · The key idea ~9 min Feed the model the same marker bytes as either one reserved token or ordinary subwords, so any change in attack success belongs to the token itself.
- 4 · Choose your own research ~3 min
- 5 · Build the method ~8 min Build byte-identical prompts that differ only in marker encoding, control for length, measure attack success, then swap the marker's vector to locate the authority.
- 6 · The experiment ~6 min You’ll guess: When forged chat markers reach the model as ordinary subwords instead of reserved tokens, with the text unchanged, what happens to attack success on most model families?
- 7 · The viva ~5 min Three questions from the examiners, answered in your own words. Win it for the paper’s trophy.
Free, with Google or an email address. Your stars and progress are kept.