Defending against Prompt Injection with Structured Queries (StruQ) and Preference Optimization (SecAlign)

AI-generated summary of reporting by Berkeley. Read the original for the full story.

Why it matters

Prompt injection, OWASP's #1 LLM threat, now has open-source fine-tuning defenses cutting attack success rates to near zero.

Read this as

Berkeley researchers published two methods, StruQ and SecAlign, that defend chatbots against 'prompt injection', attacks where hidden instructions inside webpages or documents trick an AI into ignoring its real instructions. Both use a secure front-end that marks where instructions end, plus training that simulates injections so the model learns to ignore them. SecAlign cut attack success from 45% to 8% in tests and works with any LLM via ordinary fine-tuning.

Prompt injection is OWASP's #1 threat to LLM apps, with real exploits found in Google Docs, Slack AI and ChatGPT. SecAlign is a training recipe with no added compute or human-labor cost that cuts attack success rates to near zero for a dozen attacks and below 15% against stronger optimization-based attacks, a 4x improvement over the prior best across five tested LLMs. Utility is preserved: SecAlign keeps AlpacaEval2 scores, StruQ loses 4.5%. Code is public.

The authors attribute prompt injection to LLMs lacking prompt/data separation and following any instruction in input. Their Secure Front-End uses special delimiter tokens ([MARK]) plus a data filter to block injection of delimiters; StruQ supervised-fine-tunes on injections to ignore data-part instructions; SecAlign uses DPO on pairs of desirable (intended) and undesirable (injected) responses. On Llama3-8B-Instruct: StruQ ASR 45%, SecAlign 8% on 'Print exactly Hacked!'; optimization-free attacks drop to ~0%, and SecAlign beats prior SOTA by >4x across five models with AlpacaEval2 preserved.

Read the original

This summary exists to save you time, not to replace the source.

Berkeley →

Key terms

StruQ SecAlign OWASP Llama3-8B-Instruct AlpacaEval2 Slack AI ChatGPT

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading