Jailbreak detection moves inside the model: why text-level filters lost the arms race

TL;DR: Text-level jailbreak and prompt injection detectors can be evaded, in some cases 100% of the time (arXiv 2504.11168). A different defense class reads the model’s internal representations. Kadali and Papalexakis (UC Riverside, arXiv 2602.11495) found jailbreak prompts separable from benign ones in the hidden states of eight models, and on one abliterated model, skipping jailbreak-susceptible layers blocked 78 of 100 jailbreaks while 94 of 100 benign prompts behaved normally. Prompt injection detection is already broken at the text level. This is one response: check what the model is doing internally, not only what the text says.
Your jailbreak detector is checking the wrong thing
Text-level guardrails classify what a prompt or response says, and attackers can change what it says without changing what it means. Hackett et al. (arXiv 2504.11168) evaded six commercial and open prompt injection and jailbreak detectors, including Azure Prompt Shield and Meta Prompt Guard, and emoji smuggling alone evaded all of them 100% of the time; the prompt injection detection post walks through those results.
A different approach exists. Instead of classifying the text, analyze what happens inside the model.
Why is the text-level arms race so hard to win?
Text filters are losing because attackers control the optimization target. Defenders publish a filter. Attackers observe its behavior (most commercial detectors are API-accessible) and optimize evasions offline, for example by ranking word importance on an open white-box model and transferring the result to the black-box target, as Hackett et al. did. Defenders retrain. Attackers adapt. The loop has not converged in the defender’s favor.
graph LR
A["Attacker crafts evasion"] --> B["Bypasses text filter"]
B --> C["Harmful output reaches user"]
C --> D["Defender updates filter"]
D --> E["Attacker adapts technique"]
E --> B
style A fill:#d32f2f,color:#fff
style D fill:#1976d2,color:#fff
The broader evidence points the same way. A systematization-of-knowledge study of jailbreak guardrails (Wang et al., arXiv 2506.10597) classifies guardrails along six dimensions (intervention stage, technical paradigm, safety granularity, reactiveness, applicability and explainability), benchmarks nine of them, from perplexity filters and SmoothLLM to Llama Guard, Prompt Guard and GuardReasoner, against nine jailbreak attacks, and finds that “no single guardrail excels across all dimensions”: each trades security against latency, memory or false positives.
Multi-turn attacks expose a deeper structural limit. The Mastermind framework (Li et al., arXiv 2601.05445) reached 95% jailbreak success on Qwen 2.5 72B and 94% on DeepSeek V3 with conversations that build harmful intent across individually mild turns. Each turn can pass a filter that judges one message at a time. Filters that evaluate isolated messages cannot see the conversational trajectory.
The arms race at the text layer rewards attacker sophistication. Every improvement in filtering produces a corresponding improvement in evasion. The defender’s investment depreciates. The attacker’s compounds.
What do jailbreaks look like inside the model?
They leave traces. Not only in the text, where attackers can disguise intent, but in the activation patterns of internal layers, where the model’s processing of the request is encoded before generation begins.
Kadali and Papalexakis (UC Riverside, arXiv 2602.11495) ran tensor decomposition on the hidden states of eight models: base and instruction-tuned versions of GPT-J-6B, LLaMA-3.1-8B and Mistral-7B, an abliterated LLaMA-3.1-8B, and the state-space model Mamba-2.8b. They stacked each layer’s representations into third-order tensors (prompts × sequence length × hidden dimensions) and applied CANDECOMP/PARAFAC (CP) decomposition to find low-rank patterns that distinguish jailbreak prompts from benign ones.
The finding: jailbreak and benign prompts become reliably separable at early depths, and the separation persists through later layers. It appears across all eight models tested, including the state-space model, so it is not specific to transformer attention. Jailbreak prompts are encoded differently from benign ones in the model’s internal representations, even when the surface text is designed to look harmless.
This aligns with broader work in representation engineering (Zou et al., Center for AI Safety, arXiv:2310.01405), which demonstrated that models encode traits like honesty, power-seeking, and morality as identifiable directions in activation space. The insight: if safety-relevant concepts have consistent internal representations, attacks that try to subvert safety should produce detectable perturbations in those representations.
A parallel line of research (arXiv:2507.11878) shows that models represent harmfulness and refusal as separate directions, and that some jailbreaks work by suppressing the refusal signal while the model’s internal judgment of harmfulness stays intact. The same paper used that harmfulness representation as a “Latent Guard” that performed comparably to or better than Llama Guard 3 8B across jailbreak methods. Further work (arXiv:2502.17420) finds that refusal is not one direction but several independent directions and multi-dimensional concept cones. The practical point: a jailbreak can make a request look harmless at the text level while the model’s own harmfulness signal still fires, and a monitor that reads that signal can catch what a text filter passes.
How does internal representation detection work in practice?
The Kadali approach has three components, all operating at inference time with no fine-tuning required.
Step 1: Extract internal representations. During inference, capture the hidden states and multi-head attention outputs from each layer. Reading them does not modify the model’s computation.
Step 2: Tensor decomposition and scoring. Apply CP decomposition to produce low-rank factors that capture how prompts are internally encoded, and train a lightweight classifier (logistic regression) on the prompt factors. The classifier gives a per-layer probability that the input is a jailbreak, which also identifies the layers most susceptible to jailbreak-style perturbation.
Step 3: Intervene. For a prompt scored as a jailbreak, skip the high-susceptibility layers during the forward pass. This disrupts the jailbreak while leaving most benign behavior intact. In the paper’s test on an abliterated LLaMA-3.1-8B (a model with its refusal direction removed), bypassing layer outputs blocked 78 of 100 jailbreak prompts and preserved normal behavior on 94 of 100 benign prompts. Bypassing only attention heads was weaker: 61 blocked, 92 preserved.
| Approach | Where it operates | Requires fine-tuning | Reported effect | Benign behavior |
|---|---|---|---|---|
| Text filters (commercial) | Before or after generation, on text | No | Evaded up to 100% by character injection | False positives rise with strictness |
| Kadali tensor decomposition + layer bypass | Internal layers, during inference | No | 78 of 100 jailbreaks blocked (one abliterated model) | 94 of 100 benign prompts preserved |
| HiddenDetect (arXiv:2502.14744) | Hidden states of vision-language models | No | Better LVLM jailbreak detection than prior methods | Not compared here |
| Circuit Breakers (Gray Swan AI and collaborators) | Internal representations | Yes (training-time) | Large reductions in harmful output reported | Authors report little utility loss |
The practical advantage: the detection half can run alongside an unmodified model. You do not need to retrain the model or change its weights. You attach a monitor that reads internal states and makes a classification decision in parallel with generation. The mitigation half does need a hook in the forward pass to skip layers, which most hosted APIs do not offer. Treat the 78%/94% figures as a proof of concept: one model, chosen because its built-in refusal was removed, and 200 test prompts.
HiddenDetect (arXiv:2502.14744) is a related, tuning-free approach for vision-language models that monitors safety-relevant signals in hidden activations and reports better jailbreak detection than prior methods on those models. Different method, different modality, same conclusion: jailbreaks leave internal traces detectable by more than one technique.
What are the honest trade-offs?
The 78% block rate means 22% of jailbreaks still got through, and the authors found most of those were persona or roleplay prompts. That is a real limitation. Text filters, when functioning, can catch some of that remainder. The two layers are complementary, not competing.
More concerning: obfuscated activation attacks (arXiv:2412.09565) can specifically target internal representation defenses. By optimizing adversarial inputs that keep the jailbreak working while producing activation patterns that resemble benign prompts, attackers reduced the recall of harmfulness probes from 100% to 0% while keeping a 90% jailbreak rate.
This sounds like the same arms race restarting at a deeper layer. In one sense, it is. But there is an asymmetry that favors defenders at the representation layer.
Obfuscation at the text level is cheap. Character injection, encoding substitution and synonym swaps cost the attacker almost nothing, and the model still follows the harmful instruction with full capability. Obfuscation at the representation level is more expensive. To produce activations that look benign while carrying out a harmful task, the attacker must optimize against the monitor and constrain the model’s internal computation. The obfuscation paper itself found that obfuscation reduced performance on a complex task (writing SQL code). The attacker pays a real cost that does not exist at the text level.
The 94% benign preservation rate is the other side of the equation. Six disrupted benign prompts out of 100 means roughly one in seventeen legitimate requests affected. For high-stakes applications (medical, legal, financial), that may be acceptable. For consumer chatbots with millions of daily interactions, a 6% false positive rate generates significant support load. Tuning the threshold trades false positives for missed attacks. This is the familiar precision-recall trade-off, and no detection system escapes it.
Large public red-teaming exercises add context. In Gray Swan’s agent red-teaming competition (Zou et al., arXiv 2507.20526), almost 2,000 participants made about 1.8 million attacks on agents built on 22 frontier models across 44 scenarios and produced over 60,000 successful policy violations; every model was broken on every target behavior at least once. Even the best model-level defenses let attacks through. Adding representation detection as an independent layer compounds the defense: an attack must evade both model-level alignment and representation monitoring at the same time.
Where does this fit in the defense stack?
Internal representation detection is not a replacement for text filtering. It is a new layer that changes the defensive architecture from single-plane to multi-plane.
graph TD
A["Input arrives"] --> B["Input filter<br/>(prompt injection detection)"]
B --> C["Model inference begins"]
C --> D["Internal representation monitor<br/>(tensor decomposition / probes)"]
D -->|"Jailbreak detected"| E["Block or disrupt generation"]
D -->|"Benign"| F["Model generates output"]
F --> G["Output filter<br/>(harmful content detection)"]
G -->|"Harmful"| H["Block output"]
G -->|"Clean"| I["Response delivered"]
style D fill:#ff6f00,color:#fff
style E fill:#d32f2f,color:#fff
style H fill:#d32f2f,color:#fff
The defense-in-depth architecture gains a new middle layer. Input filters catch obvious attacks before they reach the model. Representation monitors catch attacks during inference. Output filters catch anything that leaks through both. Each layer operates on different signals. An attack that evades one layer encounters independent detection at the next. For how this fits with the other agent-level controls, see the defense stack for secure agents.
Circuit Breakers (arXiv:2406.04313) offer a complementary approach at the same layer. Where representation detection monitors and flags, Circuit Breakers intervene: training teaches the model to reroute harmful internal representations while it generates. The trade-off: Circuit Breakers require training-time integration, while detection runs next to an unmodified model. In practice, deploying both, monitoring via probes or tensor decomposition and intervention via Circuit Breakers, creates a defense that both detects and disrupts.
For red-teaming exercises, internal representation analysis opens a new testing dimension. Red teams can now target the representation layer specifically, testing whether adversarial inputs can produce activations that fool both the text filter and the representation monitor at the same time. This is a harder adversarial objective than fooling either layer alone, which is the point.
The open frontier is multi-turn. Current representation detection analyzes one prompt at a time. Multi-turn attacks spread harmful intent across turns, each of which may look benign in latent space on its own. Detecting intent that accumulates across a conversation in representation space is unsolved, and attacks like Mastermind (95% against Qwen 2.5 72B) are exactly the case per-turn monitors are not built for. Until that is solved, the defense stack still depends on conversation-level behavioral monitoring as an outer layer.
Frequently asked questions
How does internal representation jailbreak detection work?
Instead of classifying the text of a prompt or response, it analyzes activation patterns in the model’s hidden layers during inference. Kadali and Papalexakis (UC Riverside, arXiv:2602.11495) apply tensor decomposition to hidden states and train a lightweight classifier on the factors to separate jailbreak from benign prompts. For mitigation they skip jailbreak-susceptible layers at inference. On an abliterated LLaMA-3.1-8B this blocked 78 of 100 jailbreak prompts while 94 of 100 benign prompts behaved normally, with no fine-tuning.
Can internal representation defenses be bypassed?
Yes. Obfuscated activation attacks (arXiv:2412.09565) reduced harmfulness probe recall from 100% to 0% while keeping a 90% jailbreak rate. Internal representation detection is not a silver bullet. It is one layer in a defense-in-depth stack. The advantage over text filtering: obfuscation has to be optimized against the monitor and can degrade the model’s performance, unlike text-level evasion, which is cheap.
Why are text-level jailbreak detectors losing the arms race?
They judge surface text. Hackett et al. (arXiv 2504.11168) evaded six detectors, including Azure Prompt Shield and Meta Prompt Guard, with character injection and word-level adversarial perturbations; emoji smuggling evaded all of them 100% of the time. Internal representation detection changes the attacker’s problem from “write harmful text that looks benign” to “make the model’s internal processing look benign”, which is harder.
What is the difference between circuit breakers and representation detection?
Circuit Breakers (arXiv:2406.04313) are trained into the model so harmful internal representations get rerouted during generation. Representation detection (Kadali et al.) reads internal states and classifies them, paired in that paper with an inference-time layer bypass rather than retraining. Circuit Breakers require model-level integration. Detection can run alongside an unmodified model. Both address the same layer but serve different functions in the defense chain.
Do multi-turn jailbreaks bypass internal representation detection?
Multi-turn attacks are the open frontier. The Mastermind framework (arXiv:2601.05445) reached 95% success on Qwen 2.5 72B with conversations whose individual turns look benign while harmful intent accumulates. Current representation detection works one prompt at a time. Detecting multi-turn intent in latent space remains unsolved.
Further reading: Prompt injection detection is already broken explains why text-level detection fails structurally. Defense-in-depth for LLM applications covers the full security architecture that representation detection fits into. Activation-space attacks covers the offensive side of the same internals. Jailbreaking in production traces the evolution from novelty attacks to systematic exploitation.