TL;DR

For those short on time, here are the key takeaways from the research:

  • The D-SEC Framework – Our Dynamic Security and Utility Threat Model helps manage the trade-offs between security and usability while addressing the dynamic nature of LLM security.
  • Balancing Security and Usability – LLM defenses affect application usability beyond simply blocking interactions. Developers must carefully consider the security-utility tradeoff.
  • Evolving Threats Require Adaptive Defenses – As attackers continuously adapt their strategies based on model feedback, static defenses fall short. Adaptive approaches provide significantly better protection.
  • Three Key Strategies for Stronger Defenses:
    • Restricting Application Scope – Narrowing application functionality through the system prompt enhances security.
    • Defense-in-Depth – Combining multiple security layers offers substantial protection benefits.
    • Adaptive Security – User behavior during interactions provides valuable insights for strengthening defenses.

Balancing Security and Utility: The Core Challenge

The central theme of the research is the delicate balance between security and utility. Mateo explains, “Unlike traditional applications, security in LLMs isn’t just about blocking attacks. It’s about ensuring the system remains usable for legitimate users.”

Overly strict defenses can degrade the user experience, causing the model to refuse benign requests or provide suboptimal responses.

The interplay between security and usability is especially delicate when defenses are implemented in the system prompt. While this approach enhances security, it can reduce the length and quality of application responses. As Niklas points out, “Every red-teaming exercise should measure not just how well the defense blocks attacks but also how it impacts the application’s utility.”

The D-SEC threat model involves three parties: the developer, the attacker, and the user. The developer builds and protects an LLM application. Both users and attackers interact with the application. The developer's goal is to create a defense that stops attacks while having minimal impact on the user experience.

Why Adaptive Defenses Matter

Static defenses often create a false sense of security. Mateo emphasizes, “Attackers don’t operate in a vacuum. They refine their strategies based on the feedback they receive from the model. Without adaptive defenses, systems remain vulnerable to the attacker getting wiser. Attackers are often stopped by the defenses in Gandalf on their first attempt, but eventually they all fall.”

To address this, the research introduces the Dynamic Security and Utility Threat Model (D-SEC), which incorporates two crucial elements:

  • Dynamic Attacker Behavior: Models how attackers learn and adapt over time.
  • Security-Utility Trade-offs: Evaluates the impact of defenses on both malicious and benign users.

Niklas explains, “D-SEC allows us to think about the problem in the right way, balancing the need to block attacks with the goal of preserving a positive user experience.”

Adaptive defenses that block attempts past a block threshold enhance security. A defense can decide to err on the side of caution and block attackers after a few suspicious interactions. This figure is clear: blocking all users after four suspicious prompts, for example, leads to a significant boost in security without large impacts on usability. 

Practical Strategies for Better Security

Lakera’s research identified three strategies that significantly improve LLM security while maintaining usability:

  • Restricting Application Domains: Narrowing the scope of an LLM’s functionality reduces its attack surface. “If an LLM is only supposed to handle financial data, make that explicit in the system prompt,” suggests Mateo. Their experiments showed that more restricted applications were inherently more secure.
  • Defense-in-Depth: Combining multiple, distinct defenses creates a stronger overall security posture. Mateo adds, “Even if individual defenses can be bypassed, their combination makes it much harder for attackers to succeed.”
  • Adaptive Defenses: Using session history to identify suspicious users early and block them, depriving attackers of an unlimited attack budget.

The paper introduces metrics such as Session Completion Rate (SCR) and Attacker Failure Rate (AFR), which allow practitioners to select the defense strategy that provides the defenses they need without impacting usability too much.

Defense in depth is extremely useful! This shows that different defenses natively specialize in different types of attacks; combining them is therefore a good idea.

The Role of Gandalf in LLM Security

Gandalf, a gamified red-teaming platform, has been instrumental in advancing our understanding of LLM vulnerabilities. Mateo explains, “With millions of players globally contributing over 25 years of gameplay, Gandalf uncovers vulnerabilities that static benchmarks often miss.”

Game overview and interface. Each player passes multiple levels sequentially with increasing difficulty (right). C levels are randomized in their order. A user playing a single level corresponds to a session (left). The level description, which is shown to the player, hints at the defense used. The player sends prompts for the LLM to answer. In the example shown, they ask for the password in reverse, which bypasses the defense (a substring check). When the player has found the password, they can enter it in a separate text field to advance to the next level. A session ends once the player enters the correct password or stops playing.

Niklas highlights two key advantages of Gandalf:

  • Human Creativity: Players generate diverse, adaptive attacks that mimic real-world adversaries.
  • Accurate Feedback: Gandalf’s interactive nature allows precise labeling of successful attacks, even when they’re subtle or unconventional.

The insights from Gandalf have directly informed the development of adaptive defense strategies, demonstrating the power of community-driven initiatives in AI security.

Challenges and Trade-offs

The interplay between security and usability presents unique challenges for LLMs. Niklas notes, “Overly strict defenses can make applications less useful, blocking benign requests or reducing response quality.”

This trade-off becomes even more pronounced in autonomous agents, where defenses influence decision-making processes. Mateo stresses the importance of designing defenses that integrate seamlessly with applications, ensuring they remain functional and effective.

In traditional security, defenses may unintentionally block legitimate users. LLM security takes this to new levels. This figure illustrates how instructing an LLM to prioritize security results in shorter and noticeably different responses compared to an unprotected LLM, highlighting the subtle impact on usability.

Play Gandalf and explore adaptive security firsthand!

Conclusion

Adaptive defenses represent the future of LLM security. They offer a way to protect systems while preserving their utility, addressing the challenges posed by evolving attacks. Tools like Gandalf and frameworks like D-SEC are paving the way for a more secure AI landscape.

To dive deeper into the research, check out the full paper, "Gandalf the Red: Adaptive Security for LLMs."