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.
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.
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
Introducing Olmicro: Small, efficient hybrid models built in the open
Researchers and developers can now experiment with small, long-context language models on modest hardware, accelerating research and reducing compute costs.
Building on Nemotron 3.5 Parse: Open Data, Fine-Tuning, and Faster Inference
NVIDIA open-sources the datasets, training recipe and inference stack behind Nemotron 3.5 Parse, letting developers fine-tune custom document-extraction models today.
System-wide ad-blocking that catches trackers browser extensions can't
Desktop apps and OS components can now be ad-blocked system-wide, not just browser traffic, closing a privacy gap browser extensions cannot reach.
A flight recorder for AI agents that even auditors can verify offline
Teams running AI agents on production systems get tamper-evident, auditor-verifiable records of every tool call instead of logs the agent could rewrite.
A Python client for Ollama, sync or async, local or cloud
Python developers can now use one identical client to call Ollama models locally or via Ollama's cloud API, removing boilerplate and rewriting when scaling up.