Key takeaways
- An LLM jailbreak defense prevents output that safety training should refuse, at four layers: input, weights, tokens, and conversation.
- Perplexity filtering is bypassed at roughly 80% attack success by repeating the prompt.
- Multi-turn attacks land 39.5% to 54.6% against production products, roughly double single-turn’s 20.7% to 28.3%.
Most articles about LLM jailbreak defense give you a list. Input filtering, output filtering, red teaming, alignment. Deploy all four, sleep well.
That list is not wrong. It’s just useless when you have to decide what to build first, on a real system, with a latency budget and a finite team.
So this page does something different. It maps each defense to the attack class it actually stops, the layer it belongs at, what it costs you in latency, and what the published numbers say about whether it works. Where the evidence says a defense fails, that’s here too.
Four numbers worth having in front of you before anything else:
- Automated attacks jailbreak GPT-4-Turbo and GPT-4o on more than 80% of prompts, and get past LlamaGuard doing it (Mehrotra et al., NeurIPS 2024)
- Multi-turn attacks succeed at 39.5% to 54.6% against production products, roughly double single-turn’s 20.7% to 28.3% (Unit 42, February 2025)
- Perplexity filtering, a standard input defense, is bypassed at about 80% attack success by repeating the prompt before the suffix (AmpleGCG, 2024)
- Rotating a model’s refusal direction internally dropped GCG success from 100% to 2.75% with no measurable capability loss (Sophos, CAMLIS 2025)
Every one of those is sourced and linked below.
What is an LLM jailbreak defense?
An LLM jailbreak defense is any control that prevents a user from manipulating a large language model into producing output its safety training was meant to refuse. Defenses operate at four layers: the input reaching the model, the model’s own weights, the tokens it generates, and the conversation surrounding both.
That four-layer framing matters more than any individual technique. Nearly every defense you’ll read about lives at exactly one of those layers, and attacks that route around a layer route around every defense sitting on it.
Jailbreaking overlaps heavily with prompt injection attacks, and the two get used interchangeably in a lot of writing. The distinction that matters operationally: injection is about overriding instructions, jailbreaking is about defeating safety behavior. Both sit inside the broader problem of LLM security.
Why single-layer defense keeps failing
Here’s the number that should reorganize your priorities.
Tree of Attacks with Pruning, published by Mehrotra and colleagues and accepted at NeurIPS 2024, uses one language model to iteratively rewrite jailbreak prompts against another. It jailbreaks GPT-4-Turbo and GPT-4o on more than 80% of prompts. It also gets past LlamaGuard, one of the most widely deployed guard models in production.
Read that last sentence again. A well-known input-classification defense, defeated by an automated attack that needs only black-box access.
Now pair it with Palo Alto Unit 42’s February 2025 study of 17 generative AI web products. Single-turn attacks landed safety violations 20.7% to 28.3% of the time. Multi-turn attacks landed 39.5% to 54.6% of the time. Their summary of the result: “All the investigated GenAI web products are vulnerable to jailbreaking in some capacity.”
The pattern across both: defenses tuned to catch a bad prompt lose to attacks that never send an obviously bad prompt.
The LLM jailbreak defense matrix
This is the part no competitor page gives you. Each defense, the layer it sits at, the attacks it stops, what it costs, and what the evidence says.
| Defense | Layer | Stops | Weak against | Latency cost | Evidence |
|---|---|---|---|---|---|
| Keyword and pattern filtering | Input | Copy-pasted public jailbreaks | Paraphrase, encoding, novel prompts | Negligible | Bypassed by any rewriting attack |
| Perplexity filtering | Input | Gibberish adversarial suffixes (GCG-style) | Fluent attacks, and prompt repetition | Low | Bypassed at 80% ASR by AmpleGCG |
| Paraphrasing and retokenization | Input | Suffix and token-splitting attacks | Semantic attacks, roleplay | Adds a model call | Degrades benign task quality |
| Guard model classification | Input + output | Known harmful categories | Automated iterative attacks | ~1 second per query | Circumvented by TAP |
| Alignment and RLHF | Model | Direct harmful requests | Roleplay, many-shot, encoding | None at inference | The baseline every attack targets |
| Adversarial training | Model | Attack families seen in training | Novel attack classes | None at inference | Coverage-limited by definition |
| Activation-space hardening | Model | Precomputed transferable attacks | Fresh per-instance attacks | None at inference | GCG success 100% to 2.75% (Sophos) |
| Decoding-time steering | Output | Harmful continuations mid-generation | Attacks that never look harmful token-by-token | Moderate, per token | Underdeployed commercially |
| Output content filtering | Output | Harmful text reaching the user | Leaked system prompts, subtle harm | Low to moderate | Standard, necessary, insufficient |
| Conversation monitoring | Session | Crescendo, many-shot, escalation | Single-turn attacks (already covered) | Low | Addresses the largest measured gap |
| Red teaming | Process | Unknown unknowns | Nothing, if you never do it | Engineering time | The only way to find your own gaps |
Two things fall out of that table.
First, the four defenses everybody writes about all cluster at the input and model layers. The output and session layers are comparatively empty in commercial practice, and that’s exactly where the measured attack success is highest.
Second, no row in that table is sufficient alone. Not one.
What the published effectiveness numbers actually say
Every figure below comes from a named study with a stated method. This is the comparison nobody assembles, so read the methodology column as carefully as the result.
| Defense or attack | Result | Tested against | Method | Source |
|---|---|---|---|---|
| Activation-space salting | GCG success 100% to 2.75% | Llama-2-7B-Chat | 300 GCG jailbreaks, AdvBench prompts | Sophos, CAMLIS 2025 |
| Activation-space salting | GCG success 100% to 1.35% | Vicuna-7B | Same | Sophos, CAMLIS 2025 |
| Perplexity filtering | Bypassed at ~80% ASR | Llama-2-7B-Chat | Prompt repeated before suffix | AmpleGCG, 2024 |
| LlamaGuard | Circumvented | GPT-4-Turbo, GPT-4o | Automated tree search, black-box | TAP, NeurIPS 2024 |
| Production guardrail stacks | 20.7 to 28.3% ASR | 17 GenAI web products | Single-turn attacks | Unit 42, Feb 2025 |
| Production guardrail stacks | 39.5 to 54.6% ASR | Same 17 products | Multi-turn attacks | Unit 42, Feb 2025 |
| Safety alignment alone | Compliance rises past a threshold | Claude 2.0 and others | Up to 256 faux in-context exchanges | Anthropic, April 2024 |
Three caveats before you use these numbers to make a decision. The salting results come from one research group on two small open models against one attack family, so treat them as a promising direction and not a settled result. The Unit 42 percentages are ranges across a product set, not a per-product score, and your own stack could sit anywhere inside or outside them. And every one of these is a snapshot: the perplexity row is what happens to a defense that looked solid a year earlier.
Input-layer defenses
The input layer is where most teams start, because it’s the cheapest place to intervene and you don’t have to touch the model.
Keyword and pattern filtering catches the public jailbreak prompts circulating on forums. It’s worth deploying and it’s worth about a week of protection. Attackers rephrase.
Perplexity filtering measures how statistically unnatural a prompt is. Gradient-based attacks like Greedy Coordinate Gradient produce adversarial suffixes that look like keyboard noise, and noise has high perplexity. Jain and colleagues evaluated it as a baseline defense in 2023 and it does catch optimized-token attacks.
Then it got broken by something almost insultingly simple. The AmpleGCG work showed that repeating the prompt template a few times before attaching the adversarial suffix drags the whole sequence’s perplexity back under the threshold, recovering roughly 80% attack success against the filter.
So: deploy it, because it’s nearly free, and don’t count it. Against a fluent roleplay prompt it was never going to tell you anything anyway, because the prompt reads like ordinary English.
Paraphrasing and retokenization rewrite the user’s input before the model sees it, breaking the precise token sequences that optimized attacks depend on. The cost is real: you’re adding a model call to every request, and paraphrasing sometimes mangles legitimate technical queries. If your users paste code or structured data, test this carefully before shipping it.
Guard models are classifiers trained specifically to flag unsafe prompts and responses. LlamaGuard, PromptGuard, and WildGuard are the open ones people benchmark against, and they’re the same category of control as the AI agent guardrails you’d deploy around a tool-using system. They’re a real improvement over regex. They are also, per the TAP results, defeatable by an automated attacker with no access to your weights.
Basic input normalization is cheap and catches a surprising amount of encoding-based evasion:
import unicodedata
def normalize_input(text: str) -> str:
# Collapse homoglyphs and compatibility characters to canonical form
text = unicodedata.normalize("NFKC", text)
# Strip zero-width and directional control characters
return "".join(c for c in text if unicodedata.category(c) != "Cf")
That won’t stop a determined attacker. It will stop a lot of automated ones, and it runs in microseconds.
Model-layer defenses
Model-layer work changes the weights. It costs nothing at inference time, which makes it the most attractive layer economically and the slowest to iterate on.
Alignment and RLHF are the baseline. Every model you’d deploy has been through safety fine-tuning. Every attack technique in this article was developed specifically to get around it.
Adversarial training feeds known attacks back into the training loop, the same logic that underpins defending against adversarial attacks generally. It works on what you trained against. The limitation is structural rather than fixable: you can only train against attacks that exist yet.
Activation-space hardening is the most interesting recent direction, and almost nobody covers it. Sophos presented a technique at CAMLIS 2025 they call LLM salting, which rotates the internal activation subspace responsible for refusal behavior. The idea borrows from password salting: if every deployed instance refuses in a slightly different internal direction, a jailbreak precomputed against one instance stops transferring to the others.
Their reported results, measured over 300 GCG jailbreaks per model using prompts from AdvBench: attack success against Llama-2-7B-Chat dropped from 100% to 2.75%, and against Vicuna-7B from 100% to 1.35%. MMLU accuracy came in at 46.8% and 49.2%, which they describe as statistically indistinguishable from the unsalted models. The models didn’t get dumber.
Those are strong numbers against one attack family, from one research group, on two small open models. Treat them as a promising signal rather than a solved problem. But the underlying insight generalizes: attack transferability is a load-bearing assumption for attackers, and breaking it is cheaper than making any single model unbreakable.
Output and decoding-layer defenses
Here’s the abandoned layer.
Search for LLM jailbreak defense and you’ll find input filtering on nearly every page and decoding-time defense on almost none. Meanwhile the academic literature has been building here for two years. SafeDecoding, an ACL 2024 paper, works from the observation that safety disclaimers still show up among the top-ranked tokens even when a jailbreak has pushed harmful continuations to the front. It amplifies those disclaimer tokens and suppresses the ones matching the attack’s objective. RAIN takes a different route: the model evaluates its own partial output and rewinds to a safer point when it detects trouble, with no fine-tuning and no weight updates at all.
Why does this layer matter? Because it’s the last place you can intervene where the model’s actual behavior is visible. An input filter guesses what a prompt will produce. A decoding-time defense watches what it’s producing.
The tradeoff is honest: you’re doing extra computation per token, not per request. On long generations that adds up, and for a chat product with streaming responses your users will feel it.
Output content filtering is the version everyone already runs. Scan the completed response, block it if it trips a policy. Necessary. Also the easiest layer to under-scope, because most implementations look for harmful content categories and miss system prompt leakage entirely. If your filter has never blocked a response for disclosing its own instructions, that’s not evidence it isn’t happening.
Defending multi-turn attacks
If you fix one thing after reading this page, fix this one.
The Unit 42 numbers again: multi-turn attacks succeeded at roughly double the rate of single-turn attacks across 17 products. Crescendo attacks escalate gradually across a conversation, each message individually benign. Many-shot jailbreaking, published by Anthropic in April 2024, floods a long context window with fabricated dialogue where an AI assistant answers progressively harmful questions, then makes the real request. Anthropic tested it out to 256 faux exchanges. A handful of examples doesn’t work. Past a threshold, compliance climbs, and it climbs faster on larger models, because the same in-context learning ability that makes them useful is the thing being exploited. As context windows keep growing, the attack surface for this one grows with them.
Neither attack contains a suspicious prompt. Both are invisible to any defense that evaluates one message at a time.
So what actually works at the session layer:
- Score the conversation, not the message. Run your classifier over a sliding window of recent turns, not just the current input.
- Track trajectory. A session that drifts steadily toward a restricted topic across eight turns is a stronger signal than any single turn provides.
- Watch context saturation. A sudden flood of in-context examples right before a request is the many-shot signature.
- Reassert instructions periodically. Re-injecting system constraints deeper into long conversations costs tokens and closes a real gap.
- Rate-limit per session, not just per user. Automated iterative attacks like TAP need many queries. Making queries expensive is a defense the attack literature rarely accounts for.
I’d argue this is where the gap between published defense advice and measured attack success is widest. The advice is written for single-shot attacks. The attacks stopped being single-shot a while ago.
What each defense actually costs
Nobody writes about this, and it’s the first question any engineer asks.
CyberArk’s researchers put guardrail overhead at roughly one second of added latency per query, plus the compute cost of running the classifier. For a batch pipeline, irrelevant. For a streaming chat interface where users judge quality by time-to-first-token, that’s the difference between a product that feels fast and one that doesn’t.
Rough shape of the tradeoffs:
| Defense | Added latency | Added compute | Ongoing engineering |
|---|---|---|---|
| Pattern filtering | Microseconds | Trivial | Constant rule updates |
| Perplexity filtering | Milliseconds | One forward pass | Low |
| Paraphrasing | Full model call | Significant | Quality regression testing |
| Guard model | ~1 second | Second model inference | Retrain as attacks evolve |
| Decoding-time steering | Per token | Significant | High |
| Conversation monitoring | Milliseconds | Windowed classification | Moderate |
| Model-layer hardening | None | One-time training | Repeat per model version |
Model-layer defenses win on inference economics and lose on iteration speed. Input and session defenses are the reverse. Most teams should run cheap controls at every layer before running an expensive control at one.
How do you know your defense works?
You measure attack success rate. Not “we deployed guardrails.” A number, against a fixed set of attacks, tracked across releases.
Three public benchmarks exist for this, and commercial security content almost never mentions them:
- AdvBench (Zou et al., 2023) provides 520 harmful-behavior prompts paired with target outputs. It’s the set Sophos used for the salting evaluation above, and the de facto starting point.
- HarmBench from the Center for AI Safety standardizes automated red teaming. The paper itself compares 18 red teaming methods against 33 models and defenses, so you’re measuring against a published baseline rather than an internal one.
- JailbreakBench maintains an open leaderboard, an evaluation library, and the JBB-Behaviors dataset. Use it when you want your number to be comparable to someone else’s.
Run one before you ship a defense and after. If your ASR didn’t move, your defense didn’t work, regardless of what the vendor slide said.
Then run AI red teaming on a repeating schedule, because the defense you benchmarked against last quarter’s attacks is not the defense you have. Perplexity filtering was a credible control in 2023 and a bypassed one by 2024. Guard models looked solid until TAP walked through LlamaGuard. Every technique in this article has an expiry date you won’t be told about in advance.
Mapping defenses to OWASP, NIST, and MITRE
If you need to justify this work to a risk committee, the vocabulary already exists.
| Framework | Relevant entry | What it covers |
|---|---|---|
| OWASP Top 10 for LLM Applications | LLM01:2025 Prompt Injection | Direct and indirect injection, the category jailbreaks sit under |
| OWASP Top 10 for LLM Applications | LLM05:2025 Improper Output Handling | Why output validation is a control, not a nicety |
| OWASP Top 10 for LLM Applications | LLM07:2025 System Prompt Leakage | The failure mode most output filters miss |
| NIST AI 100-2e2025 | Adversarial ML taxonomy | Shared terminology for attack classes, expanded in March 2025 to cover generative AI and prompt injection |
| NIST AI Risk Management Framework | Govern, Map, Measure, Manage | Where continuous red teaming lives in a governance program |
| MITRE ATLAS | Adversarial tactics for AI systems | Attack technique catalog, structured like ATT&CK |
| EU AI Act | Article 55, GPAI models with systemic risk | Adversarial testing is a legal obligation, not a best practice, since 2 August 2025 |
That last row is the one that changes conversations. For general-purpose models above the systemic-risk threshold, adversarial testing and incident reporting became binding obligations under Article 55 rather than something a security team has to argue for on merit. Mapping your controls to LLM01 and citing ATLAS technique IDs converts an engineering argument into one a compliance function can act on, which is the same move that makes any AI governance framework useful rather than decorative.
A layered defense you can actually deploy
In order, cheapest and highest-return first:
- Normalize every input. Unicode canonicalization, strip control characters, reject unexpected encodings. Microseconds, catches automated evasion.
- Filter output for both harmful content and system prompt leakage. Most teams do the first and skip the second.
- Score conversations, not messages. Sliding window over recent turns. This is where the measured gap is largest.
- Add a guard model at input and output. Knowing it’s defeatable by determined attackers, deploy it anyway. It raises the floor.
- Rate-limit per session. Iterative automated attacks need query volume. Take that away.
- Benchmark before and after. AdvBench or HarmBench, tracked as a release metric.
- Red team on a schedule. Quarterly minimum, and after every model version change. Fold it into your AI runtime security practice rather than treating it as a separate audit event.
- Then consider model-layer work. Adversarial training or activation-space hardening, once the cheap layers are in place and you have measurements proving what’s still getting through.
Steps 1 through 5 are a few weeks of engineering. Step 8 is a research project. Do them in that order.
Frequently asked questions
What is jailbreaking in an LLM?
Jailbreaking is manipulating a language model into producing output its safety training was designed to refuse. It’s done through the prompt or the conversation rather than through code, which is why traditional application security controls don’t catch it.
How do you prevent LLM jailbreaks?
You can’t prevent them entirely. You reduce attack success rate by layering controls: input normalization and filtering, guard model classification, output filtering, conversation-level monitoring, and periodic red teaming. Measure the result with a benchmark like HarmBench so you know whether the layers are working.
What is the difference between prompt injection and jailbreaking?
Prompt injection is the broader category, covering any input that overrides intended instructions, including instructions hidden in documents or web pages the model reads. Jailbreaking specifically targets the model’s safety behavior. OWASP tracks both under LLM01:2025.
Can guardrails completely stop jailbreaks?
No. Tree of Attacks with Pruning defeated LlamaGuard while jailbreaking GPT-4-Turbo and GPT-4o at over 80% success. Guardrails raise cost and catch the bulk of unsophisticated attempts, which is worth doing, but treating them as complete coverage is how systems get compromised.
Does perplexity filtering still work against GCG attacks?
Partially. It was an effective detector for gibberish adversarial suffixes when Jain and colleagues benchmarked it in 2023, but the AmpleGCG work showed that simply repeating the prompt before the suffix lowers overall perplexity enough to slip past the threshold while keeping around 80% attack success. Keep it as a cheap filter, not as coverage.
How often should you red team an LLM application?
Quarterly at minimum, plus after any model version upgrade, system prompt change, or new tool integration. Given how quickly new attack techniques circulate, an annual assessment is close to no assessment. This sits alongside the rest of your AI security best practices rather than replacing any of them.
Does defending against jailbreaks make the model worse at its job?
Sometimes. Paraphrasing defenses can mangle technical inputs, and aggressive filtering produces false refusals on legitimate queries. Sophos reported MMLU accuracy holding at 46.8% and 49.2% after their salting intervention, which suggests model-layer work doesn’t have to cost capability. Test utility alongside safety, always.
Where to go next
The single highest-value thing you can do after reading this is get a baseline number. Pick JailbreakBench or HarmBench, run it against your current stack, and write down the attack success rate. You’ll probably dislike the number. That’s the point of having it.