Papers › Defending LLMs against Jailbreaking Attacks via Backtranslation

Defending LLMs against Jailbreaking Attacks via Backtranslation

26 Feb 2024arXiv:2402.16459archive 2025-07-28

Yihan Wang, Zhouxing Shi, Andrew Bai, Cho-Jui Hsieh

Although many large language models (LLMs) have been trained to refuse harmful requests, they are still vulnerable to jailbreaking attacks which rewrite the original prompt to conceal its harmful intent. In this paper, we propose a new method for defending LLMs against jailbreaking attacks by ``backtranslation''. Specifically, given an initial response generated by the target LLM from an input prompt, our backtranslation prompts a language model to infer an input prompt that can lead to the response. The inferred prompt is called the backtranslated prompt which tends to reveal the actual intent of the original prompt, since it is generated based on the LLM's response and not directly manipulated by the attacker. We then run the target LLM again on the backtranslated prompt, and we refuse the original prompt if the model refuses the backtranslated prompt. We explain that the proposed defense provides several benefits on its effectiveness and efficiency. We empirically demonstrate that our defense significantly outperforms the baselines, in the cases that are hard for the baselines, and our defense also has little impact on the generation quality for benign input prompts. Our implementation is based on our library for LLM jailbreaking defense algorithms at \url{https://github.com/YihanWang617/llm-jailbreaking-defense}, and the code for reproducing our experiments is available at \url{https://github.com/YihanWang617/LLM-Jailbreaking-Defense-Backtranslation}.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.16459")

Code

Syntology Ran 12 of 16 code samples harvested from 2 repositories linked to this paper; 4 have no recorded run. Of those that ran: 1 ran · fixture could not drive it; 11 ran with no contract checked.

By repository: official repository: 16 samples from 2 repositories, 12 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

yihanwang617/llm-jailbreaking-defense officialmentioned in papermentioned on GitHubMIT report
yihanwang617/llm-jailbreaking-defense-backtranslation officialmentioned in papermentioned on GitHubBSD-3-Clause report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

16 samples harvested; 12 ran; 0 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · fixture could not drive it
11ran
4unverified

Licence: 0 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

extract_json yihanwang617/llm-jailbreaking-defense-backtranslation/PAIR/common.py official repository ran fingerprinted BSD-3-Clause (permissive) · d7a1e728e5b74d3f · report
get_attacker_system_prompt yihanwang617/llm-jailbreaking-defense-backtranslation/PAIR/system_prompts.py official repository ran fingerprinted BSD-3-Clause (permissive) · 41afa37a7f32ead4 · report
get_init_msg yihanwang617/llm-jailbreaking-defense-backtranslation/PAIR/common.py official repository ran fingerprinted BSD-3-Clause (permissive) · e5d6b48c8179a8d3 · report
get_judge_system_prompt yihanwang617/llm-jailbreaking-defense-backtranslation/PAIR/system_prompts.py official repository ran fingerprinted BSD-3-Clause (permissive) · 581e46fff7eed12a · report
get_parser yihanwang617/llm-jailbreaking-defense-backtranslation/arguments.py official repository ran BSD-3-Clause (permissive) · 99b925af061ea18f · report
get_recursive_key yihanwang617/llm-jailbreaking-defense-backtranslation/utils.py official repository ran BSD-3-Clause (permissive) · 5de204a83268b25b · report
load_model_and_tokenizer yihanwang617/llm-jailbreaking-defense-backtranslation/attacks/autodan.py official repository ran BSD-3-Clause (permissive) · 3bcc8e42ea5e457e · report
load_prompts yihanwang617/llm-jailbreaking-defense-backtranslation/utils.py official repository ran BSD-3-Clause (permissive) · 37cddda277e8045d · report
load_tokenizer yihanwang617/llm-jailbreaking-defense/llm_jailbreaking_defense/models.py official repository ran MIT (permissive) · ee5d16865ecd5e2b · report
parse_args yihanwang617/llm-jailbreaking-defense-backtranslation/arguments.py official repository ran BSD-3-Clause (permissive) · 15642ad4bb2fccb7 · report
process_target_response yihanwang617/llm-jailbreaking-defense-backtranslation/PAIR/common.py official repository ran BSD-3-Clause (permissive) · 9fdfb4537f5fd761 · report
roulette_wheel_selection yihanwang617/llm-jailbreaking-defense-backtranslation/attacks/autodan.py official repository ran · fixture could not drive it fingerprinted BSD-3-Clause (permissive) · 1fe7dbe6f5cc4593 · report
autodan_sample_control yihanwang617/llm-jailbreaking-defense-backtranslation/attacks/autodan.py official repository unverified BSD-3-Clause (permissive) · 6c4da698c1f967dc · report
get_embedding_layer yihanwang617/llm-jailbreaking-defense-backtranslation/GCG/llm_attacks/base/attack_manager.py official repository unverified BSD-3-Clause (permissive) · 0bf2136a7171ae80 · report
get_embedding_matrix yihanwang617/llm-jailbreaking-defense-backtranslation/GCG/llm_attacks/base/attack_manager.py official repository unverified BSD-3-Clause (permissive) · 688aaeba506e3329 · report
get_embeddings yihanwang617/llm-jailbreaking-defense-backtranslation/GCG/llm_attacks/base/attack_manager.py official repository unverified BSD-3-Clause (permissive) · f556dda0785f3c77 · report

Tasks

Language Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections