arxiv-2402-06363 · paperStruQ: Defending Against Prompt Injection with Structured Queries
Sizhe Chen, Julien Piet, Chawin Sitawarin, David Wagner
Created: 2024 · Ingested: 2026-09-02
This source: StruQ: Defending Against Prompt Injection with Structured QueriesHow much the field cites it — very heavily cited in the last 12 months243 in the last 12 months · 394 totalpublished 2024checked 2026-09-04243 citations in the last 12 months · 394 total · checked 2026-09-04
https://arxiv.org/abs/2402.06363(opens in a new tab)In brief
Separating prompt from data at the API level, and fine-tuning a base model to only obey the prompt channel, drives hand-crafted prompt injection to near zero without costing utility. StruQ combines a front-end that encodes prompt and data with reserved delimiter tokens ([MARK], [INST], [INPT], [RESP], [COLN]) and filters those strings plus ## from user data, with "structured instruction tuning": 50% clean Alpaca samples, 25% with a Naive injection, 25% with a Completion-Other injection, all trained to answer only the prompt-side instruction. Evaluated on Llama-7B and Mistral-7B against at least 15 attack types, using 208 AlpacaFarm samples per attack and AlpacaEval 1.0 for utility. All manual attacks drop to <2%; Completion-Real goes 96% to 0% on both models. Optimization-based attacks survive: TAP falls 97% to 9% on Llama (100% to 36% on Mistral), GCG only 97% to 58% (99% to 56%). Utility moves 67.2% to 67.6% on Llama and 80.0% to 78.7% on Mistral, against a 0.7% standard error. Ablations isolate the components: naive+completion augmentation gives 0% best-ASR versus 41% undefended, fake-delimiter augmentation is worse than useless (70%), and all-special delimiters give the best utility at equal security. Adaptive "near-miss" delimiters, 9 variants, are stopped. Baselines are test-time prompting defenses (39%-85% ASR) and a BIPIA reproduction. Limits: 2 7B base models, 1 instruction-tuning dataset, short AlpacaFarm data, injection only at the end of data, and no defense against gradient-access attackers. Treat channel separation as a strong fix for scripted injection and an open problem for optimized ones.
Written from the abstract by claude-opus-5 on 2026-09-05, with every figure checked against it. Not a substitute for the paper.
Referenced by
Claims in this catalog that draw on this source, and whether as support or counterpoint.
- supportsSeparating prompt and data with reserved delimiters and fine-tuning on that structure blocks most injections at little cost to utility.
- supportsSeparating instructions from data raises injection resistance substantially, but both published versions get their strength from fine-tuning the model on the separation, and both report improved robustness rather than elimination. Treat it as one layer of defense in depth; the prompt-only variant, without training, has no measured efficacy behind it here.