Blog

Protecting LLM systems from prompt attacks

· security, llm, prompt-engineering

My article “Protecting LLM Systems from Prompt Attacks” appeared in Hakin9 Magazine, in the issue LLM Mayhem – Hackers’ New Anthem, which is about the security problems that come with large language models. It builds on the “Prompt Engineering” chapter of Chip Huyen’s book AI Engineering.

The problem

A well-written prompt is what makes an LLM useful. The same openness is what makes it vulnerable: the model cannot always tell your instructions apart from an attacker’s, because both arrive as text in the same input. Once an application has access to data or tools, that confusion can lead to leaked data, misinformation, unwanted actions or a copied product.

What the article covers

  • Four kinds of attack: prompt injection, jailbreaking, prompt extraction and information extraction, and what each one puts at risk.
  • How to measure robustness: the trade-off between refusing too often and letting attacks through, and open tools for testing a system against known attacks.
  • Three levels of defense:
    • the model level, where training teaches the model which instructions take priority;
    • the prompt level, where clear, well-placed instructions keep the model on its task;
    • the system level, where isolation, human approval, filtering and monitoring limit what an attack can do.

The main point: no single defense is enough, and none of them removes the risk entirely. Security for LLM systems is an ongoing balance between keeping the application useful and keeping it safe.

Read it

The full article is in the LLM Mayhem issue of Hakin9. Thanks to Grzegorz Pielot at Hakin9 for the invitation and the support along the way.