Skip to content

StruQ: defending against prompt injection with structured queriesStruQ: Defending Against Prompt Injection with Structured Queries

arXiv· arXiv:2402.06363· USENIX Security 2025· Sizhe Chen, Julien Piet, Chawin Sitawarin, David Wagner·Indexed by this site · 26 days ago· Originally publishedDefenses
AI summary

The researchers propose StruQ, which uses structured queries to defend against prompt injection attacks on large language models, separating the prompt from user data into two channels, significantly improving resistance to prompt injection with little or no impact on usability. The system includes a secure front end that formats the prompt and user data into a special format, and a model specially trained to follow only the instructions in the prompt portion of the query; during training, a base (non-instruction-tuned) model is converted into a structured instruction-tuned model by adding to standard instruction-tuning data samples in which the data portion also contains instructions, and fine-tuning the model to ignore these instructions. Code is open-sourced at https://github.com/Sizhe-Chen/StruQ.

Read originalUSENIX Security 2025