Steering Dialogue Dynamics for Robustness against Multi-turn Jailbreaking Attacks

Hanjiang Hu, Alexander Robey, Changliu Liu
2/28/2025
cs.CLcs.CRcs.LG

Official code: HanjiangHu/NBF-LLM (17 stars, MIT, last commit 2025-03-04).

Abstract

Large language models (LLMs) are shown to be vulnerable to jailbreaking attacks where adversarial prompts are designed to elicit harmful responses. While existing defenses effectively mitigate single-turn attacks by detecting and filtering unsafe inputs, they fail against multi-turn jailbreaks that exploit contextual drift over multiple interactions, gradually leading LLMs away from safe behavior. To address this challenge, we propose a safety steering framework grounded in safe control theory, ensuring invariant safety in multi-turn dialogues. Our approach models the dialogue with LLMs using state-space representations and introduces a novel neural barrier function (NBF) to detect and filter harmful queries emerging from evolving contexts proactively. Our method achieves invariant safety at each turn of dialogue by learning a safety predictor that accounts for adversarial queries, preventing potential context drift toward jailbreaks. Extensive experiments under multiple LLMs show that our NBF-based safety steering outperforms safety alignment, prompt-based steering and lightweight LLM guardrails baselines, offering stronger defenses against multi-turn jailbreaks while maintaining a better trade-off among safety, helpfulness and over-refusal. Check out the website here https://sites.google.com/view/llm-nbf/home . Our code is available on https://github.com/HanjiangHu/NBF-LLM .

View on arXivView PDF

Code Implementations(1)

HanjiangHu/NBF-LLMOfficial100%
MIT

The official code for "Steering Dialogue Dynamics for Robustness against Multi-turn Jailbreaking Attacks".

170PythonFeb 26, 20251 years agoMIT

Similar Papers

Cite this paper

@article{hu2025steering,
  title  = {Steering Dialogue Dynamics for Robustness against Multi-turn Jailbreaking Attacks},
  author = {Hanjiang Hu and Alexander Robey and Changliu Liu},
  year   = {2025},
  eprint = {2503.00187},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.00187v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.00187.svg)](https://codeofpaper.com/paper/2503.00187)

Discussion